Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullPointerException when setting -XDuseUnsharedTable=true #371

Closed
hisener opened this issue Feb 29, 2024 · 6 comments · Fixed by #373
Closed

NullPointerException when setting -XDuseUnsharedTable=true #371

hisener opened this issue Feb 29, 2024 · 6 comments · Fixed by #373
Assignees

Comments

@hisener
Copy link

hisener commented Feb 29, 2024

Not a plexus-compiler per se, but since -XDuseUnsharedTable=true is now default since 2.14.0 in c396cc8, I thought I share it here.

I can reproduce it with both Java 17 and 21. I first noticed it while upgrading maven-compiler-plugin from 3.11.0 to 3.12.1 (which uses plexus-compiler 2.14.2). But it also happens with maven-compiler-plugin 3.11.0 + -XDuseUnsharedTable=true compiler argument.

The problematic code was using raw parameterized class. Something like var context = new Context(...). Specifying the parameterized type fixed the issue, i.e., var context = new Context<Key, Value>(...). I didn't debug it further, though.

The stack trace:

Fatal error compiling: Cannot load from object array because "this.hashes" is null -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.11.0:testCompile (default-testCompile) on project ...: Fatal error compiling
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:375)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:351)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:171)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:163)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:210)
    at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:195)
    at java.util.concurrent.FutureTask.run (FutureTask.java:317)
    at java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:572)
    at java.util.concurrent.FutureTask.run (FutureTask.java:317)
    at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1144)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:642)
    at java.lang.Thread.run (Thread.java:1583)
Caused by: org.apache.maven.plugin.MojoExecutionException: Fatal error compiling
    at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute (AbstractCompilerMojo.java:1143)
    at org.apache.maven.plugin.compiler.TestCompilerMojo.execute (TestCompilerMojo.java:199)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:370)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:351)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:171)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:163)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:210)
    at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:195)
    at java.util.concurrent.FutureTask.run (FutureTask.java:317)
    at java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:572)
    at java.util.concurrent.FutureTask.run (FutureTask.java:317)
    at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1144)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:642)
    at java.lang.Thread.run (Thread.java:1583)
Caused by: org.codehaus.plexus.compiler.CompilerException: Cannot load from object array because "this.hashes" is null
    at org.codehaus.plexus.compiler.javac.JavaxToolsCompiler.compileInProcess (JavaxToolsCompiler.java:198)
    at org.codehaus.plexus.compiler.javac.JavacCompiler.performCompile (JavacCompiler.java:183)
    at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute (AbstractCompilerMojo.java:1140)
    at org.apache.maven.plugin.compiler.TestCompilerMojo.execute (TestCompilerMojo.java:199)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:370)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:351)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:171)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:163)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:210)
    at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:195)
    at java.util.concurrent.FutureTask.run (FutureTask.java:317)
    at java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:572)
    at java.util.concurrent.FutureTask.run (FutureTask.java:317)
    at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1144)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:642)
    at java.lang.Thread.run (Thread.java:1583)
