diff options
author | Alexander Kriegisch <Alexander@Kriegisch.name> | 2021-06-26 16:18:29 +0700 |
---|---|---|
committer | Alexander Kriegisch <Alexander@Kriegisch.name> | 2021-06-26 17:11:38 +0700 |
commit | 68a8916c9bda92df9fb31d4fa8988511a2294d04 (patch) | |
tree | a8155a48d1317033b3af658c7fbd4e0a402fd613 /tests/features198 | |
parent | 9de03c3ea52f78678d8c47296395d5f01d031a48 (diff) | |
download | aspectj-68a8916c9bda92df9fb31d4fa8988511a2294d04.tar.gz aspectj-68a8916c9bda92df9fb31d4fa8988511a2294d04.zip |
Add integration test for '--release N' compiler option
Relates to #70
Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
Diffstat (limited to 'tests/features198')
-rw-r--r-- | tests/features198/compiler_release/Buffers.java | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/features198/compiler_release/Buffers.java b/tests/features198/compiler_release/Buffers.java new file mode 100644 index 000000000..7245640c8 --- /dev/null +++ b/tests/features198/compiler_release/Buffers.java @@ -0,0 +1,20 @@ +import java.nio.Buffer; +import java.nio.ByteBuffer; + +public class Buffers { + /** + * Running this method will fail during runtime on JDK 8, if compiled on JDK 9+ with {@code -source 8 -target 8}, + * because the API has changed: In JDK 8 there was only {@code Buffer.flip()}, but since JDK 9 it is overloaded by + * {@code ByteBuffer.flip()}. + * <p> + * Therefore, it is imperative to compile against the old API, using the correct boot classpath. On JDK 9+, the + * canonical way to do this is to use {@code --release 8}, because the JDK contains a compatibility layer exactly for + * this purpose. + * <p> + * If incorrectly compiled against JDK 9+ API, this will fail with: + * <pre>{@code java.lang.NoSuchMethodError: java.nio.ByteBuffer.flip()Ljava/nio/ByteBuffer; }</pre> + */ + public static Buffer flip(ByteBuffer buffer) { + return buffer.flip(); + } +} |