Bug 485583 - NullPointerException in org.aspectj.ajdt.internal.compiler.ast.PointcutDeclaration
Summary: NullPointerException in org.aspectj.ajdt.internal.compiler.ast.PointcutDeclar...
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: unspecified   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 1.8.9   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-01-11 16:41 EST by Oliver CLA
Modified: 2016-02-10 18:59 EST (History)
2 users (show)

See Also:


Attachments
Tar file with maven project to reproduce error (27.50 KB, application/x-gzip)
2016-01-11 16:41 EST, Oliver CLA
no flags Details
ajcore file (18.85 KB, text/plain)
2016-02-09 15:25 EST, Oliver CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Oliver CLA 2016-01-11 16:41:26 EST
Created attachment 259112 [details]
Tar file with maven project to reproduce error

During maven build with aspectj-maven-plugin I got the following NullPointerException:

[ERROR] Failed to execute goal org.codehaus.mojo:aspectj-maven-plugin:1.8:compile (compile) on project patterntesting-check-rt: AJC compiler errors:
[ERROR] abort ABORT -- (NullPointerException) null
[ERROR] null
[ERROR] java.lang.NullPointerException
[ERROR] at org.aspectj.ajdt.internal.compiler.ast.PointcutDeclaration.isAtAspectJ(PointcutDeclaration.java:122)
[ERROR] at org.aspectj.ajdt.internal.compiler.ast.PointcutDeclaration.postParse(PointcutDeclaration.java:94)
[ERROR] at org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ClassScope.postParse(ClassScope.java:215)
[ERROR] at org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ClassScope.buildFieldsAndMethods(ClassScope.java:191)
[ERROR] at org.aspectj.org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope.buildFieldsAndMethods(CompilationUnitScope.java:84)
[ERROR] at org.aspectj.ajdt.internal.compiler.lookup.AjLookupEnvironment.completeTypeBindings(AjLookupEnvironment.java:141)
[ERROR] at org.aspectj.org.eclipse.jdt.internal.compiler.Compiler.internalBeginToCompile(Compiler.java:852)
[ERROR] at org.aspectj.org.eclipse.jdt.internal.compiler.Compiler.beginToCompile(Compiler.java:385)
[ERROR] at org.aspectj.org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:428)
[ERROR] at org.aspectj.ajdt.internal.core.builder.AjBuildManager.performCompilation(AjBuildManager.java:1036)
[ERROR] at org.aspectj.ajdt.internal.core.builder.AjBuildManager.performBuild(AjBuildManager.java:272)
[ERROR] at org.aspectj.ajdt.internal.core.builder.AjBuildManager.batchBuild(AjBuildManager.java:185)
[ERROR] at org.aspectj.ajdt.ajc.AjdtCommand.doCommand(AjdtCommand.java:114)
[ERROR] at org.aspectj.ajdt.ajc.AjdtCommand.runCommand(AjdtCommand.java:60)
[ERROR] at org.aspectj.tools.ajc.Main.run(Main.java:371)
[ERROR] at org.aspectj.tools.ajc.Main.runMain(Main.java:248)
[ERROR] at org.codehaus.mojo.aspectj.AbstractAjcCompiler.execute(AbstractAjcCompiler.java:537)

From the listed stacktrace it seems to be a bug of the AspectJ compiler or AJDT. The problem only occurs on Linux (tested with Ubuntu 14.04 and Debian) with Java 8 or Java 7, and with Maven 3.3 and Maven 3.0. The bug does not appear on MacOS.

Steps to reproduce the error:

1. Extract the attached 'testcase.tgz' on a Linux machine
2. go to the directory testcase/patterntesting-check-rt
3. start 'mvn clean compile'
Comment 1 Oliver CLA 2016-02-09 15:25:46 EST
Created attachment 259673 [details]
ajcore file

Looks like the build server runs only an JRE, not an JDK. But nevertheless a NPE should not happen...
Comment 2 Andrew Clement CLA 2016-02-10 18:49:10 EST
Actually an AspectJ bug. Thanks for the testcode. I've fixed it up and committed the changes into AspectJ with a test.

The problem was that the code was attempting to look at annotations too soon - looking for the resolved type of an annotation just after parsing. I've moved the checks to later on (from postParse() into resolve()).
Comment 3 Andrew Clement CLA 2016-02-10 18:59:37 EST
Worth mentioning it does actually report an error now it is beyond the NPE - related to  abstract pointcuts in classes. If those were not abstract you would avoid the error and the NPE (or they need to be in an aspect).