Java Code Examples for jdk.internal.org.objectweb.asm.ClassWriter#COMPUTE_MAXS
The following examples show how to use
jdk.internal.org.objectweb.asm.ClassWriter#COMPUTE_MAXS .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestBadHostClass.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
static public void badHostClass(Class<?> hostClass) { // choose a class name in the same package as the host class String className; if (hostClass != null) { String prefix = packageName(hostClass); if (prefix.length() > 0) prefix = prefix.replace('.', '/') + "/"; className = prefix + "Anon"; } else { className = "Anon"; } // create the class String superName = "java/lang/Object"; ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS + ClassWriter.COMPUTE_FRAMES); cw.visit(V1_8, ACC_PUBLIC + ACC_FINAL + ACC_SUPER, className, null, superName, null); byte[] classBytes = cw.toByteArray(); int cpPoolSize = constantPoolSize(classBytes); Class<?> anonClass = unsafe.defineAnonymousClass(hostClass, classBytes, new Object[cpPoolSize]); }
Example 2
Source File: DefineAnon.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
static Class<?> getAnonClass(Class<?> hostClass, final String className) { final String superName = "java/lang/Object"; ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS + ClassWriter.COMPUTE_FRAMES); cw.visit(Opcodes.V1_8, Opcodes.ACC_PUBLIC + Opcodes.ACC_FINAL + Opcodes.ACC_SUPER, className, null, superName, null); MethodVisitor mv = cw.visitMethod(Opcodes.ACC_STATIC | Opcodes.ACC_PUBLIC, "test", "()V", null, null); mv.visitMethodInsn(Opcodes.INVOKESTATIC, "p1/T", "test0", "()V", false); mv.visitMethodInsn(Opcodes.INVOKESTATIC, "p1/T", "test1", "()V", false); mv.visitMethodInsn(Opcodes.INVOKESTATIC, "p1/T", "test2", "()V", false); mv.visitMethodInsn(Opcodes.INVOKESTATIC, "p1/T", "test3", "()V", false); mv.visitInsn(Opcodes.RETURN); mv.visitMaxs(0, 0); mv.visitEnd(); final byte[] classBytes = cw.toByteArray(); Class<?> invokerClass = UNSAFE.defineAnonymousClass(hostClass, classBytes, new Object[0]); UNSAFE.ensureClassInitialized(invokerClass); return invokerClass; }
Example 3
Source File: RedefineTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * Generates a class of the following shape: * static class T { * @DontInline public static int f() { return $r; } * } */ static byte[] getClassFile(int r) { ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS); MethodVisitor mv; cw.visit(52, ACC_PUBLIC | ACC_SUPER, NAME, null, "java/lang/Object", null); { mv = cw.visitMethod(ACC_PUBLIC | ACC_STATIC, "f", "()I", null, null); mv.visitAnnotation("Ljdk/internal/vm/annotation/DontInline;", true); mv.visitCode(); mv.visitLdcInsn(r); mv.visitInsn(IRETURN); mv.visitMaxs(0, 0); mv.visitEnd(); } cw.visitEnd(); return cw.toByteArray(); }
Example 4
Source File: TestInstrumentation.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
public byte[] transform( ClassLoader classLoader, String className, Class<?> classBeingRedefined, ProtectionDomain pd, byte[] bytes) throws IllegalClassFormatException { // Check if this class should be instrumented. if (!instrClassesTarget.contains(className)) { return null; } boolean isRedefinition = classBeingRedefined != null; log("instrument class(" + className + ") " + (isRedefinition ? "redef" : "load")); ClassReader reader = new ClassReader(bytes); ClassWriter writer = new ClassWriter( reader, ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES); CallbackClassVisitor classVisitor = new CallbackClassVisitor(writer); reader.accept(classVisitor, 0); instrClassesDone.add(className); return writer.toByteArray(); }
Example 5
Source File: TestAMEnotNPE.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
/** * The bytes for D, a NOT abstract class extending abstract class C without * supplying an implementation for abstract method m. There is a default * method in the interface I, but it should lose to the abstract class. * * @return * @throws Exception */ public static byte[] bytesForD() throws Exception { ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS); MethodVisitor mv; cw.visit(V1_8, ACC_PUBLIC + ACC_SUPER, "p/D", null, "p/C", null); { mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null); mv.visitCode(); mv.visitVarInsn(ALOAD, 0); mv.visitMethodInsn(INVOKESPECIAL, "p/C", "<init>", "()V"); mv.visitInsn(RETURN); mv.visitMaxs(0, 0); mv.visitEnd(); } cw.visitEnd(); return cw.toByteArray(); }
Example 6
Source File: TestInstrumentation.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
public byte[] transform( ClassLoader classLoader, String className, Class<?> classBeingRedefined, ProtectionDomain pd, byte[] bytes) throws IllegalClassFormatException { // Check if this class should be instrumented. if (!instrClassesTarget.contains(className)) { return null; } boolean isRedefinition = classBeingRedefined != null; log("instrument class(" + className + ") " + (isRedefinition ? "redef" : "load")); ClassReader reader = new ClassReader(bytes); ClassWriter writer = new ClassWriter( reader, ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES); CallbackClassVisitor classVisitor = new CallbackClassVisitor(writer); reader.accept(classVisitor, 0); instrClassesDone.add(className); return writer.toByteArray(); }
Example 7
Source File: ClassEmitter.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * Constructor from the compiler. * * @param env Script environment * @param sourceName Source name * @param unitClassName Compile unit class name. * @param strictMode Should we generate this method in strict mode */ ClassEmitter(final Context context, final String sourceName, final String unitClassName, final boolean strictMode) { this(context, new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS) { private static final String OBJECT_CLASS = "java/lang/Object"; @Override protected String getCommonSuperClass(final String type1, final String type2) { try { return super.getCommonSuperClass(type1, type2); } catch (final RuntimeException e) { if (isScriptObject(Compiler.SCRIPTS_PACKAGE, type1) && isScriptObject(Compiler.SCRIPTS_PACKAGE, type2)) { return className(ScriptObject.class); } return OBJECT_CLASS; } } }); this.unitClassName = unitClassName; this.constantMethodNeeded = new HashSet<>(); cw.visit(V1_7, ACC_PUBLIC | ACC_SUPER, unitClassName, null, pathName(jdk.nashorn.internal.scripts.JS.class.getName()), null); cw.visitSource(sourceName, null); defineCommonStatics(strictMode); }
Example 8
Source File: ClassGenerator.java From nashorn with GNU General Public License v2.0 | 5 votes |
static ClassWriter makeClassWriter() { return new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS) { @Override protected String getCommonSuperClass(final String type1, final String type2) { try { return super.getCommonSuperClass(type1, type2); } catch (final RuntimeException | LinkageError e) { return StringConstants.OBJECT_TYPE; } } }; }
Example 9
Source File: DefineClassTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Generate a class file with the given class name. The class implements Runnable * with a run method to invokestatic the given targetClass/targetMethod. */ byte[] generateRunner(String className, String targetClass, String targetMethod) throws Exception { ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS + ClassWriter.COMPUTE_FRAMES); cw.visit(V1_9, ACC_PUBLIC + ACC_SUPER, className.replace(".", "/"), null, "java/lang/Object", new String[] { "java/lang/Runnable" }); // <init> MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null); mv.visitVarInsn(ALOAD, 0); mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V", false); mv.visitInsn(RETURN); mv.visitMaxs(0, 0); mv.visitEnd(); // run() String tc = targetClass.replace(".", "/"); mv = cw.visitMethod(ACC_PUBLIC, "run", "()V", null, null); mv.visitMethodInsn(INVOKESTATIC, tc, targetMethod, "()V", false); mv.visitInsn(RETURN); mv.visitMaxs(0, 0); mv.visitEnd(); cw.visitEnd(); return cw.toByteArray(); }
Example 10
Source File: GenerateJLIClassesHelper.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private static byte[] generateCodeBytesForLFs(String className, String[] names, LambdaForm[] forms) { ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS + ClassWriter.COMPUTE_FRAMES); cw.visit(Opcodes.V1_8, Opcodes.ACC_PRIVATE + Opcodes.ACC_FINAL + Opcodes.ACC_SUPER, className, null, InvokerBytecodeGenerator.INVOKER_SUPER_NAME, null); cw.visitSource(className.substring(className.lastIndexOf('/') + 1), null); for (int i = 0; i < forms.length; i++) { addMethod(className, names[i], forms[i], forms[i].methodType(), cw); } return cw.toByteArray(); }
Example 11
Source File: ClassEmitter.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * Constructor from the compiler. * * @param env Script environment * @param sourceName Source name * @param unitClassName Compile unit class name. * @param strictMode Should we generate this method in strict mode */ ClassEmitter(final Context context, final String sourceName, final String unitClassName, final boolean strictMode) { this(context, new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS) { private static final String OBJECT_CLASS = "java/lang/Object"; @Override protected String getCommonSuperClass(final String type1, final String type2) { try { return super.getCommonSuperClass(type1, type2); } catch (final RuntimeException e) { if (isScriptObject(Compiler.SCRIPTS_PACKAGE, type1) && isScriptObject(Compiler.SCRIPTS_PACKAGE, type2)) { return className(ScriptObject.class); } return OBJECT_CLASS; } } }); this.unitClassName = unitClassName; this.constantMethodNeeded = new HashSet<>(); cw.visit(V1_7, ACC_PUBLIC | ACC_SUPER, unitClassName, null, pathName(jdk.nashorn.internal.scripts.JS.class.getName()), null); cw.visitSource(sourceName, null); defineCommonStatics(strictMode); }
Example 12
Source File: ClassEmitter.java From jdk8u_nashorn with GNU General Public License v2.0 | 5 votes |
/** * Constructor from the compiler. * * @param env Script environment * @param sourceName Source name * @param unitClassName Compile unit class name. * @param strictMode Should we generate this method in strict mode */ ClassEmitter(final Context context, final String sourceName, final String unitClassName, final boolean strictMode) { this(context, new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS) { private static final String OBJECT_CLASS = "java/lang/Object"; @Override protected String getCommonSuperClass(final String type1, final String type2) { try { return super.getCommonSuperClass(type1, type2); } catch (final RuntimeException e) { if (isScriptObject(Compiler.SCRIPTS_PACKAGE, type1) && isScriptObject(Compiler.SCRIPTS_PACKAGE, type2)) { return className(ScriptObject.class); } return OBJECT_CLASS; } } }); this.unitClassName = unitClassName; this.constantMethodNeeded = new HashSet<>(); cw.visit(V1_7, ACC_PUBLIC | ACC_SUPER, unitClassName, null, pathName(jdk.nashorn.internal.scripts.JS.class.getName()), null); cw.visitSource(sourceName, null); defineCommonStatics(strictMode); }
Example 13
Source File: ClassEmitter.java From nashorn with GNU General Public License v2.0 | 5 votes |
/** * Constructor from the compiler * * @param env Script environment * @param sourceName Source name * @param unitClassName Compile unit class name. * @param strictMode Should we generate this method in strict mode */ ClassEmitter(final ScriptEnvironment env, final String sourceName, final String unitClassName, final boolean strictMode) { this(env, new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS) { private static final String OBJECT_CLASS = "java/lang/Object"; @Override protected String getCommonSuperClass(final String type1, final String type2) { try { return super.getCommonSuperClass(type1, type2); } catch (final RuntimeException e) { if (isScriptObject(Compiler.SCRIPTS_PACKAGE, type1) && isScriptObject(Compiler.SCRIPTS_PACKAGE, type2)) { return className(ScriptObject.class); } return OBJECT_CLASS; } } }); this.unitClassName = unitClassName; this.constantMethodNeeded = new HashSet<>(); cw.visit(V1_7, ACC_PUBLIC | ACC_SUPER, unitClassName, null, pathName(jdk.nashorn.internal.scripts.JS.class.getName()), null); cw.visitSource(sourceName, null); defineCommonStatics(strictMode); }
Example 14
Source File: TestAMEnotNPE.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
/** * The bytecodes for a class p/T defining a methods test() and test(11args) * that contain an invokeExact of a particular methodHandle, I.m. * * Test will be passed values that may imperfectly implement I, * and thus may in turn throw exceptions. * * @return * @throws Exception */ public static byte[] bytesForT() throws Exception { ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS); MethodVisitor mv; cw.visit(V1_8, ACC_PUBLIC + ACC_SUPER, "p/T", null, "java/lang/Object", null); { mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null); mv.visitCode(); mv.visitVarInsn(ALOAD, 0); mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V"); mv.visitInsn(RETURN); mv.visitMaxs(0, 0); mv.visitEnd(); } // static int test(I) { mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, "test", "(Lp/I;)I", null, null); mv.visitCode(); mv.visitLdcInsn(new Handle(Opcodes.H_INVOKEINTERFACE, "p/I", "m", "()I")); mv.visitVarInsn(ALOAD, 0); mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/invoke/MethodHandle", "invokeExact", "(Lp/I;)I"); mv.visitInsn(IRETURN); mv.visitMaxs(0, 0); mv.visitEnd(); } // static int test(I,11args) { mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, "test", "(Lp/I;BCSIJLjava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)I", null, null); mv.visitCode(); mv.visitLdcInsn(new Handle(Opcodes.H_INVOKEINTERFACE, "p/I", "m", "(BCSIJLjava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)I")); mv.visitVarInsn(ALOAD, 0); mv.visitVarInsn(ILOAD, 1); mv.visitVarInsn(ILOAD, 2); mv.visitVarInsn(ILOAD, 3); mv.visitVarInsn(ILOAD, 4); mv.visitVarInsn(LLOAD, 5); mv.visitVarInsn(ALOAD, 7); mv.visitVarInsn(ALOAD, 8); mv.visitVarInsn(ALOAD, 9); mv.visitVarInsn(ALOAD, 10); mv.visitVarInsn(ALOAD, 11); mv.visitVarInsn(ALOAD, 12); mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/invoke/MethodHandle", "invokeExact", "(Lp/I;BCSIJLjava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)I"); mv.visitInsn(IRETURN); mv.visitMaxs(0, 0); mv.visitEnd(); } cw.visitEnd(); return cw.toByteArray(); }
Example 15
Source File: JavaAdapterServices.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
private static MethodHandle createNoPermissionsInvoker() { final String className = "NoPermissionsInvoker"; final ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS); cw.visit(Opcodes.V1_7, ACC_PUBLIC | ACC_SUPER | ACC_FINAL, className, null, "java/lang/Object", null); final Type objectType = Type.getType(Object.class); final Type methodHandleType = Type.getType(MethodHandle.class); final InstructionAdapter mv = new InstructionAdapter(cw.visitMethod(ACC_PUBLIC | ACC_STATIC, "invoke", Type.getMethodDescriptor(Type.VOID_TYPE, methodHandleType, objectType), null, null)); mv.visitCode(); mv.visitVarInsn(ALOAD, 0); mv.visitVarInsn(ALOAD, 1); mv.invokevirtual(methodHandleType.getInternalName(), "invokeExact", Type.getMethodDescriptor( Type.VOID_TYPE, objectType), false); mv.visitInsn(RETURN); mv.visitMaxs(0, 0); mv.visitEnd(); cw.visitEnd(); final byte[] bytes = cw.toByteArray(); final ClassLoader loader = AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() { @Override public ClassLoader run() { return new SecureClassLoader(null) { @Override protected Class<?> findClass(final String name) throws ClassNotFoundException { if(name.equals(className)) { return defineClass(name, bytes, 0, bytes.length, new ProtectionDomain( new CodeSource(null, (CodeSigner[])null), new Permissions())); } throw new ClassNotFoundException(name); } }; } }); try { return MethodHandles.lookup().findStatic(Class.forName(className, true, loader), "invoke", MethodType.methodType(void.class, MethodHandle.class, Object.class)); } catch(final ReflectiveOperationException e) { throw new AssertionError(e.getMessage(), e); } }
Example 16
Source File: TestAMEnotNPE.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
/** * The bytecodes for a class p/T defining a methods test() and test(11args) * that contain an invokeExact of a particular methodHandle, I.m. * * Test will be passed values that may imperfectly implement I, * and thus may in turn throw exceptions. * * @return * @throws Exception */ public static byte[] bytesForT() throws Exception { ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS); MethodVisitor mv; cw.visit(V1_8, ACC_PUBLIC + ACC_SUPER, "p/T", null, "java/lang/Object", null); { mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null); mv.visitCode(); mv.visitVarInsn(ALOAD, 0); mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V"); mv.visitInsn(RETURN); mv.visitMaxs(0, 0); mv.visitEnd(); } // static int test(I) { mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, "test", "(Lp/I;)I", null, null); mv.visitCode(); mv.visitLdcInsn(new Handle(Opcodes.H_INVOKEINTERFACE, "p/I", "m", "()I")); mv.visitVarInsn(ALOAD, 0); mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/invoke/MethodHandle", "invokeExact", "(Lp/I;)I"); mv.visitInsn(IRETURN); mv.visitMaxs(0, 0); mv.visitEnd(); } // static int test(I,11args) { mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, "test", "(Lp/I;BCSIJLjava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)I", null, null); mv.visitCode(); mv.visitLdcInsn(new Handle(Opcodes.H_INVOKEINTERFACE, "p/I", "m", "(BCSIJLjava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)I")); mv.visitVarInsn(ALOAD, 0); mv.visitVarInsn(ILOAD, 1); mv.visitVarInsn(ILOAD, 2); mv.visitVarInsn(ILOAD, 3); mv.visitVarInsn(ILOAD, 4); mv.visitVarInsn(LLOAD, 5); mv.visitVarInsn(ALOAD, 7); mv.visitVarInsn(ALOAD, 8); mv.visitVarInsn(ALOAD, 9); mv.visitVarInsn(ALOAD, 10); mv.visitVarInsn(ALOAD, 11); mv.visitVarInsn(ALOAD, 12); mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/invoke/MethodHandle", "invokeExact", "(Lp/I;BCSIJLjava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)I"); mv.visitInsn(IRETURN); mv.visitMaxs(0, 0); mv.visitEnd(); } cw.visitEnd(); return cw.toByteArray(); }
Example 17
Source File: TestAMEnotNPE.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
/** * The bytecodes for a class p/T defining a methods test() and test(11args) * that contain an invokeExact of a particular methodHandle, I.m. * * Test will be passed values that may imperfectly implement I, * and thus may in turn throw exceptions. * * @return * @throws Exception */ public static byte[] bytesForT() throws Exception { ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS); MethodVisitor mv; cw.visit(V1_8, ACC_PUBLIC + ACC_SUPER, "p/T", null, "java/lang/Object", null); { mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null); mv.visitCode(); mv.visitVarInsn(ALOAD, 0); mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V"); mv.visitInsn(RETURN); mv.visitMaxs(0, 0); mv.visitEnd(); } // static int test(I) { mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, "test", "(Lp/I;)I", null, null); mv.visitCode(); mv.visitLdcInsn(new Handle(Opcodes.H_INVOKEINTERFACE, "p/I", "m", "()I")); mv.visitVarInsn(ALOAD, 0); mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/invoke/MethodHandle", "invokeExact", "(Lp/I;)I"); mv.visitInsn(IRETURN); mv.visitMaxs(0, 0); mv.visitEnd(); } // static int test(I,11args) { mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, "test", "(Lp/I;BCSIJLjava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)I", null, null); mv.visitCode(); mv.visitLdcInsn(new Handle(Opcodes.H_INVOKEINTERFACE, "p/I", "m", "(BCSIJLjava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)I")); mv.visitVarInsn(ALOAD, 0); mv.visitVarInsn(ILOAD, 1); mv.visitVarInsn(ILOAD, 2); mv.visitVarInsn(ILOAD, 3); mv.visitVarInsn(ILOAD, 4); mv.visitVarInsn(LLOAD, 5); mv.visitVarInsn(ALOAD, 7); mv.visitVarInsn(ALOAD, 8); mv.visitVarInsn(ALOAD, 9); mv.visitVarInsn(ALOAD, 10); mv.visitVarInsn(ALOAD, 11); mv.visitVarInsn(ALOAD, 12); mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/invoke/MethodHandle", "invokeExact", "(Lp/I;BCSIJLjava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)I"); mv.visitInsn(IRETURN); mv.visitMaxs(0, 0); mv.visitEnd(); } cw.visitEnd(); return cw.toByteArray(); }
Example 18
Source File: SystemModulesPlugin.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
public SystemModulesClassGenerator(boolean retainModuleTarget) { this.cw = new ClassWriter(ClassWriter.COMPUTE_MAXS + ClassWriter.COMPUTE_FRAMES); this.dropModuleTarget = !retainModuleTarget; }
Example 19
Source File: ClassEmitter.java From jdk8u_nashorn with GNU General Public License v2.0 | 2 votes |
/** * Constructor. * * @param env script environment * @param className name of class to weave * @param superClassName super class name for class * @param interfaceNames names of interfaces implemented by this class, or * {@code null} if none */ ClassEmitter(final Context context, final String className, final String superClassName, final String... interfaceNames) { this(context, new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS)); cw.visit(V1_7, ACC_PUBLIC | ACC_SUPER, className, null, superClassName, interfaceNames); }
Example 20
Source File: ClassEmitter.java From jdk8u60 with GNU General Public License v2.0 | 2 votes |
/** * Constructor. * * @param env script environment * @param className name of class to weave * @param superClassName super class name for class * @param interfaceNames names of interfaces implemented by this class, or * {@code null} if none */ ClassEmitter(final Context context, final String className, final String superClassName, final String... interfaceNames) { this(context, new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS)); cw.visit(V1_7, ACC_PUBLIC | ACC_SUPER, className, null, superClassName, interfaceNames); }