Bug 160167 - NPE when using crossrefs option for iajc ant task
Summary: NPE when using crossrefs option for iajc ant task
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Ant (show other bugs)
Version: 1.5.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 1.5.4   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-10-08 18:51 EDT by Arjun Singh CLA
Modified: 2007-10-25 05:29 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Arjun Singh CLA 2006-10-08 18:51:11 EDT
The ant task is shown below.  I ommited the full paths to the values of inpath, outJar, and argfiles, because they are somewhat long (hence the "..." before the file names):

<iajc  
crossrefs="true" argfiles="...\weave-jars.txt" inpath="...\org.eclipse.core.runtime_3.2.0.v20060603.jar" outJar="...\org.eclipse.core.runtime_3.2.0.v20060603_woven.jar">
  <classpath>
    <pathelement location="C:\aspectj1.5\lib\aspectjrt.jar"/>
      <fileset dir="${plugins.dir}">
        <include name="**/*.jar"/>
      </fileset>
  </classpath>
</iajc>

My argfile only contains the absolute path of a single .aj file, which contains one aspect.  The aspect is shown below.  It is very basic - advice bodies simply toggle a boolean variable.  

public aspect FFDC {
  public static boolean bit = false;
  protected pointcut ffdcScope(): within(org.eclipse..*);	
  protected pointcut excluded():  within(org.eclipse.ffdc.FFDC+)
	|| within(org.eclipse.core.internal.runtime.PlatformActivator);
	
  before(CoreException c): ffdcScope() && !excluded() 
      && handler(CoreException+) && args(c) {
    bit = !bit;
  }
	
  after() throwing(CoreException c): ffdcScope() && !excluded() && !handler(*) {
    bit = !bit;
  }
	
  after(Plugin activator): execution(void PlatformActivator.start(..)) 
      && this(activator) {
    bit = !bit;
  }
}

This task worked properly before I added "crossrefs=true".  After adding this option, I get the following error:

weave-C:\eclipse\sdk-aspect-package\eclipse\plugins\org.eclipse.core.runtime_3.2.0.v20060603.jar:
     [iajc] abort ABORT -- (NullPointerException) null
     [iajc] null
     [iajc] java.lang.NullPointerException
     [iajc]     at org.aspectj.ajdt.internal.core.builder.AjBuildManager.doBuild(AjBuildManager.java:313)
     [iajc]     at org.aspectj.ajdt.internal.core.builder.AjBuildManager.batchBuild(AjBuildManager.java:163)
     [iajc]     at org.aspectj.ajdt.ajc.AjdtCommand.doCommand(AjdtCommand.java:112)
     [iajc]     at org.aspectj.ajdt.ajc.AjdtCommand.runCommand(AjdtCommand.java:60)
     [iajc]     at org.aspectj.tools.ajc.Main.run(Main.java:367)
     [iajc]     at org.aspectj.tools.ajc.Main.runMain(Main.java:246)
     [iajc]     at org.aspectj.tools.ant.taskdefs.AjcTask.executeInSameVM(AjcTask.java:1282)
     [iajc]     at org.aspectj.tools.ant.taskdefs.AjcTask.execute(AjcTask.java:1080)
     [iajc]     at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
     [iajc]     at org.apache.tools.ant.Task.perform(Task.java:364)
     [iajc]     at org.apache.tools.ant.Target.execute(Target.java:341)
     [iajc]     at org.apache.tools.ant.Target.performTasks(Target.java:369)
     [iajc]     at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
     [iajc]     at org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleCheckExecutor.java:37)
     [iajc]     at org.apache.tools.ant.Project.executeTargets(Project.java:1068)
     [iajc]     at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:382)
     [iajc]     at org.apache.tools.ant.taskdefs.CallTarget.execute(CallTarget.java:107)
     [iajc]     at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
     [iajc]     at org.apache.tools.ant.Task.perform(Task.java:364)
     [iajc]     at org.apache.tools.ant.Target.execute(Target.java:341)
     [iajc]     at org.apache.tools.ant.Target.performTasks(Target.java:369)
     [iajc]     at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
     [iajc]     at org.apache.tools.ant.Project.executeTarget(Project.java:1185)
     [iajc]     at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:40)
     [iajc]     at org.apache.tools.ant.Project.executeTargets(Project.java:1068)
     [iajc]     at org.apache.tools.ant.Main.runBuild(Main.java:668)
     [iajc]     at org.apache.tools.ant.Main.startAnt(Main.java:187)
     [iajc]     at org.apache.tools.ant.launch.Launcher.run(Launcher.java:246)
     [iajc]     at org.apache.tools.ant.launch.Launcher.main(Launcher.java:67)
Comment 1 Andrew Clement CLA 2006-10-09 03:26:17 EDT
There is a bug here - it shouldn't crash. But crossrefs is a very old option - are you sure it is what you want to use?
If you want an information on what was woven where, use '-showWeaveInfo'.  The crossrefs option produces an emacs compatible ajsym file that is never used by anything other than emacs...
Comment 2 Andrew Clement CLA 2006-10-09 06:03:19 EDT
-crossrefs is similar to -emacssym in that they are both a way to cause the compiler to generate a structure model and relationships map outside of AJDT (command line or through Ant).  I can make the command line compiler fail with something as easy as:

ajc -crossrefs -inpath x.jar

the problem is that we don't initialize the output location correctly for the crossrefs option (and so NPE).  The workaround is to supply an output directory, so this works:

ajc -crossrefs -inpath x.jar -d output

In the example Ant script here, the output location is a jar and nothing in the -crossrefs processing understands jar locations as the output destination.

Are you planning to use the AspectJ classes to parse this serialized object yourself?
Comment 3 Andrew Clement CLA 2006-10-09 08:34:47 EDT
the fix is in - we will no longer NPE.  However, if outjar is used, we won't put the .ajsym file into the output jar - that would be a new enhancement request I think.  As I mentioned previously, to see the result of weaving it is best to use showWeaveInfo - or if you want to post-process the weaving messages then supply your own message handler and you can do whatever you like with the messages as they come out.
Comment 4 Arjun Singh CLA 2006-10-09 18:25:45 EDT
The -showWeaveInfo option shows me what I need, so I can use that.  Thanks for your help.
Comment 5 Mik Kersten CLA 2006-10-18 16:02:08 EDT
Ron Bodkin pointed me at this report.  It made me wonder if we should be putting the .ajsym file, or something equivalent, into the META-INF directory of JARs that should expose crosscutting structure.  But as you point out Andy, that would be a separate enhancement request.
Comment 6 Andrew Clement CLA 2007-10-25 05:29:16 EDT
nothing further to do for this bug - the final comments refer to what would be a future enhancement that has yet to be requested...