Package org.objectweb.asm

Examples of org.objectweb.asm.ClassVisitor.visitField()


            Function function;
            try {
                function = getFunction(library.findSymbolAddress(functionName),
                    resultType, parameterTypes, saveErrno, callingConvention);
            } catch (SymbolNotFoundError ex) {
                cv.visitField(ACC_PRIVATE | ACC_FINAL | ACC_STATIC, "error_" + i, ci(String.class), null, ex.getMessage());
                generateFunctionNotFound(cv, className, i, functionName, javaReturnType, javaParameterTypes);
                continue;
            }

            for (MethodGenerator g : generators) {
View Full Code Here


        AsmBuilder.ObjectField[] fields = builder.getObjectFieldArray();
        Object[] fieldObjects = new Object[fields.length];
        for (int i = 0; i < fieldObjects.length; i++) {
            fieldObjects[i] = fields[i].value;
            String fieldName = fields[i].name;
            cv.visitField(ACC_PRIVATE | ACC_FINAL, fieldName, ci(fields[i].klass), null, null);
            init.aload(0);
            init.aload(2);
            init.pushInt(i);
            init.aaload();
View Full Code Here

    public void test() throws Exception {
        ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
        ClassVisitor cv = new StaticInitMerger("$clinit$", cw);
        cv.visit(V1_1, ACC_PUBLIC, "A", null, "java/lang/Object", null);
        cv.visitField(ACC_PUBLIC + ACC_STATIC, "counter", "I", null, null);
        for (int i = 0; i < 5; ++i) {
            MethodVisitor mv = cv.visitMethod(ACC_PUBLIC,
                    "<clinit>",
                    "()V",
                    null,
View Full Code Here

    public void testIllegalFieldAccessFlagSet() {
        ClassVisitor cv = new CheckClassAdapter(new EmptyVisitor());
        cv.visit(V1_1, ACC_PUBLIC, "C", null, "java/lang/Object", null);
        try {
            cv.visitField(ACC_PUBLIC + ACC_PRIVATE, "i", "I", null, null);
            fail();
        } catch (Exception e) {
        }
    }
   
View Full Code Here

   
    public void testIllegalFieldSignature() {
        ClassVisitor cv = new CheckClassAdapter(new EmptyVisitor());
        cv.visit(V1_1, ACC_PUBLIC, "C", null, "java/lang/Object", null);
        try {
            cv.visitField(ACC_PUBLIC, "i", "I", "L;", null);
            fail();
        } catch (Exception e) {
        }
        try {
            cv.visitField(ACC_PUBLIC, "i", "I", "LC+", null);
View Full Code Here

            cv.visitField(ACC_PUBLIC, "i", "I", "L;", null);
            fail();
        } catch (Exception e) {
        }
        try {
            cv.visitField(ACC_PUBLIC, "i", "I", "LC+", null);
            fail();
        } catch (Exception e) {
        }
        try {
            cv.visitField(ACC_PUBLIC, "i", "I", "LC;I", null);
View Full Code Here

            cv.visitField(ACC_PUBLIC, "i", "I", "LC+", null);
            fail();
        } catch (Exception e) {
        }
        try {
            cv.visitField(ACC_PUBLIC, "i", "I", "LC;I", null);
            fail();
        } catch (Exception e) {
        }
    }
View Full Code Here

        ClassVisitor cv = getClassVisitor();

        String realName = getNewConstantName();

        // declare the field
        cv.visitField(ACC_PRIVATE, realName, type, null, null).visitEnd();

        if(init != null) {
            initMethod.aload(THIS);
            initMethod.ldc(init);
            initMethod.putfield(getClassname(),realName, type);
View Full Code Here

    public String getNewField(String type, String name, Object init) {
        ClassVisitor cv = getClassVisitor();

        // declare the field
        cv.visitField(ACC_PRIVATE, name, type, null, null).visitEnd();

        if(init != null) {
            initMethod.aload(THIS);
            initMethod.ldc(init);
            initMethod.putfield(getClassname(),name, type);
View Full Code Here

        synchronized (this) {
            realName = "__" + constants++;
        }

        // declare the field
        cv.visitField(ACC_PRIVATE | ACC_STATIC | ACC_FINAL, realName, type, null, null).visitEnd();
        return realName;
    }
}
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.