< prev index next > test/jdk/java/lang/invoke/DefineClassTest.java
Print this page
/**
* Generates a class file with the given class name
*/
byte[] generateClass(String className) {
return ClassFile.of().build(ClassDesc.of(className), clb -> {
! clb.withFlags(AccessFlag.PUBLIC, AccessFlag.SUPER);
clb.withSuperclass(CD_Object);
clb.withMethodBody(INIT_NAME, MTD_void, PUBLIC, cob -> {
cob.aload(0);
cob.invokespecial(CD_Object, INIT_NAME, MTD_void);
cob.return_();
/**
* Generates a class file with the given class name
*/
byte[] generateClass(String className) {
return ClassFile.of().build(ClassDesc.of(className), clb -> {
! clb.withFlags(AccessFlag.PUBLIC, AccessFlag.IDENTITY);
clb.withSuperclass(CD_Object);
clb.withMethodBody(INIT_NAME, MTD_void, PUBLIC, cob -> {
cob.aload(0);
cob.invokespecial(CD_Object, INIT_NAME, MTD_void);
cob.return_();
byte[] generateClassWithInitializer(String className,
String targetClass,
String targetMethod) throws Exception {
return ClassFile.of().build(ClassDesc.of(className), clb -> {
! clb.withFlags(AccessFlag.PUBLIC, AccessFlag.SUPER);
clb.withSuperclass(CD_Object);
clb.withMethodBody(INIT_NAME, MTD_void, ACC_PUBLIC, cob -> {
cob.aload(0);
cob.invokespecial(CD_Object, INIT_NAME, MTD_void);
cob.return_();
byte[] generateClassWithInitializer(String className,
String targetClass,
String targetMethod) throws Exception {
return ClassFile.of().build(ClassDesc.of(className), clb -> {
! clb.withFlags(AccessFlag.PUBLIC, AccessFlag.IDENTITY);
clb.withSuperclass(CD_Object);
clb.withMethodBody(INIT_NAME, MTD_void, ACC_PUBLIC, cob -> {
cob.aload(0);
cob.invokespecial(CD_Object, INIT_NAME, MTD_void);
cob.return_();
/**
* Generates a non-linkable class file with the given class name
*/
byte[] generateNonLinkableClass(String className) {
return ClassFile.of().build(ClassDesc.of(className), clb -> {
! clb.withFlags(AccessFlag.PUBLIC, AccessFlag.SUPER);
clb.withSuperclass(CD_MissingSuperClass);
clb.withMethodBody(INIT_NAME, MTD_void, ACC_PUBLIC, cob -> {
cob.aload(0);
cob.invokespecial(CD_MissingSuperClass, INIT_NAME, MTD_void);
cob.return_();
/**
* Generates a non-linkable class file with the given class name
*/
byte[] generateNonLinkableClass(String className) {
return ClassFile.of().build(ClassDesc.of(className), clb -> {
! clb.withFlags(AccessFlag.PUBLIC, AccessFlag.IDENTITY);
clb.withSuperclass(CD_MissingSuperClass);
clb.withMethodBody(INIT_NAME, MTD_void, ACC_PUBLIC, cob -> {
cob.aload(0);
cob.invokespecial(CD_MissingSuperClass, INIT_NAME, MTD_void);
cob.return_();
< prev index next >