Hi,
We are doing migration of our project to Java 11 and got blocked by this
aspectjtools fail with NPE during maven build. Context:
1. Java 11 (AdoptOpenJDK jdk-11.0.10.9-hotspot)
2. aspectj-maven-plugin v1.14
3. aspectjtools v1.9.7
4. pom.xml snippet
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.14</version>
<configuration>
<complianceLevel>11</complianceLevel>
<source>11</source>
<target>11</target>
<showWeaveInfo>true</showWeaveInfo>
<verbose>true</verbose>
<aspectLibraries>
<aspectLibrary>
<groupId>xxx.xxx.xxx</groupId>
<artifactId>xxx-aspects</artifactId>
</aspectLibrary>
</aspectLibraries>
<includes>
<include>**/*.aj</include>
<include>**/*.class</include>
</includes>
<Xlint>cantFindType=ignore</Xlint>
<weaveDirectories>
<weaveDirectory>${project.build.directory}/classesToWeav</weaveDirectory>
</weaveDirectories>
</configuration>
<executions>
<execution>
<!-- Compile and
weave aspects after all classes compiled by javac -->
<phase>process-classes</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjtools</artifactId>
<version>1.9.7<version>
<scope>compile</scope>
</dependency>
</dependencies>
</plugin>
5. Stack trace:
[ERROR] Failed to execute goal
org.codehaus.mojo:aspectj-maven-plugin:1.14.0:compile (default) on project
xxx: AJC compiler errors:
[ERROR] abort ABORT -- (NullPointerException) null
[ERROR] null
[ERROR] java.lang.NullPointerException
[ERROR] at
org.aspectj.org.eclipse.jdt.internal.compiler.batch.ClasspathJmod.getModulesDeclaringPackage(ClasspathJmod.java:146)
[ERROR] at
org.aspectj.org.eclipse.jdt.internal.compiler.batch.ClasspathLocation.isPackage(ClasspathLocation.java:184)
[ERROR] at
org.aspectj.org.eclipse.jdt.internal.compiler.batch.ClasspathJmod.findClass(ClasspathJmod.java:55)
[ERROR] at
org.aspectj.org.eclipse.jdt.internal.compiler.batch.FileSystem.internalFindClass(FileSystem.java:544)
[ERROR] at
org.aspectj.org.eclipse.jdt.internal.compiler.batch.FileSystem.findClass(FileSystem.java:464)
[ERROR] at
org.aspectj.org.eclipse.jdt.internal.compiler.batch.FileSystem.findType(FileSystem.java:617)
[ERROR] at
org.aspectj.org.eclipse.jdt.internal.compiler.env.IModuleAwareNameEnvironment.findType(IModuleAwareNameEnvironment.java:101)
[ERROR] at
org.aspectj.ajdt.internal.core.builder.StatefulNameEnvironment.findType(StatefulNameEnvironment.java:101)
[ERROR] at
org.aspectj.org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.createPlainPackage(LookupEnvironment.java:1151)
[ERROR] at
org.aspectj.org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope.buildTypeBindings(CompilationUnitScope.java:136)
[ERROR] at
org.aspectj.org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.buildTypeBindings(LookupEnvironment.java:487)
[ERROR] at
org.aspectj.ajdt.internal.compiler.lookup.AjLookupEnvironment.buildTypeBindings(AjLookupEnvironment.java:1471)
[ERROR] at
org.aspectj.org.eclipse.jdt.internal.compiler.Compiler.internalBeginToCompile(Compiler.java:870)
[ERROR] at
org.aspectj.org.eclipse.jdt.internal.compiler.Compiler.beginToCompile(Compiler.java:395)
[ERROR] at
org.aspectj.org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:449)
[ERROR] at
org.aspectj.org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:427)
[ERROR] at
org.aspectj.ajdt.internal.core.builder.AjBuildManager.performCompilation(AjBuildManager.java:1096)
[ERROR] at
org.aspectj.ajdt.internal.core.builder.AjBuildManager.performBuild(AjBuildManager.java:275)
[ERROR] at
org.aspectj.ajdt.internal.core.builder.AjBuildManager.batchBuild(AjBuildManager.java:188)
[ERROR] at
org.aspectj.ajdt.ajc.AjdtCommand.doCommand(AjdtCommand.java:103)
[ERROR] at
org.aspectj.ajdt.ajc.AjdtCommand.runCommand(AjdtCommand.java:47)
[ERROR] at
org.aspectj.tools.ajc.Main.run(Main.java:372)
[ERROR] at
org.aspectj.tools.ajc.Main.runMain(Main.java:250)
[ERROR] at
org.codehaus.mojo.aspectj.AbstractAjcCompiler.execute(AbstractAjcCompiler.java:568)
[ERROR] at
org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
[ERROR] at
org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:210)
[ERROR] at
org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:156)
[ERROR] at
org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148)
[ERROR] at
org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
[ERROR] at
org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
[ERROR] at
org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56)
[ERROR] at
org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
[ERROR] at
org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:305)
[ERROR] at
org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192)
[ERROR] at
org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105)
[ERROR] at
org.apache.maven.cli.MavenCli.execute(MavenCli.java:956)
[ERROR] at
org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
[ERROR] at
org.apache.maven.cli.MavenCli.main(MavenCli.java:192)
[ERROR] at
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native
Method)
[ERROR] at
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[ERROR] at
java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[ERROR] at
java.base/java.lang.reflect.Method.invoke(Method.java:566)
[ERROR] at
org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
[ERROR] at
org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
[ERROR] at
org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
[ERROR] at
org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
[ERROR]
The problem is that ClasspathJmod objects for JMOD files have
zipFile=null
hence this code in ClasspathJmode fails
After some more patching and debugging I also found that some of
ClasspathJar objects throw NPE for the same reason – zipFile is null
I could not find if there is some configuration missing or something else
that has to be provided in pom.xml so that aspect plugin finishes
successfully. Appreciate any help on this.