Package org.gjt.jclasslib.structures.attributes

Examples of org.gjt.jclasslib.structures.attributes.CodeAttribute


        mi1.setAccessFlags(AccessFlags.ACC_PUBLIC);
        mi1.setNameIndex(ConstantPoolUtil.addConstantUTF8Info(cf, "<init>", 0));
        mi1.setDescriptorIndex(ConstantPoolUtil.addConstantUTF8Info(cf,
                "()V",
                0));
        CodeAttribute ca1 = new CodeAttribute();
        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)) })));
        ca2.setMaxStack(2);
        ca2.setMaxLocals(1);
        mi2.setAttributes(new AttributeInfo[] { ca2 });

        cf.setMethods(new org.gjt.jclasslib.structures.MethodInfo[] { mi1, mi2 });
        cf.setAttributes(new AttributeInfo[] { sa });
View Full Code Here


                           lblCodeLength = highlightLabel());
    }

    public void show(TreePath treePath) {
       
        CodeAttribute attribute = (CodeAttribute)findAttribute(treePath);

        lblMaxStack.setText(attribute.getMaxStack());
        lblMaxLocals.setText(attribute.getMaxLocals());
        lblCodeLength.setText(attribute.getCode().length);
       
        super.show(treePath);
    }
View Full Code Here

        this.instructions.setModel(new DefaultComboBoxModel(mnemonics.toArray()));
    }
   
    public void show(TreePath treePath) {
       
        CodeAttribute attribute = (CodeAttribute)findAttribute(treePath);
        if (byteCodeDisplay.getCodeAttribute() != attribute) {
           
            BrowserComponent browserComponent = services.getBrowserComponent();
            browserComponent.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
            byteCodeDisplay.setCodeAttribute(attribute, services.getClassFile());
View Full Code Here

                           lblCodeLength = highlightLabel());
    }

    public void show(TreePath treePath) {
       
        CodeAttribute attribute = (CodeAttribute)findAttribute(treePath);

        lblMaxStack.setText(attribute.getMaxStack());
        lblMaxLocals.setText(attribute.getMaxLocals());
        lblCodeLength.setText(attribute.getCode().length);
       
        super.show(treePath);
    }
View Full Code Here

        this.instructions.setModel(new DefaultComboBoxModel(mnemonics.toArray()));
    }
   
    public void show(TreePath treePath) {
       
        CodeAttribute attribute = (CodeAttribute)findAttribute(treePath);
        if (byteCodeDisplay.getCodeAttribute() != attribute) {
           
            BrowserComponent browserComponent = services.getBrowserComponent();
            browserComponent.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
            try {
View Full Code Here

TOP

Related Classes of org.gjt.jclasslib.structures.attributes.CodeAttribute

Copyright © 2018 www.massapicom. 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.