Bug 551084 - NullPointerException at org.aspectj.ajdt.internal.core.builder.AjBuildManager.checkRtJar(AjBuildManager.java:1372)
Summary: NullPointerException at org.aspectj.ajdt.internal.core.builder.AjBuildManager...
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: 1.9.4   Edit
Hardware: PC Mac OS X
: P3 critical with 1 vote (vote)
Target Milestone: 1.9.5   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-09-16 03:01 EDT by Prashanth K CLA
Modified: 2019-09-18 08:33 EDT (History)
2 users (show)

See Also:


Attachments
This is the source jar that is used to compile and got error. (8.11 MB, application/java-archive)
2019-09-16 03:01 EDT, Prashanth K CLA
no flags Details
ajcore dump (5.13 KB, text/plain)
2019-09-16 05:08 EDT, Prashanth K CLA
no flags Details
Sample project in which i got the exception (25.00 KB, application/zip)
2019-09-16 06:46 EDT, Prashanth K CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Prashanth K CLA 2019-09-16 03:01:23 EDT
Created attachment 279870 [details]
This is the source jar that is used to compile and got error.

When i try ti run a simple aspectj program from terminal using ant task in build.xml with ajc-1.9.4 (attached the source jar) it throws me the following error.

Ajx:
     [echo] ##### Ajx list=arglist.lst class=build/classes/testing
      [ajc] ABORT
      [ajc] 	
      [ajc] Exception thrown from AspectJ 1.9.3
      [ajc] 
      [ajc] This might be logged as a bug already -- find current bugs at
      [ajc]   http://bugs.eclipse.org/bugs/buglist.cgi?product=AspectJ&component=Compiler
      [ajc] 
      [ajc] Bugs for exceptions thrown have titles File:line from the top stack, 
      [ajc] e.g., "SomeFile.java:243"
      [ajc] 
      [ajc] If you don't find the exception below in a bug, please add a new bug
      [ajc] at http://bugs.eclipse.org/bugs/enter_bug.cgi?product=AspectJ
      [ajc] To make the bug a priority, please include a test program
      [ajc] that can reproduce this exception.
      [ajc] 
      [ajc] when batch building BuildConfig[null] #Files=2 AopXmls=#0
      [ajc] null
      [ajc] java.lang.NullPointerException
      [ajc] 	at org.aspectj.ajdt.internal.core.builder.AjBuildManager.checkRtJar(AjBuildManager.java:1372)
      [ajc] 	at org.aspectj.ajdt.internal.core.builder.AjBuildManager.performBuild(AjBuildManager.java:231)
      [ajc] 	at org.aspectj.ajdt.internal.core.builder.AjBuildManager.batchBuild(AjBuildManager.java:189)
      [ajc] 	at org.aspectj.ajdt.ajc.AjdtCommand.doCommand(AjdtCommand.java:114)
      [ajc] 	at org.aspectj.ajdt.ajc.AjdtCommand.runCommand(AjdtCommand.java:60)
      [ajc] 	at org.aspectj.tools.ajc.Main.run(Main.java:371)
      [ajc] 	at org.aspectj.tools.ajc.Main.runMain(Main.java:248)
      [ajc] 	at org.aspectj.tools.ajc.Main.main(Main.java:84)
      [ajc] 
      [ajc] Sep 16, 2019 12:04:34 PM org.aspectj.weaver.tools.Jdk14Trace info
      [ajc] INFO: Dumping to /Users/prashanth-8239/AntProject/./ajcore.20190916.120434.011.txt
      [ajc] 
      [ajc] 1 fail|abort

BUILD FAILED

There are so many bugs in NPE but they are not occurred at AjBuildManager.checkRtJar(AjBuildManager.java:1372)
This is the latest release i guess and it throws an error.

kindly help me to come out of this error.

Regards,
prashanth.k
Comment 1 Prashanth K CLA 2019-09-16 03:13:57 EDT
This is my simple build.xml which is used to compile the aspect file.

<project name="AntProject">

    <target name="clean">
        <delete dir="build"/>
    </target>

    <taskdef name="ajc" classname="org.aspectj.tools.ant.taskdefs.AjcTask">
        <classpath>
                <pathelement location="/Users/prashanth-8239/aspectj/aspectjrt-1.9.4-sources.jar"/>
                <pathelement location="/Users/prashanth-8239/aspectj/aspectjtools-1.9.4-sources.jar"/>
        </classpath>
    </taskdef>

    <property name="list" value="arglist.lst"/>
    <property name="class" value="build/classes/testing"/>
    <property name="classes.dir" value="build/classes/testing"/>
    <property name="aspectjrt.jar" value="/Users/prashanth-8239/aspectj/aspectjrt-1.9.4-sources.jar"/>
    <property name="aspectjtools.jar" value="/Users/prashanth-8239/aspectj/aspectjtools-1.9.4-sources.jar"/>

    <target name="Ajx" description="compile {list} and run {class} of example">
        <echo message="##### Ajx list=${list} class=${class}"/>
        <!-- <antcall target="clean"/> -->
        <!--  can use ajc or iajc here  -->
        <ajc destdir="${classes.dir}" argfiles="${list}" fork="true">
                <classpath>
                        <pathelement location=${aspectjrt.jar}/>
                        <pathelement location=${aspectjtools.jar}/>
                </classpath>
        </ajc>
    </target>

    <target name="run" description="run {class} unless {norun} is set" unless="norun">
        <echo message="##### Ajx-run list=${list} class=${class}"/>
        <java classname="${class}" fork="yes">
                <classpath>
                        <pathelement path="${classes.dir}"/>
                        <pathelement path="${aspectjrt.jar}"/>
                </classpath>
        </java>
    </target>

</project>

---

My content inside arglist.lst file is,

src/testing/SampleAspect.java
src/testing/Sample.java

---
Comment 2 Prashanth K CLA 2019-09-16 05:08:55 EDT
Created attachment 279873 [details]
ajcore dump
Comment 3 Prashanth K CLA 2019-09-16 06:46:39 EDT
Created attachment 279881 [details]
Sample project in which i got the exception

This was the simple project which is created to run from terminal for testing Compile Time Weaving and i failed in this point where i got NullPointerException!

Kindly reply me ASAP.
Comment 4 Andrew Clement CLA 2019-09-16 16:11:08 EDT
Why are you supplying source jars on the classpath?  It looks like the problem is finding the runtime sources file which doesn't have the necessary attributes in its manifest. Really the classpath should contain the built version of aspectjrt (the one with classfiles in) called something like aspectjrt-1.9.4.jar.

Which might get you beyond it but you shouldn't really be supplying sources like that on the classpath - and I don't think the app will run if you do that when you run the compiled result, you will need to include the aspectjrt-1.9.4.jar built artifact.
Comment 5 Andrew Clement CLA 2019-09-16 16:13:40 EDT
guard committed.
Comment 6 Prashanth K CLA 2019-09-18 08:33:23 EDT
Hi Andrew,

Why are you supplying source jars on the classpath?

     When i failed to give the source jars on the classpath i got the error like

-------------------------------ERROR MESSAGE-------------------------------
Buildfile: /Users/prashanth-8239/AntProject/build.xml
     [echo] AspectjPATH - /Users/prashanth-8239/aspectj/1/files/lib

compile:
     [echo] list=arglist.lst class=/Users/prashanth-8239/AntProject/build/classes/testing/Sample
     [echo] AspectjPATH - /Users/prashanth-8239/aspectj/1/files/lib

clean:
   [delete] Deleting directory /Users/prashanth-8239/AntProject/build
      [ajc] The following attributes were ignored [fork]
      [ajc] Compiling 0 source and 1 arg files to /Users/prashanth-8239/AntProject/build/classes
      [ajc] [error] classpath error: unable to find org.aspectj.lang.JoinPoint (check that aspectjrt.jar is in your classpath)
      [ajc] 	

BUILD FAILED
-------------------------------END OF ERROR--------------------------------

     and after i came out of the NullPointerException, i got the error like 

-------------------------------ERROR MESSAGE-------------------------------
syntax error, annotations are only available if source level is 1.5 or greater
-------------------------------END OF ERROR--------------------------------

     and then i mentioned the <source="1.5"> argument in ajc tag and then i got the compiled file successfully :)

THANK YOU!