Package alt.jiapi.reflect

Examples of alt.jiapi.reflect.InstructionFactory.invoke()


        JiapiMethod method = c.addMethod(Modifier.PUBLIC, "<init>", emptySig);
        InstructionList il = method.getInstructionList();
        InstructionFactory iFactory = il.getInstructionFactory();
        il.add(iFactory.aload(0));
        il.add(iFactory.invoke(0, "java/lang/Object", "<init>", emptySig));
        il.add(iFactory.returnMethod(method));

        method = c.addMethod(Modifier.PUBLIC | Modifier.STATIC, "main", mainSig);
        il = method.getInstructionList();
        iFactory = il.getInstructionFactory();
View Full Code Here


        il.add(iFactory.getField(Modifier.STATIC,
                "java/lang/System",
                "out",
                "Ljava/io/PrintStream;"));
        il.add(iFactory.pushConstant("Hello world!"));
        il.add(iFactory.invoke(0, "java/io/PrintStream", "println", printlnSig));
        il.add(iFactory.returnMethod(method));

        return c.getByteCode();
    }
View Full Code Here

            throw new JiapiRuntimeException("No such field: " + e.getMessage());
        }

        // Get the initialized value from Runtime.
        il.add(factory.pushConstant(fieldName));
        il.add(factory.invoke(getFieldValue));
       
        // Cast the field.
        il.add(factory.cast(field.getTypeName()));

        // Set the field.
View Full Code Here

//         il.add(iFactory.getField(loader.loadClass("java.lang.System").getField("out")));
//         JiapiMethod println = loader.loadClass(System.out.getClass().getName()).getMethod("println", new String[] { "java.lang.String" } );

        il.add(iFactory.pushConstant("hello world!"));

        il.add(iFactory.invoke(println));
        il.add(iFactory.returnMethod(method));

        // Finalize the modified class and dump it to the file:

        clazz.dump(new FileOutputStream("Test.class"));
View Full Code Here

            case Opcodes.GETFIELD:
                invokeList.add(factory.getField(jiapiField));
                invokeList.add(factory.pushThis());
                invokeList.add(factory.pushConstant(ins.getFieldName()));
                if (ins.getOpcode() == Opcodes.GETFIELD) {
                    invokeList.add(factory.invoke(fieldGet));
                }
                else {
                    invokeList.add(factory.invoke(fieldSet));
                }
                break;
View Full Code Here

                invokeList.add(factory.pushConstant(ins.getFieldName()));
                if (ins.getOpcode() == Opcodes.GETFIELD) {
                    invokeList.add(factory.invoke(fieldGet));
                }
                else {
                    invokeList.add(factory.invoke(fieldSet));
                }
                break;
            case Opcodes.PUTSTATIC:
            case Opcodes.GETSTATIC:
                invokeList.add(factory.getField(jiapiField));
View Full Code Here

            case Opcodes.GETSTATIC:
                invokeList.add(factory.getField(jiapiField));
                invokeList.add(factory.getField(jiapiField)); // BUG: Class
                invokeList.add(factory.pushConstant(ins.getFieldName()));
                if (ins.getOpcode() == Opcodes.GETSTATIC) {
                    invokeList.add(factory.invoke(fieldGet));
                }
                else {
                    invokeList.add(factory.invoke(fieldSet));
                }
                break;
View Full Code Here

                invokeList.add(factory.pushConstant(ins.getFieldName()));
                if (ins.getOpcode() == Opcodes.GETSTATIC) {
                    invokeList.add(factory.invoke(fieldGet));
                }
                else {
                    invokeList.add(factory.invoke(fieldSet));
                }
                break;
            }

            // Insert list after field access operation
View Full Code Here

        }
        else {
            entryList.add(factory.pushThis());
        }
        entryList.add(factory.pushConstant(il.getDeclaringMethod().getName()));
        entryList.add(factory.invoke(methodEntered));

        // Skip super(....) call, if in <init> method
        int superIdx = il.indexOf(Opcodes.INVOKESPECIAL);

        // BUG: we should insert entrylist on <clinit> pass the
View Full Code Here

        else {
            exitList.add(factory.pushThis());
        }

        exitList.add(factory.pushConstant(il.getDeclaringMethod().getName()));
        exitList.add(factory.invoke(methodExited));

        // Find all method exits
        int idx = il.indexOf(OpcodeGroups.RETURN_INSTRUCTIONS, 0);
        while (idx != -1) {
            Instruction ins = il.get(idx);
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.