Bug 108370 - NPE at SourceTypeBinding.java:411 on enum switch in intertype method woven into binary class
Summary: NPE at SourceTypeBinding.java:411 on enum switch in intertype method woven in...
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: 1.5.0M3   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 1.5.0 M4   Edit
Assignee: Adrian Colyer CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-08-30 10:27 EDT by Aske Simon Christensen CLA
Modified: 2005-08-31 12:22 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Aske Simon Christensen CLA 2005-08-30 10:27:42 EDT
I have some class Q:

package et;
public class Q {}

and the following aspect:

public aspect EnumTest {
    public static enum Test {
	A,B,C
    }

    public void et.Q.foo(Test t) {
	switch (t) {
	case B:
	    break;
	}
    }
}

First I compile Q. Then I weave in the aspect:

ajc -1.5 EnumTest.java -inpath et

and get this exception:

java.lang.NullPointerException
        at
org.aspectj.org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding.addSyntheticFieldForSwitchEnum(SourceTypeBinding.java:411)
        at
org.aspectj.org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding.addSyntheticMethodForSwitchEnum(SourceTypeBinding.java:457)
        at
org.aspectj.org.eclipse.jdt.internal.compiler.ast.SwitchStatement.analyseCode(SwitchStatement.java:83)
        at
org.aspectj.org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.analyseCode(MethodDeclaration.java:84)
        at
org.aspectj.ajdt.internal.compiler.ast.InterTypeMethodDeclaration.analyseCode(InterTypeMethodDeclaration.java:73)
        at
org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.internalAnalyseCode(TypeDeclaration.java:720)
        at
org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.analyseCode(TypeDeclaration.java:270)
        at
org.aspectj.org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.analyseCode(CompilationUnitDeclaration.java:80)
        at
org.aspectj.org.eclipse.jdt.internal.compiler.Compiler.process(Compiler.java:517)
        at
org.aspectj.org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:329)
        at
org.aspectj.ajdt.internal.core.builder.AjBuildManager.performCompilation(AjBuildManager.java:728)
        at
org.aspectj.ajdt.internal.core.builder.AjBuildManager.doBuild(AjBuildManager.java:206)
        at
org.aspectj.ajdt.internal.core.builder.AjBuildManager.batchBuild(AjBuildManager.java:140)
        at org.aspectj.ajdt.ajc.AjdtCommand.doCommand(AjdtCommand.java:112)
        at org.aspectj.ajdt.ajc.AjdtCommand.runCommand(AjdtCommand.java:60)
        at org.aspectj.tools.ajc.Main.run(Main.java:324)
        at org.aspectj.tools.ajc.Main.runMain(Main.java:238)
        at org.aspectj.tools.ajc.Main.main(Main.java:82)

Apparently, it only appears if the switch has at least one case construct (i.e.
it does not happen on default).
Comment 1 Adrian Colyer CLA 2005-08-30 11:10:34 EDT
tagging with M4 ...
Comment 2 Adrian Colyer CLA 2005-08-31 09:19:02 EDT
The problem occurs when the target type of the ITD method is placed on the
inpath, and the code inside the method requires the generation of one or more
synthetic members. Since the target type is only known to JDT as a
*Binary*TypeBinding these members can't be added (and doing so would give a
lousy independent compilation story anyway). Resolved by adding the synthetic
members to the declaring type of the ITD instead. 
Comment 3 Adrian Colyer CLA 2005-08-31 12:22:56 EDT
fix now available in latest published build