Community
Participate
Working Groups
I have an aspect specification in a file called SimpleTracing.java whose contents I give below. The command ajc SimpleTracing.java throws an exception that I give at the end of this message. Note that the pointcut references a class called SampleClass. If I compile SampleClass.java before I compile SimpleTracing.java then there is no NullPointerException. /* * Created on Nov 13, 2003 * * To change the template for this generated file go to * Window>Preferences>Java>Code Generation>Code and Comments */ /** * @author Arun_Sh * * To change the template for this generated type comment go to * Window>Preferences>Java>Code Generation>Code and Comments */ aspect SimpleTracing { pointcut traceCall(): call (void SampleClass.foo(..)); before(): traceCall() { System.out.println ("Entering: " + thisJoinPoint); } after(): traceCall() { System.out.println ("Exiting: " + thisJoinPoint); } } The exception message is (the message is for ajc -verbose SimpleTracing.java): zipfile classpath entry does not exist: C:\j2sdk1.4.1_02\jre\lib\i18n.jar directory classpath entry does not exist: C:\j2sdk1.4.1_02\jre\classes compiling C:\Arun\AspectJTrial\SimpleTracing.java compiling C:\Arun\AspectJTrial\.\SampleClass.java java.lang.NullPointerException at org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding.fields(Sou rceTypeBinding.java:363) at org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding.faultInTyp esForFieldsAndMethods(SourceTypeBinding.java:351) at org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope.faultIn Types(CompilationUnitScope.java:354) at org.eclipse.jdt.internal.compiler.Compiler.process(Compiler.java:531) at org.aspectj.ajdt.internal.compiler.AjCompiler.process(AjCompiler.java :65) at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:338) at org.aspectj.ajdt.internal.core.builder.AjBuildManager.performCompilat ion(AjBuildManager.java:373) at org.aspectj.ajdt.internal.core.builder.AjBuildManager.doBuild(AjBuild Manager.java:125) at org.aspectj.ajdt.internal.core.builder.AjBuildManager.batchBuild(AjBu ildManager.java:70) at org.aspectj.ajdt.ajc.AjdtCommand.doCommand(AjdtCommand.java:99) at org.aspectj.ajdt.ajc.AjdtCommand.runCommand(AjdtCommand.java:53) at org.aspectj.tools.ajc.Main.run(Main.java:217) at org.aspectj.tools.ajc.Main.runMain(Main.java:155) at org.aspectj.tools.ajc.Main.main(Main.java:72) C:\Arun\AspectJTrial\SampleClass.java:0 Internal compiler error java.lang.NullPointerException at org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding.fields(Sou rceTypeBinding.java:363) at org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding.faultInTyp esForFieldsAndMethods(SourceTypeBinding.java:351) at org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope.faultIn Types(CompilationUnitScope.java:354) at org.eclipse.jdt.internal.compiler.Compiler.process(Compiler.java:531) at org.aspectj.ajdt.internal.compiler.AjCompiler.process(AjCompiler.java :65) at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:338) at org.aspectj.ajdt.internal.core.builder.AjBuildManager.performCompilat ion(AjBuildManager.java:373) at org.aspectj.ajdt.internal.core.builder.AjBuildManager.doBuild(AjBuild Manager.java:125) at org.aspectj.ajdt.internal.core.builder.AjBuildManager.batchBuild(AjBu ildManager.java:70) at org.aspectj.ajdt.ajc.AjdtCommand.doCommand(AjdtCommand.java:99) at org.aspectj.ajdt.ajc.AjdtCommand.runCommand(AjdtCommand.java:53) at org.aspectj.tools.ajc.Main.run(Main.java:217) at org.aspectj.tools.ajc.Main.runMain(Main.java:155) at org.aspectj.tools.ajc.Main.main(Main.java:72) !! no source information available !! ABORT Exception thrown from AspectJ 1.1.1 This might be logged as a bug already -- find current bugs at http://bugs.eclipse.org/bugs/buglist.cgi?product=AspectJ&component=Compiler Bugs for exceptions thrown have titles File:line from the top stack, e.g., "SomeFile.java:243" If you don't find the exception below in a bug, please add a new bug at http://bugs.eclipse.org/bugs/enter_bug.cgi?product=AspectJ To make the bug a priority, please include a test program that can reproduce this exception. null java.lang.NullPointerException at org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding.fields(Sou rceTypeBinding.java:363) at org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding.faultInTyp esForFieldsAndMethods(SourceTypeBinding.java:351) at org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope.faultIn Types(CompilationUnitScope.java:354) at org.eclipse.jdt.internal.compiler.Compiler.process(Compiler.java:531) at org.aspectj.ajdt.internal.compiler.AjCompiler.process(AjCompiler.java :65) at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:338) at org.aspectj.ajdt.internal.core.builder.AjBuildManager.performCompilat ion(AjBuildManager.java:373) at org.aspectj.ajdt.internal.core.builder.AjBuildManager.doBuild(AjBuild Manager.java:125) at org.aspectj.ajdt.internal.core.builder.AjBuildManager.batchBuild(AjBu ildManager.java:70) at org.aspectj.ajdt.ajc.AjdtCommand.doCommand(AjdtCommand.java:99) at org.aspectj.ajdt.ajc.AjdtCommand.runCommand(AjdtCommand.java:53) at org.aspectj.tools.ajc.Main.run(Main.java:217) at org.aspectj.tools.ajc.Main.runMain(Main.java:155) at org.aspectj.tools.ajc.Main.main(Main.java:72) 1 fail|abort, 1 error
Created attachment 6784 [details] The source file for the SampleClass referenced in the pointcut
I've put the testcases into the aspectj harness that I run and I can't recreate the failure. Checking with Jim H, there doesn't seem to be any reason why the compiler would pull in SampleClass.java if only being told to compile SimpleTracing.java. We can see from the two lines: zipfile classpath entry does not exist: C:\j2sdk1.4.1_02\jre\lib\i18n.jar directory classpath entry does not exist: C:\j2sdk1.4.1_02\jre\classes compiling C:\Arun\AspectJTrial\SimpleTracing.java compiling C:\Arun\AspectJTrial\.\SampleClass.java java.lang.NullPointerException at org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding.fields (SourceTypeBinding.java:363) That *something* is causing SampleClass to be pulled in. I guess I need confirmation that you are definetly compiling it using AJC 1.1.1 and just the command 'ajc -verbose SimpleTracing.java' - and do you have any environment variables set that might influence the compilation? (Maybe there is something in the face that the SampleClass.java reference is prefixed with a './' .... thanks. Andy.
Hold that thought ... I recreated it. The 'faulting in' of SampleClass appears to occur if the source can be found on the classpath. I'll continue to investigate. I knew that './' was a clue ;)
Fixed. The default behaviour within the eclipse compiler is to dig around classpath components (represented as ClasspathDirectory objects) for source when it can't find binary. The fix is to add code to AjBuildManager such that when it builds the FileSystem object (in getLibraryAccess) for the compilation, we override the default and force ClasspathDirectory objects to only look for BINARY. Patch sent to Adrian for integration.
*** Bug 46816 has been marked as a duplicate of this bug. ***
Fixed by patch contributed by Andy Clement.
updating target flag to indicate inclusion in 1.2 release.