Uploaded image for project: 'Maven Surefire'
  1. Maven Surefire
  2. SUREFIRE-1882

Fix failures when compiled on Java 9+ and run on Java 8

Agile BoardAttach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    Description

      When running my build on JDK 8, I see

      [INFO] --- maven-surefire-plugin:3.0.0-M6-SNAPSHOT:test (reuse-jvm) @ sarek-mock ---
      [INFO] 
      [INFO] -------------------------------------------------------
      [INFO]  T E S T S
      [INFO] -------------------------------------------------------
      [INFO] 
      [INFO] Results:
      [INFO] 
      [INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
      [INFO] 
      [WARNING] Could not delete temp directory C:\Users\alexa\AppData\Local\Temp\surefire9150168311367699157 because File C:\Users\alexa\AppData\Local\Temp\surefire9150168311367699157\surefirebooter4446112705128419789.jar unable to be deleted.
      [INFO] ------------------------------------------------------------------------
      [INFO] Reactor Summary for sarek-parent 1.0-SNAPSHOT:
      [INFO] 
      [INFO] (...)
      [INFO] sarek-mock ......................................... FAILURE [  1.541 s]
      [INFO] (...)
      [INFO] ------------------------------------------------------------------------
      [INFO] BUILD FAILURE
      [INFO] ------------------------------------------------------------------------
      [INFO] Total time:  15.095 s
      [INFO] Finished at: 2021-01-26T13:22:20+07:00
      [INFO] ------------------------------------------------------------------------
      [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M6-SNAPSHOT:test (reuse-jvm) on project sarek-mock: There are test failures.
      [ERROR] 
      [ERROR] Please refer to C:\Users\alexa\Documents\java-src\Sarek\sarek-mock\target\surefire-reports for the individual test results.
      [ERROR] Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.
      [ERROR] The forked VM terminated without properly saying goodbye. VM crash or System.exit called?
      [ERROR] Command was cmd.exe /X /C ""C:\Program Files\Java\jdk1.8.0_211\jre\bin\java" -jar C:\Users\alexa\AppData\Local\Temp\surefire9150168311367699157\surefirebooter4446112705128419789.jar C:\Users\alexa\AppData\Local\Temp\surefire9150168311367699157 2021-01-26T13-22-12_972-jvmRun1 surefire4902538894981773413tmp surefire_05054187083706494231tmp"
      [ERROR] org.apache.maven.surefire.booter.SurefireBooterForkException: The forked VM terminated without properly saying goodbye. VM crash or System.exit called?
      [ERROR] Command was cmd.exe /X /C ""C:\Program Files\Java\jdk1.8.0_211\jre\bin\java" -jar C:\Users\alexa\AppData\Local\Temp\surefire9150168311367699157\surefirebooter4446112705128419789.jar C:\Users\alexa\AppData\Local\Temp\surefire9150168311367699157 2021-01-26T13-22-12_972-jvmRun1 surefire4902538894981773413tmp surefire_05054187083706494231tmp"
      [ERROR] 	at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:751)
      [ERROR] 	at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:306)
      [ERROR] 	at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:266)
      [ERROR] 	at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeProvider(AbstractSurefireMojo.java:1320)
      [ERROR] 	(...)
      

      See also the dump file attached to this ticket.

      When running the build e.g. with Java 11 or Java 14, the same error does not occur. I tested with the current master, commit f14fa54b.

      The root cause seems to be this part of the dump file:

      java.lang.NoSuchMethodError: java.nio.ByteBuffer.flip()Ljava/nio/ByteBuffer;
      	at org.apache.maven.surefire.api.util.internal.AbstractNoninterruptibleWritableChannel.write(AbstractNoninterruptibleWritableChannel.java:67)
      	at org.apache.maven.surefire.api.util.internal.AbstractNoninterruptibleWritableChannel.write(AbstractNoninterruptibleWritableChannel.java:44)
      	at org.apache.maven.surefire.api.stream.AbstractStreamEncoder.write(AbstractStreamEncoder.java:77)
      	at org.apache.maven.surefire.booter.spi.EventChannelEncoder.write(EventChannelEncoder.java:333)
      	at org.apache.maven.surefire.booter.spi.EventChannelEncoder.encodeOpcode(EventChannelEncoder.java:324)
      	at org.apache.maven.surefire.booter.spi.EventChannelEncoder.bye(EventChannelEncoder.java:274)
      	at org.apache.maven.surefire.booter.ForkedBooter.acknowledgedExit(ForkedBooter.java:419)
      	at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:194)
      	at org.apache.maven.surefire.booter.ForkedBooter.run(ForkedBooter.java:570)
      	at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:556)
      

      ByteBuffer.flip() simply does not exist yet in Java 8. The read-me file says:

      Build the Surefire project using Maven 3.1.0+ and JDK 1.8+.

      OTOH, the corresponding commit 5e3348cd by Tibor Digana is 2 years old already, calling a Java 9+ method flip():

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            tibordigana Tibor Digana
            kriegaex Alexander Kriegisch
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment