Community
Participate
Working Groups
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).
tagging with M4 ...
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.
fix now available in latest published build