[lworld] RFR: 8281763: Support Valhalla class file features in asmtools
Dan Smith
dlsmith at openjdk.java.net
Tue Feb 15 23:22:44 UTC 2022
On Mon, 14 Feb 2022 20:48:06 GMT, Dan Smith <dlsmith at openjdk.org> wrote:
> Modifying the Valhalla repo's fork of asmtools to implement Valhalla class file features:
>
> - ACC_VALUE, ACC_PERMITS_VALUE, and ACC_PRIMITIVE
> - Preload attribute
> - aconst_init & withfield instructions
> - Unnamed factory methods
> - Q descriptors
>
> Mainly relevant to the `jasm` tool, but there are also some interactions with `jdis` and `jdec`. No impact on `jcod`.
I don't think we typically write tests for our testing code, but here's an example that can be used to manually sanity-check the behavior:
/**
* @test
* @summary Make sure custom jasm works
* @library /test/lib
* @build org.openjdk.asmtools.* org.openjdk.asmtools.jasm.*
* @run driver org.openjdk.asmtools.JtregDriver jasm -strict JasmTest.jasm
* @run main JasmTest
*/
public final primitive value class JasmTest version 62:0 {
Preload java/lang/String;
private final Field x:I;
public static Method make:"(I)QJasmTest;" stack 2 {
aconst_init JasmTest;
iload_0;
withfield x:I;
areturn;
}
public static Method id:"(QJasmTest;)QJasmTest;" stack 1 {
aload_0;
areturn;
}
public static Method fail:"()V" stack 2 {
new java/lang/RuntimeException;
dup;
invokespecial java/lang/RuntimeException.<init>:"()V";
athrow;
}
public static Method main:"([Ljava/lang/String;)V" stack 1 {
//invokestatic fail:"()V";
iconst_2;
invokestatic make:"(I)QJasmTest;";
pop;
return;
}
}
-------------
PR: https://git.openjdk.java.net/valhalla/pull/647
More information about the valhalla-dev
mailing list