Caused by: java.lang.NullPointerException: Cannot load from object array because "this.hashes" is null
    at com.sun.tools.javac.util.UnsharedNameTable.fromValidUtf (UnsharedNameTable.java:97)
    at com.sun.tools.javac.util.UnsharedNameTable.fromUtf (UnsharedNameTable.java:91)
    at com.sun.tools.javac.util.Names.fromUtf (Names.java:455)
    at com.sun.tools.javac.jvm.PoolReader.resolve (PoolReader.java:233)
    at com.sun.tools.javac.jvm.PoolReader$ImmutablePoolHelper.readIfNeeded (PoolReader.java:391)
    at com.sun.tools.javac.jvm.PoolReader.getName (PoolReader.java:185)
    at com.sun.tools.javac.jvm.PoolReader.resolve (PoolReader.java:247)
    at com.sun.tools.javac.jvm.PoolReader$ImmutablePoolHelper.readIfNeeded (PoolReader.java:391)
    at com.sun.tools.javac.jvm.PoolReader.getClass (PoolReader.java:121)
    at com.sun.tools.javac.jvm.ClassReader.readClass (ClassReader.java:2584)
    at com.sun.tools.javac.jvm.ClassReader.readClassBuffer (ClassReader.java:2732)
    at com.sun.tools.javac.jvm.ClassReader.readClassFile (ClassReader.java:2756)
    at com.sun.tools.javac.code.ClassFinder.fillIn (ClassFinder.java:373)
    at com.sun.tools.javac.code.ClassFinder.complete (ClassFinder.java:302)
    at com.sun.tools.javac.code.Symbol.complete (Symbol.java:682)
    at com.sun.tools.javac.code.Symbol$ClassSymbol.complete (Symbol.java:1418)
    at com.sun.tools.javac.code.Symbol.apiComplete (Symbol.java:688)
    at com.sun.tools.javac.jvm.ClassReader$1.getEnclosingType (ClassReader.java:597)
    at com.sun.tools.javac.code.Printer.visitClassType (Printer.java:228)
    at com.sun.tools.javac.code.Printer.visitClassType (Printer.java:52)
    at com.sun.tools.javac.code.Type$ClassType.accept (Type.java:1050)
    at com.sun.tools.javac.code.Printer.visit (Printer.java:136)
    at com.sun.tools.javac.code.Printer.visitTypes (Printer.java:108)
    at com.sun.tools.javac.code.Printer.visitClassType (Printer.java:239)
    at com.sun.tools.javac.code.Printer.visitClassType (Printer.java:52)
    at com.sun.tools.javac.code.Type$ClassType.accept (Type.java:1050)
    at com.sun.tools.javac.code.Printer.visit (Printer.java:136)
    at com.sun.tools.javac.code.Printer.visitTypes (Printer.java:108)
    at com.sun.tools.javac.code.Printer.visitClassType (Printer.java:239)
    at com.sun.tools.javac.code.Printer.visitClassType (Printer.java:52)
    at com.sun.tools.javac.code.Type$ClassType.accept (Type.java:1050)
    at com.sun.tools.javac.code.Printer.visit (Printer.java:136)
    at com.sun.tools.javac.code.Printer.visitTypes (Printer.java:108)
    at com.sun.tools.javac.code.Printer.printMethodArgs (Printer.java:339)
    at com.sun.tools.javac.code.Printer.visitMethodSymbol (Printer.java:381)
    at com.sun.tools.javac.code.Printer.visitMethodSymbol (Printer.java:52)
    at com.sun.tools.javac.code.Symbol$MethodSymbol.accept (Symbol.java:2271)
    at com.sun.tools.javac.code.Printer.visit (Printer.java:147)
    at com.sun.tools.javac.util.AbstractDiagnosticFormatter.formatArgument (AbstractDiagnosticFormatter.java:206)
    at com.sun.tools.javac.util.AbstractDiagnosticFormatter.formatArguments (AbstractDiagnosticFormatter.java:167)
    at com.sun.tools.javac.util.BasicDiagnosticFormatter.formatMessage (BasicDiagnosticFormatter.java:111)
    at com.sun.tools.javac.util.BasicDiagnosticFormatter.formatMeta (BasicDiagnosticFormatter.java:186)
    at com.sun.tools.javac.util.BasicDiagnosticFormatter.formatDiagnostic (BasicDiagnosticFormatter.java:100)
    at com.sun.tools.javac.util.AbstractDiagnosticFormatter.format (AbstractDiagnosticFormatter.java:123)
    at com.sun.tools.javac.util.AbstractDiagnosticFormatter.format (AbstractDiagnosticFormatter.java:75)
    at com.sun.tools.javac.util.JCDiagnostic.toString (JCDiagnostic.java:800)
    at com.sun.tools.javac.api.ClientCodeWrapper$DiagnosticSourceUnwrapper.toString (ClientCodeWrapper.java:852)
    at org.codehaus.plexus.compiler.javac.JavaxToolsCompiler.compileInProcess (JavaxToolsCompiler.java:154)
    at org.codehaus.plexus.compiler.javac.JavacCompiler.performCompile (JavacCompiler.java:183)
    at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute (AbstractCompilerMojo.java:1140)
    at org.apache.maven.plugin.compiler.TestCompilerMojo.execute (TestCompilerMojo.java:199)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:370)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:351)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:171)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:163)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:210)
    at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:195)
    at java.util.concurrent.FutureTask.run (FutureTask.java:317)
    at java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:572)
    at java.util.concurrent.FutureTask.run (FutureTask.java:317)
    at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1144)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:642)
    at java.lang.Thread.run (Thread.java:1583)
@slawekjaranowski
Copy link
Member

Caused by: java.lang.NullPointerException: Cannot load from object array because "this.hashes" is null
    at com.sun.tools.javac.util.UnsharedNameTable.fromValidUtf (UnsharedNameTable.java:97)
    at com.sun.tools.javac.util.UnsharedNameTable.fromUtf (UnsharedNameTable.java:91)

it looks like a bug in JDK ... what do you think?

@slawekjaranowski
Copy link
Member

Reference PR #309

@hisener
Copy link
Author

hisener commented Feb 29, 2024

it looks like a bug in JDK ... what do you think?

Agreed. Shared it here because -XDuseUnsharedTable=true is now the default. I'll find some time later to create a minimal reproducible example.

@slawekjaranowski
Copy link
Member

it looks like a bug in JDK ... what do you think?

Agreed. Shared it here because -XDuseUnsharedTable=true is now the default. I'll find some time later to create a minimal reproducible example.

great.

As workaround we can check if XDuseUnsharedTable is already on arguments list

@hisener
Copy link
Author

hisener commented Feb 29, 2024

I think moving this block before the getCustomCompilerArgumentsEntries for-loop should be sufficient.

if (!config.isFork()) {
args.add("-XDuseUnsharedTable=true");
}

That way, one can pass -XDuseUnsharedTable=false as compilerArg to override.

@slawekjaranowski
Copy link
Member

slawekjaranowski commented Feb 29, 2024

Yes it is this place of code ... can be simply check if args contains -XDuseUnsharedTable=false

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants