✕
Skip to content

3.6.0 leads to java.lang.IllegalAccessError (with forking/toolchain?) and very slow run (otherwise) #3511

Closed

Description

@cpovirk

Affected version

3.6.0

Bug description

We're seeing this in https://github.com/google/guava:

$ git checkout 99dfa90a138b9d833a9b144dab22991dbaab0288

$ perl -pi -e 's/\d[\d.]+/3.6.0/ if /maven-surefire-plugin.version/' pom.xml

$ JAVA_HOME=/usr/local/google/home/cpovirk/jdk-26+35 ./mvnw clean install -Dsurefire.toolchain.version=11
...
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:3.6.0:test (default-test) on project guava-tests: 
[ERROR] 
[ERROR] See /usr/local/google/home/cpovirk/clients/guava-black/guava/guava-tests/target/surefire-reports for the individual test results.
[ERROR] See dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.
[ERROR] There was an error in the forked process
[ERROR] java.lang.IllegalAccessError: failed to access class com.google.common.collect.testing.AbstractIteratorTester from class com.google.common.collect.MinMaxPriorityQueueTest (com.google.common.collect.testing.AbstractIteratorTester and com.google.common.collect.MinMaxPriorityQueueTest are in unnamed module of loader 'app')
[ERROR] org.apache.maven.surefire.booter.SurefireBooterForkException: There was an error in the forked process
[ERROR] java.lang.IllegalAccessError: failed to access class com.google.common.collect.testing.AbstractIteratorTester from class com.google.common.collect.MinMaxPriorityQueueTest (com.google.common.collect.testing.AbstractIteratorTester and com.google.common.collect.MinMaxPriorityQueueTest are in unnamed module of loader 'app')
[ERROR]   at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:708)
[ERROR]   at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:523)
[ERROR]   at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:323)
[ERROR]   at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:287)
[ERROR]   at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeProvider(AbstractSurefireMojo.java:1474)
[ERROR]   at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked(AbstractSurefireMojo.java:1246)
[ERROR]   at org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute(AbstractSurefireMojo.java:1082)
[ERROR]   at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:126)
[ERROR]   at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2(MojoExecutor.java:328)
[ERROR]   at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute(MojoExecutor.java:316)
[ERROR]   at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
[ERROR]   at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:174)
[ERROR]   at org.apache.maven.lifecycle.internal.MojoExecutor.access$000(MojoExecutor.java:75)
[ERROR]   at org.apache.maven.lifecycle.internal.MojoExecutor$1.run(MojoExecutor.java:162)
[ERROR]   at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute(DefaultMojosExecutionStrategy.java:39)
[ERROR]   at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:159)
[ERROR]   at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:105)
[ERROR]   at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:73)
[ERROR]   at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:53)
[ERROR]   at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:118)
[ERROR]   at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:261)
[ERROR]   at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:173)
[ERROR]   at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:101)
[ERROR]   at org.apache.maven.cli.MavenCli.execute(MavenCli.java:919)
[ERROR]   at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:285)
[ERROR]   at org.apache.maven.cli.MavenCli.main(MavenCli.java:207)
[ERROR]   at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
[ERROR]   at java.base/java.lang.reflect.Method.invoke(Method.java:565)
[ERROR]   at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:255)
[ERROR]   at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:201)
[ERROR]   at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:361)
[ERROR]   at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:314)
[ERROR]   at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
[ERROR]   at java.base/java.lang.reflect.Method.invoke(Method.java:565)
[ERROR]   at org.apache.maven.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.java:52)
[ERROR]   at org.apache.maven.wrapper.WrapperExecutor.execute(WrapperExecutor.java:161)
[ERROR]   at org.apache.maven.wrapper.MavenWrapperMain.main(MavenWrapperMain.java:73)

Additionally, when I omit -Dsurefire.toolchain.version (which causes our build to use Java 26 for Surefire), I am seeing very slow execution for the tests of our guava-tests module: That historically has taken ~5 minutes of a total build time of ~7 minutes, but I stopped the build that was using 3.6.0 after about 40 minutes, when it appeared to have been running the same test classes (e.g., com.google.common.collect.testing.testers.CollectionClearTester) repeatedly. That may be a separate issue, probably related to how our tests build custom JUnit 3 suites. But from the release notes, I wonder if both symptoms might be a result of #3444. I tried to build my own Surefire at that commit, but (if I did things correct and I'm remembering correctly) I saw no tests run at that commit. When I tried to bisect the no-tests issue from there, I ran into trouble with our internal Maven mirror, and I gave up.

Activity

  1. self-assigned this
    on Oct 8, 2026
  2. olamy commented on Oct 8, 2026

    @olamy
    Member

    @cpovirk, thanks for the report, which is very interesting. I suspect the slowdown is coming from this method getEnclosingClassNames from this change 45102fa9f#diff-80115dd9c11ea216f73791da899b0ea3dc424f154dd7c8c65173de7071cc38eeR559 (PR #3447)
    which might be very slow for java 8 and 11 because of now using getEnclosingClass
    I may have some ideas for a fix

  3. added this to the 3.6.1 milestone on Oct 8, 2026
  4. olamy commented on Oct 8, 2026

    @olamy
    Member

    ok bug fix here #3513
    The performance issue is another problem I will look at in a separate PR.

  5. olamy commented on Oct 8, 2026

    @olamy
    Member

    @cpovirk well, you could at least move to Junit 4 ;)

  6. cpovirk commented on Oct 8, 2026

    @cpovirk
    ContributorAuthor

    Thanks for having a look! And yes, haha, we have taken baby steps toward migrating to a less obsolete version of JUnit, but it will take some effort to do it completely, especially with the weird suites that I'd mentioned.

  7. olamy commented on Oct 8, 2026

    @olamy
    Member

    possible fix for performance issue #3514
    still something fishy with your tests here due to #3466
    Need more investigations and possibly another PR

  8. cpovirk commented on Oct 8, 2026

    @cpovirk
    ContributorAuthor

    Thanks again.

    I had left another run that used a matching (Java 26) toolchain for Surefire and for Maven itself running overnight. After 118,528 lines with "Tests run" in them (some of those in guava-testlib but 117,468 in guava-tests), it ran out of memory:

    [ERROR] There was an error in the forked process
    [ERROR] Java heap space
    [ERROR] org.apache.maven.surefire.booter.SurefireBooterForkException: There was an error in the forked process
    [ERROR] Java heap space
    [ERROR]   at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:708)
    [ERROR]   at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:523)
    [ERROR]   at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:323)
    [ERROR]   at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:287)
    [ERROR]   at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeProvider(AbstractSurefireMojo.java:1474)
    [ERROR]   at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked(AbstractSurefireMojo.java:1246)
    [ERROR]   at org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute(AbstractSurefireMojo.java:1082)
    [ERROR]   at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:126)
    [ERROR]   at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2(MojoExecutor.java:328)
    [ERROR]   at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute(MojoExecutor.java:316)
    [ERROR]   at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
    [ERROR]   at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:174)
    [ERROR]   at org.apache.maven.lifecycle.internal.MojoExecutor.access$000(MojoExecutor.java:75)
    [ERROR]   at org.apache.maven.lifecycle.internal.MojoExecutor$1.run(MojoExecutor.java:162)
    [ERROR]   at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute(DefaultMojosExecutionStrategy.java:39)
    [ERROR]   at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:159)
    [ERROR]   at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:105)
    [ERROR]   at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:73)
    [ERROR]   at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:53)
    [ERROR]   at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:118)
    [ERROR]   at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:261)
    [ERROR]   at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:173)
    [ERROR]   at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:101)
    [ERROR]   at org.apache.maven.cli.MavenCli.execute(MavenCli.java:919)
    [ERROR]   at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:285)
    [ERROR]   at org.apache.maven.cli.MavenCli.main(MavenCli.java:207)
    [ERROR]   at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
    [ERROR]   at java.base/java.lang.reflect.Method.invoke(Method.java:565)
    [ERROR]   at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:255)
    [ERROR]   at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:201)
    [ERROR]   at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:361)
    [ERROR]   at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:314)
    [ERROR]   at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
    [ERROR]   at java.base/java.lang.reflect.Method.invoke(Method.java:565)
    [ERROR]   at org.apache.maven.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.java:52)
    [ERROR]   at org.apache.maven.wrapper.WrapperExecutor.execute(WrapperExecutor.java:161)
    [ERROR]   at org.apache.maven.wrapper.MavenWrapperMain.main(MavenWrapperMain.java:73)
    
  9. olamy commented on Oct 8, 2026

    @olamy
    Member

    @cpovirk yup I saw this while testing with your project and testing possible improvement with both #3514 and #3515

  10. olamy commented on Oct 9, 2026

    @olamy
    Member

    @cpovirk all merged. It looks better ;)
    feel free to test with master now.

  11. cpovirk commented on Oct 9, 2026

    @cpovirk
    ContributorAuthor

    Yep, thanks! Initial testing suggests that things may have gotten a little slower, but we're now talking on the order of a few minutes, not "just keeps going until it runs out of heap" :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions