Bug 46671 - ajc throws NullPointerException when parsing pointcut specification.
Summary: ajc throws NullPointerException when parsing pointcut specification.
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: 1.1.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 1.2   Edit
Assignee: Jim Hugunin CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 46816 (view as bug list)
Depends on:
Blocks:
 
Reported: 2003-11-14 10:14 EST by Arun Shankar CLA
Modified: 2004-03-19 09:53 EST (History)
1 user (show)

See Also:


Attachments
The source file for the SampleClass referenced in the pointcut (537 bytes, text/plain)
2003-11-14 10:16 EST, Arun Shankar CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Arun Shankar CLA 2003-11-14 10:14:44 EST
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
Comment 1 Arun Shankar CLA 2003-11-14 10:16:55 EST
Created attachment 6784 [details]
The source file for the SampleClass referenced in the pointcut
Comment 2 Andrew Clement CLA 2004-01-08 04:29:00 EST
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.
Comment 3 Andrew Clement CLA 2004-01-08 04:38:05 EST
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 ;)
Comment 4 Andrew Clement CLA 2004-01-08 06:47:56 EST
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.
Comment 5 Jim Hugunin CLA 2004-01-12 04:36:34 EST
*** Bug 46816 has been marked as a duplicate of this bug. ***
Comment 6 Adrian Colyer CLA 2004-01-15 04:12:55 EST
Fixed by patch contributed by Andy Clement.
Comment 7 Adrian Colyer CLA 2004-03-19 09:53:00 EST
updating target flag to indicate inclusion in 1.2 release.