Commit 785f47ac authored by Remi Forax's avatar Remi Forax

The class version can be flagged with V_PREVIEW (JEP 12)

parent 94c6d3c0
Pipeline #1559 failed with stage
in 1 minute and 22 seconds
......@@ -30,6 +30,8 @@ package jdk11;
/**
* By default with jdk 11, constant lambda are compiled using constant dynamic
* The classfile was generated with the amber (branch condy-folding) compiler.
*
* /usr/jdk/jdk-11/bin/javac -source 11 --enable-preview jdk11/LambdaCondy.java
*/
public class LambdaCondy {
public static void main(String[] args) {
......
// class version 55.0 (55)
// class version 55.65535 (-65481)
// access flags 0x21
public class jdk11/LambdaCondy {
......@@ -9,7 +9,7 @@ public class jdk11/LambdaCondy {
// access flags 0x1
public <init>()V
L0
LINENUMBER 7 L0
LINENUMBER 36 L0
ALOAD 0
INVOKESPECIAL java/lang/Object.<init> ()V
RETURN
......@@ -19,15 +19,15 @@ public class jdk11/LambdaCondy {
// access flags 0x9
public static main([Ljava/lang/String;)V
L0
LINENUMBER 9 L0
LINENUMBER 38 L0
LDC run : Ljava/lang/Runnable; java/lang/invoke/LambdaMetafactory.metafactory(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/Class;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)Ljava/lang/Object; (6) [()V, jdk11/LambdaCondy.lambda$main$0()V (6), ()V]
ASTORE 1
L1
LINENUMBER 10 L1
LINENUMBER 39 L1
ALOAD 1
INVOKEINTERFACE java/lang/Runnable.run ()V (itf)
L2
LINENUMBER 11 L2
LINENUMBER 40 L2
RETURN
MAXSTACK = 1
MAXLOCALS = 2
......@@ -35,7 +35,7 @@ public class jdk11/LambdaCondy {
// access flags 0x100A
private static synthetic lambda$main$0()V
L0
LINENUMBER 9 L0
LINENUMBER 38 L0
GETSTATIC java/lang/System.out : Ljava/io/PrintStream;
LDC "hello condy"
INVOKEVIRTUAL java/io/PrintStream.println (Ljava/lang/String;)V
......
......@@ -69,6 +69,14 @@ public interface Opcodes {
int V10 = 0 << 16 | 54;
int V11 = 0 << 16 | 55;
/**
* Version flag indicating that the class is using 'preview' features.
*
* {@code version & V_PREVIEW == V_PREVIEW} tests if a version is flagged with {@code V_PREVIEW}.
*/
int V_PREVIEW = 0xFFFF0000;
// Access flags values, defined in
// - https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-4.html#jvms-4.1-200-E.1
// - https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-4.html#jvms-4.5-200-A.1
......
......@@ -427,6 +427,20 @@ public class ClassReaderTest extends AsmTest implements Opcodes {
0);
assertTrue(success.get());
}
@Test
public void testPreviewMinorVersion() {
ClassReader classReader = new ClassReader(PrecompiledClass.JDK11_LAMBDA_CONDY.getBytes());
classReader.accept(
new ClassVisitor(Opcodes.ASM7_EXPERIMENTAL) {
@Override
public void visit(int version, int access, String name, String signature, String superName,
String[] interfaces) {
assertTrue((version & Opcodes.V_PREVIEW) == Opcodes.V_PREVIEW);
}
},
0);
}
/** Tests that reading an invalid class throws an exception. */
@ParameterizedTest
......
......@@ -67,6 +67,7 @@ public class ConstantsTest {
assertFalse(asmVersions.contains(field.getInt(null)));
asmVersions.add(field.getInt(null));
break;
case "V_PREVIEW":
case "V1_1":
case "V1_2":
case "V1_3":
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment