Java Code Examples for jdk.internal.org.objectweb.asm.ClassWriter#COMPUTE_FRAMES

The following examples show how to use jdk.internal.org.objectweb.asm.ClassWriter#COMPUTE_FRAMES . 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: CallSiteDepContextTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
static byte[] getClassFile(String suffix) {
    ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
    MethodVisitor mv;
    cw.visit(52, ACC_PUBLIC | ACC_SUPER, CLASS_NAME + suffix, null, "java/lang/Object", null);
    {
        mv = cw.visitMethod(ACC_PUBLIC | ACC_STATIC, METHOD_NAME, TYPE.toMethodDescriptorString(), null, null);
        mv.visitCode();
        Handle bsm = new Handle(H_INVOKESTATIC,
                CallSiteDepContextTest.class.getName().replace(".", "/"),
                "bootstrap",
                bsmMH.type().toMethodDescriptorString());
        mv.visitInvokeDynamicInsn("methodName", TYPE.toMethodDescriptorString(), bsm);
        mv.visitInsn(IRETURN);
        mv.visitMaxs(0, 0);
        mv.visitEnd();
    }
    cw.visitEnd();
    return cw.toByteArray();
}
 
Example 2
Source File: TestAMEnotNPE.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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 3
Source File: DefineClassTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Generates a class file with the given class name
 */
byte[] generateClass(String className) {
    ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS
                                     + ClassWriter.COMPUTE_FRAMES);
    cw.visit(V1_9,
            ACC_PUBLIC + ACC_SUPER,
            className.replace(".", "/"),
            null,
            "java/lang/Object",
            null);

    // <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();

    cw.visitEnd();
    return cw.toByteArray();
}
 
Example 4
Source File: TestInstrumentation.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
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: DefineClassTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Generate a class file with the given class name. The class will initializer
 * to invokestatic the given targetClass/targetMethod.
 */
byte[] generateClassWithInitializer(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",
            null);

    // <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();

    // <clinit>
    String tc = targetClass.replace(".", "/");
    mv = cw.visitMethod(ACC_STATIC, "<clinit>", "()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 6
Source File: ClassGenerator.java    From jdk8u_nashorn with GNU General Public License v2.0 5 votes vote down vote up
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 7
Source File: ClassEmitter.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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 TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
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: JIClassInstrumentation.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private byte[] makeBytecode() throws IOException, ClassNotFoundException {

        // Find the methods to instrument and inline

        final List<Method> instrumentationMethods = new ArrayList<>();
        for (final Method m : instrumentor.getDeclaredMethods()) {
            JIInstrumentationMethod im = m.getAnnotation(JIInstrumentationMethod.class);
            if (im != null) {
                instrumentationMethods.add(m);
            }
        }

        // We begin by inlining the target's methods into the instrumentor

        ClassNode temporary = new ClassNode();
        ClassVisitor inliner = new JIInliner(
                Opcodes.ASM5,
                temporary,
                targetName,
                instrumentorName,
                targetClassReader,
                instrumentationMethods);
        instrClassReader.accept(inliner, ClassReader.EXPAND_FRAMES);

        // Now we have the target's methods inlined into the instrumentation code (in 'temporary').
        // We now need to replace the target's method with the code in the
        // instrumentation method.

        ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES);
        JIMethodMergeAdapter ma = new JIMethodMergeAdapter(
                cw,
                temporary,
                instrumentationMethods,
                instrumentor.getAnnotationsByType(JITypeMapping.class));
        targetClassReader.accept(ma, ClassReader.EXPAND_FRAMES);

       return cw.toByteArray();
    }
 
Example 10
Source File: ClassGenerator.java    From nashorn with GNU General Public License v2.0 5 votes vote down vote up
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 11
Source File: TestOSRWithNonEmptyStack.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private static byte[] generateTestClass() {
    ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES);

    cw.visit(TestOSRWithNonEmptyStack.CLASS_FILE_VERSION, ACC_PUBLIC,
            TestOSRWithNonEmptyStack.CLASS_NAME, null, "java/lang/Object",
            null);

    TestOSRWithNonEmptyStack.generateConstructor(cw);
    TestOSRWithNonEmptyStack.generateTestMethod(cw);

    cw.visitEnd();
    return cw.toByteArray();
}
 
Example 12
Source File: ClassEmitter.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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: TestAMEnotNPE.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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 14
Source File: SystemModulesPlugin.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public SystemModulesClassGenerator(boolean retainModuleTarget) {
    this.cw = new ClassWriter(ClassWriter.COMPUTE_MAXS +
                              ClassWriter.COMPUTE_FRAMES);
    this.dropModuleTarget = !retainModuleTarget;
}
 
Example 15
Source File: UntrustedInterfaces.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected Class<?> findClass(String name) throws ClassNotFoundException {
    if (name.equals(POISON_IMPL_NAME)) {
        ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES);

        cw.visit(Opcodes.V1_8, Opcodes.ACC_PUBLIC, POISON_IMPL_NAME.replace('.', '/'), null, Type.getInternalName(Pill.class), null);
        // constructor
        MethodVisitor constructor = cw.visitMethod(Opcodes.ACC_PUBLIC, "<init>", "()V", null, null);
        constructor.visitCode();
        constructor.visitVarInsn(Opcodes.ALOAD, 0);
        constructor.visitMethodInsn(Opcodes.INVOKESPECIAL, Type.getInternalName(Pill.class), "<init>", "()V", false);
        constructor.visitInsn(Opcodes.RETURN);
        constructor.visitMaxs(0, 0);
        constructor.visitEnd();

        MethodVisitor setList = cw.visitMethod(Opcodes.ACC_PUBLIC, "setField", "()V", null, null);
        setList.visitCode();
        setList.visitVarInsn(Opcodes.ALOAD, 0);
        setList.visitTypeInsn(Opcodes.NEW, Type.getInternalName(Object.class));
        setList.visitInsn(Opcodes.DUP);
        setList.visitMethodInsn(Opcodes.INVOKESPECIAL, Type.getInternalName(Object.class), "<init>", "()V", false);
        setList.visitFieldInsn(Opcodes.PUTFIELD, Type.getInternalName(Pill.class), "field", Type.getDescriptor(TestInterface.class));
        setList.visitInsn(Opcodes.RETURN);
        setList.visitMaxs(0, 0);
        setList.visitEnd();

        MethodVisitor setStaticList = cw.visitMethod(Opcodes.ACC_PUBLIC, "setStaticField", "()V", null, null);
        setStaticList.visitCode();
        setStaticList.visitTypeInsn(Opcodes.NEW, Type.getInternalName(Object.class));
        setStaticList.visitInsn(Opcodes.DUP);
        setStaticList.visitMethodInsn(Opcodes.INVOKESPECIAL, Type.getInternalName(Object.class), "<init>", "()V", false);
        setStaticList.visitFieldInsn(Opcodes.PUTSTATIC, Type.getInternalName(Pill.class), "staticField", Type.getDescriptor(TestInterface.class));
        setStaticList.visitInsn(Opcodes.RETURN);
        setStaticList.visitMaxs(0, 0);
        setStaticList.visitEnd();

        MethodVisitor callMe = cw.visitMethod(Opcodes.ACC_PUBLIC, "callMe", Type.getMethodDescriptor(Type.INT_TYPE, Type.getType(CallBack.class)), null, null);
        callMe.visitCode();
        callMe.visitVarInsn(Opcodes.ALOAD, 1);
        callMe.visitTypeInsn(Opcodes.NEW, Type.getInternalName(Object.class));
        callMe.visitInsn(Opcodes.DUP);
        callMe.visitMethodInsn(Opcodes.INVOKESPECIAL, Type.getInternalName(Object.class), "<init>", "()V", false);
        callMe.visitMethodInsn(Opcodes.INVOKEINTERFACE, Type.getInternalName(CallBack.class), "callBack", Type.getMethodDescriptor(Type.INT_TYPE, Type.getType(TestInterface.class)), true);
        callMe.visitInsn(Opcodes.IRETURN);
        callMe.visitMaxs(0, 0);
        callMe.visitEnd();

        MethodVisitor getList = cw.visitMethod(Opcodes.ACC_PUBLIC, "get", Type.getMethodDescriptor(Type.getType(TestInterface.class)), null, null);
        getList.visitCode();
        getList.visitTypeInsn(Opcodes.NEW, Type.getInternalName(Object.class));
        getList.visitInsn(Opcodes.DUP);
        getList.visitMethodInsn(Opcodes.INVOKESPECIAL, Type.getInternalName(Object.class), "<init>", "()V", false);
        getList.visitInsn(Opcodes.ARETURN);
        getList.visitMaxs(0, 0);
        getList.visitEnd();

        cw.visitEnd();

        byte[] bytes = cw.toByteArray();
        return defineClass(name, bytes, 0, bytes.length);
    }
    return super.findClass(name);
}
 
Example 16
Source File: Module.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Loads module-info.class as a package-private interface in a class loader
 * that is a child of this module's class loader.
 */
private Class<?> loadModuleInfoClass(InputStream in) throws IOException {
    final String MODULE_INFO = "module-info";

    ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS
                                     + ClassWriter.COMPUTE_FRAMES);

    ClassVisitor cv = new ClassVisitor(Opcodes.ASM5, cw) {
        @Override
        public void visit(int version,
                          int access,
                          String name,
                          String signature,
                          String superName,
                          String[] interfaces) {
            cw.visit(version,
                    Opcodes.ACC_INTERFACE
                        + Opcodes.ACC_ABSTRACT
                        + Opcodes.ACC_SYNTHETIC,
                    MODULE_INFO,
                    null,
                    "java/lang/Object",
                    null);
        }
        @Override
        public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
            // keep annotations
            return super.visitAnnotation(desc, visible);
        }
        @Override
        public void visitAttribute(Attribute attr) {
            // drop non-annotation attributes
        }
    };

    ClassReader cr = new ClassReader(in);
    cr.accept(cv, 0);
    byte[] bytes = cw.toByteArray();

    ClassLoader cl = new ClassLoader(loader) {
        @Override
        protected Class<?> findClass(String cn)throws ClassNotFoundException {
            if (cn.equals(MODULE_INFO)) {
                return super.defineClass(cn, bytes, 0, bytes.length);
            } else {
                throw new ClassNotFoundException(cn);
            }
        }
    };

    try {
        return cl.loadClass(MODULE_INFO);
    } catch (ClassNotFoundException e) {
        throw new InternalError(e);
    }
}
 
Example 17
Source File: ClassEmitter.java    From jdk8u60 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * 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 18
Source File: ClassEmitter.java    From hottub with GNU General Public License v2.0 2 votes vote down vote up
/**
 * 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 19
Source File: ClassEmitter.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 2 votes vote down vote up
/**
 * 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 nashorn with GNU General Public License v2.0 2 votes vote down vote up
/**
 * 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 null if none
 */
ClassEmitter(final ScriptEnvironment env, final String className, final String superClassName, final String... interfaceNames) {
    this(env, new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS));
    cw.visit(V1_7, ACC_PUBLIC | ACC_SUPER, className, null, superClassName, interfaceNames);
}