[
https://issues.apache.org/jira/browse/SUREFIRE-1820?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17160167#comment-17160167
]
Robert Varga commented on SUREFIRE-1820:
----------------------------------------
Yes, exactly – if the project is being built JDK is 9+ (I think you were using
JDK11 for 3.0.0-M5) – something like
[https://github.com/eclipse/jetty.project/blob/jetty-9.4.18.v20190429/pom.xml#L1843-L1858]
.
The problem is not the bytecode target:
{noformat}
nite@nitebug : ~/x$ file
./org/apache/maven/surefire/api/util/internal/AbstractNoninterruptibleWritableChannel.class
./org/apache/maven/surefire/api/util/internal/AbstractNoninterruptibleWritableChannel.class:
compiled Java class data, version 51.0 (Java 1.7)
{noformat}
but rather the library version observed by javac: without --release it will be
linking against JDK11, hence this call:
[https://github.com/apache/maven-surefire/blob/eb48f1b59ca5ccf6954ef33ecab03dbaf93214cd/surefire-api/src/main/java/org/apache/maven/surefire/api/util/internal/AbstractNoninterruptibleWritableChannel.java#L76]
will actually be linking to this method (i.e. a covariant override):
[https://github.com/openjdk/jdk/blob/master/src/java.base/share/classes/java/nio/X-Buffer.java.template#L1364-L1368]
which was introduced as part of
[https://bugs.openjdk.java.net/browse/JDK-4774077]
This can be seen via 'javap -v':
{noformat}
nite@nitebug : ~/x$ javap -v
./org/apache/maven/surefire/api/util/internal/AbstractNoninterruptibleWritableChannel.class
Classfile
/home/nite/x/org/apache/maven/surefire/api/util/internal/AbstractNoninterruptibleWritableChannel.class
Last modified 10-Jun-2020; size 1862 bytes
MD5 checksum 367202c73bf1cedbf32c1e50987249bf
Compiled from "AbstractNoninterruptibleWritableChannel.java"
abstract class
org.apache.maven.surefire.api.util.internal.AbstractNoninterruptibleWritableChannel
implements
org.apache.maven.surefire.api.util.internal.WritableBufferedByteChannel
minor version: 0
major version: 51
flags: ACC_SUPER, ACC_ABSTRACT
[...]
int write(java.nio.ByteBuffer, boolean) throws java.io.IOException;
descriptor: (Ljava/nio/ByteBuffer;Z)I
flags:
Code:
stack=2, locals=4, args_size=3
0: aload_0
[...]
72: aload_1
73: aload_1
74: invokevirtual #16 // Method
java/nio/ByteBuffer.limit:()I
77: invokevirtual #17 // Method
java/nio/ByteBuffer.position:(I)Ljava/nio/ByteBuffer;
80: pop
81: iload_2
82: ifeq 89
85: aload_0
86: invokevirtual #18 // Method flushImpl:()V
89: iload_3
90: ireturn
{noformat}
> Using SurefireForkNodeFactory with JDK8 results in NoSuchMethodError
> --------------------------------------------------------------------
>
> Key: SUREFIRE-1820
> URL: https://issues.apache.org/jira/browse/SUREFIRE-1820
> Project: Maven Surefire
> Issue Type: Bug
> Components: process forking
> Affects Versions: 3.0.0-M5
> Reporter: Robert Varga
> Priority: Major
>
> Attempting to use TCP channels for communication with JDK 1.8 results in the
> following splat:
> {noformat}
> xception in thread "commands-fork-1" java.lang.NoSuchMethodError:
> java.nio.ByteBuffer.position(I)Ljava/nio/ByteBuffer;
> at
> org.apache.maven.surefire.api.util.internal.AbstractNoninterruptibleWritableChannel.write(AbstractNoninterruptibleWritableChannel.java:76)
> at
> org.apache.maven.surefire.api.util.internal.AbstractNoninterruptibleWritableChannel.write(AbstractNoninterruptibleWritableChannel.java:44)
> at
> org.apache.maven.plugin.surefire.extensions.StreamFeeder.run(StreamFeeder.java:92)
> Exception in thread "fork-1-event-thread" java.lang.NoSuchMethodError:
> java.nio.ByteBuffer.position(I)Ljava/nio/ByteBuffer;
> at
> org.apache.maven.plugin.surefire.extensions.EventConsumerThread.decode(EventConsumerThread.java:140)
> at
> org.apache.maven.plugin.surefire.extensions.EventConsumerThread.run(EventConsumerThread.java:113)
> Exception in thread "fork-1-err-thread" java.lang.NoSuchMethodError:
> java.nio.ByteBuffer.position(I)Ljava/nio/ByteBuffer;
> at
> org.apache.maven.surefire.api.util.internal.Channels$3.readImpl(Channels.java:217)
> at
> org.apache.maven.surefire.api.util.internal.AbstractNoninterruptibleReadableChannel.read(AbstractNoninterruptibleReadableChannel.java:54)
> at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:274)
> at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:326)
> at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:178)
> at java.io.Reader.read(Reader.java:100)
> at java.util.Scanner.readInput(Scanner.java:804)
> at java.util.Scanner.findWithinHorizon(Scanner.java:1685)
> at java.util.Scanner.hasNextLine(Scanner.java:1500)
> at
> org.apache.maven.surefire.extensions.util.LineConsumerThread.run(LineConsumerThread.java:67)
> {noformat}
> at least in the following configuration:
> {noformat}
> [ERROR] Failed to execute goal
> org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M5:test (default) on
> project pt-triemap: There are test failures.
> [ERROR]
> [ERROR] Please refer to
> /home/nite/pt/triemap/pt-triemap/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 /bin/sh -c cd /home/nite/pt/triemap/pt-triemap &&
> /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.252.b09-1.fc32.x86_64/jre/bin/java -jar
> /home/nite/pt/triemap/pt-triemap/target/surefire/surefirebooter5389144270021152085.jar
> /home/nite/pt/triemap/pt-triemap/target/surefire
> 2020-07-14T09-05-53_813-jvmRun1 surefire4432899852251024839tmp
> surefire_06735691049687446297tmp{noformat}
> Based on the discussion here:
> [https://github.com/eclipse/jetty.project/issues/3244] , it would seem the
> cause is that surefire release was compiled with JDK9+ without setting
> --release to 8-or-lower.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)