Examples of ImmediateShortInstruction


Examples of org.gjt.jclasslib.bytecode.ImmediateShortInstruction

        ca1.setAttributeNameIndex(ConstantPoolUtil.addConstantUTF8Info(cf,
                CodeAttribute.ATTRIBUTE_NAME,
                0));
        ca1.setCode(ByteCodeWriter.writeByteCode(Arrays.asList(new org.gjt.jclasslib.bytecode.AbstractInstruction[] {
            new SimpleInstruction(org.gjt.jclasslib.bytecode.Opcodes.OPCODE_ALOAD_0),
            new ImmediateShortInstruction(org.gjt.jclasslib.bytecode.Opcodes.OPCODE_INVOKESPECIAL,
                    ConstantPoolUtil.addConstantMethodrefInfo(cf,
                            "java/lang/Object",
                            "<init>",
                            "()V",
                            0)),
            new SimpleInstruction(org.gjt.jclasslib.bytecode.Opcodes.OPCODE_RETURN) })));
        ca1.setMaxStack(1);
        ca1.setMaxLocals(1);
        mi1.setAttributes(new AttributeInfo[] { ca1 });

        ConstantStringInfo s = new ConstantStringInfo();
        s.setStringIndex(ConstantPoolUtil.addConstantUTF8Info(cf,
                "Hello world!",
                0));

        org.gjt.jclasslib.structures.MethodInfo mi2 = new org.gjt.jclasslib.structures.MethodInfo();
        mi2.setAccessFlags(AccessFlags.ACC_PUBLIC | AccessFlags.ACC_STATIC);
        mi2.setNameIndex(ConstantPoolUtil.addConstantUTF8Info(cf, "main", 0));
        mi2.setDescriptorIndex(ConstantPoolUtil.addConstantUTF8Info(cf,
                "([Ljava/lang/String;)V",
                0));
        CodeAttribute ca2 = new CodeAttribute();
        ca2.setAttributeNameIndex(ConstantPoolUtil.addConstantUTF8Info(cf,
                CodeAttribute.ATTRIBUTE_NAME,
                0));
        ca2.setCode(ByteCodeWriter.writeByteCode(Arrays.asList(new org.gjt.jclasslib.bytecode.AbstractInstruction[] {
            new ImmediateShortInstruction(org.gjt.jclasslib.bytecode.Opcodes.OPCODE_GETSTATIC,
                    ConstantPoolUtil.addConstantFieldrefInfo(cf,
                            "java/lang/System",
                            "out",
                            "Ljava/io/PrintStream;",
                            0)),
            new ImmediateByteInstruction(org.gjt.jclasslib.bytecode.Opcodes.OPCODE_LDC,
                    false,
                    ConstantPoolUtil.addConstantPoolEntry(cf, s, 0)),
            new ImmediateShortInstruction(org.gjt.jclasslib.bytecode.Opcodes.OPCODE_INVOKEVIRTUAL,
                    ConstantPoolUtil.addConstantMethodrefInfo(cf,
                            "java/io/PrintStream",
                            "println",
                            "(Ljava/lang/String;)V",
                            0)) })));
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.