Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Jason Zaugg
asm
Commits
785f47ac
Commit
785f47ac
authored
May 05, 2018
by
Remi Forax
Browse files
The class version can be flagged with V_PREVIEW (JEP 12)
parent
94c6d3c0
Changes
6
Hide whitespace changes
Inline
Side-by-side
asm-test/src/main/resources/jdk11/LambdaCondy.class
View file @
785f47ac
No preview for this file type
asm-test/src/resources/java/jdk11/LambdaCondy.java
View file @
785f47ac
...
...
@@ -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
)
{
...
...
asm-util/src/test/resources/jdk11.LambdaCondy.txt
View file @
785f47ac
// 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
...
...
asm/src/main/java/org/objectweb/asm/Opcodes.java
View file @
785f47ac
...
...
@@ -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
...
...
asm/src/test/java/org/objectweb/asm/ClassReaderTest.java
View file @
785f47ac
...
...
@@ -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
...
...
asm/src/test/java/org/objectweb/asm/ConstantsTest.java
View file @
785f47ac
...
...
@@ -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"
:
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment