Java Code Examples for com.sun.java.util.jar.pack.Package.Class#Method

The following examples show how to use com.sun.java.util.jar.pack.Package.Class#Method . 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: PackageWriter.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
void writeMembers(Class cls) throws IOException {
    List<Class.Field> fields = cls.getFields();
    class_field_count.putInt(fields.size());
    for (Class.Field f : fields) {
        field_descr.putRef(f.getDescriptor());
        writeAttrs(ATTR_CONTEXT_FIELD, f, cls);
    }

    List<Class.Method> methods = cls.getMethods();
    class_method_count.putInt(methods.size());
    for (Class.Method m : methods) {
        method_descr.putRef(m.getDescriptor());
        writeAttrs(ATTR_CONTEXT_METHOD, m, cls);
        assert((m.code != null) == (m.getAttribute(attrCodeEmpty) != null));
        if (m.code != null) {
            writeCodeHeader(m.code);
            writeByteCodes(m.code);
        }
    }
}
 
Example 2
Source File: PackageWriter.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
void writeMembers(Class cls) throws IOException {
    List<Class.Field> fields = cls.getFields();
    class_field_count.putInt(fields.size());
    for (Class.Field f : fields) {
        field_descr.putRef(f.getDescriptor());
        writeAttrs(ATTR_CONTEXT_FIELD, f, cls);
    }

    List<Class.Method> methods = cls.getMethods();
    class_method_count.putInt(methods.size());
    for (Class.Method m : methods) {
        method_descr.putRef(m.getDescriptor());
        writeAttrs(ATTR_CONTEXT_METHOD, m, cls);
        assert((m.code != null) == (m.getAttribute(attrCodeEmpty) != null));
        if (m.code != null) {
            writeCodeHeader(m.code);
            writeByteCodes(m.code);
        }
    }
}
 
Example 3
Source File: PackageWriter.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
void writeMembers(Class cls) throws IOException {
    List<Class.Field> fields = cls.getFields();
    class_field_count.putInt(fields.size());
    for (Class.Field f : fields) {
        field_descr.putRef(f.getDescriptor());
        writeAttrs(ATTR_CONTEXT_FIELD, f, cls);
    }

    List<Class.Method> methods = cls.getMethods();
    class_method_count.putInt(methods.size());
    for (Class.Method m : methods) {
        method_descr.putRef(m.getDescriptor());
        writeAttrs(ATTR_CONTEXT_METHOD, m, cls);
        assert((m.code != null) == (m.getAttribute(attrCodeEmpty) != null));
        if (m.code != null) {
            writeCodeHeader(m.code);
            writeByteCodes(m.code);
        }
    }
}
 
Example 4
Source File: PackageReader.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
Code[] buildCodeAttrs(List<Class.Method> methods) {
    List<Code> codes = new ArrayList<>(methods.size());
    for (Class.Method m : methods) {
        if (m.getAttribute(attrCodeEmpty) != null) {
            m.code = new Code(m);
            codes.add(m.code);
        }
    }
    Code[] a = new Code[codes.size()];
    codes.toArray(a);
    return a;
}
 
Example 5
Source File: PackageReader.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
Code[] buildCodeAttrs(List<Class.Method> methods) {
    List<Code> codes = new ArrayList<>(methods.size());
    for (Class.Method m : methods) {
        if (m.getAttribute(attrCodeEmpty) != null) {
            m.code = new Code(m);
            codes.add(m.code);
        }
    }
    Code[] a = new Code[codes.size()];
    codes.toArray(a);
    return a;
}
 
Example 6
Source File: PackageReader.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
Code[] buildCodeAttrs(List<Class.Method> methods) {
    List<Code> codes = new ArrayList<>(methods.size());
    for (Class.Method m : methods) {
        if (m.getAttribute(attrCodeEmpty) != null) {
            m.code = new Code(m);
            codes.add(m.code);
        }
    }
    Code[] a = new Code[codes.size()];
    codes.toArray(a);
    return a;
}
 
Example 7
Source File: PackageReader.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
Code[] buildCodeAttrs(List<Class.Method> methods) {
    List<Code> codes = new ArrayList<>(methods.size());
    for (Class.Method m : methods) {
        if (m.getAttribute(attrCodeEmpty) != null) {
            m.code = new Code(m);
            codes.add(m.code);
        }
    }
    Code[] a = new Code[codes.size()];
    codes.toArray(a);
    return a;
}
 
Example 8
Source File: ClassWriter.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
void writeAttributes(int ctype, Attribute.Holder h) throws IOException {
    if (h.attributes == null) {
        writeShort(0);  // attribute size
        return;
    }
    // there may be cases if an InnerClass attribute is explicit, then the
    // ordering could be wrong, fix the ordering before we write it out.
    if (h instanceof Package.Class)
        reorderBSMandICS(h);

    writeShort(h.attributes.size());
    for (Attribute a : h.attributes) {
        a.finishRefs(cpIndex);
        writeRef(a.getNameRef());
        if (a.layout() == Package.attrCodeEmpty ||
            a.layout() == Package.attrBootstrapMethodsEmpty ||
            a.layout() == Package.attrInnerClassesEmpty) {
            // These are hardwired.
            DataOutputStream savedOut = out;
            assert(out != bufOut);
            buf.reset();
            out = bufOut;
            if ("Code".equals(a.name())) {
                Class.Method m = (Class.Method) h;
                writeCode(m.code);
            } else if ("BootstrapMethods".equals(a.name())) {
                assert(h == cls);
                writeBootstrapMethods(cls);
            } else if ("InnerClasses".equals(a.name())) {
                assert(h == cls);
                writeInnerClasses(cls);
            } else {
                throw new AssertionError();
            }
            out = savedOut;
            if (verbose > 2)
                Utils.log.fine("Attribute "+a.name()+" ["+buf.size()+"]");
            writeInt(buf.size());
            buf.writeTo(out);
        } else {
            if (verbose > 2)
                Utils.log.fine("Attribute "+a.name()+" ["+a.size()+"]");
            writeInt(a.size());
            out.write(a.bytes());
        }
    }
}
 
Example 9
Source File: Code.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
public Class.Method getMethod() {
    return m;
}
 
Example 10
Source File: Code.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public Class.Method getMethod() {
    return m;
}
 
Example 11
Source File: ClassWriter.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
void writeAttributes(int ctype, Attribute.Holder h) throws IOException {
    if (h.attributes == null) {
        writeShort(0);  // attribute size
        return;
    }
    // there may be cases if an InnerClass attribute is explicit, then the
    // ordering could be wrong, fix the ordering before we write it out.
    if (h instanceof Package.Class)
        reorderBSMandICS(h);

    writeShort(h.attributes.size());
    for (Attribute a : h.attributes) {
        a.finishRefs(cpIndex);
        writeRef(a.getNameRef());
        if (a.layout() == Package.attrCodeEmpty ||
            a.layout() == Package.attrBootstrapMethodsEmpty ||
            a.layout() == Package.attrInnerClassesEmpty) {
            // These are hardwired.
            DataOutputStream savedOut = out;
            assert(out != bufOut);
            buf.reset();
            out = bufOut;
            if ("Code".equals(a.name())) {
                Class.Method m = (Class.Method) h;
                writeCode(m.code);
            } else if ("BootstrapMethods".equals(a.name())) {
                assert(h == cls);
                writeBootstrapMethods(cls);
            } else if ("InnerClasses".equals(a.name())) {
                assert(h == cls);
                writeInnerClasses(cls);
            } else {
                throw new AssertionError();
            }
            out = savedOut;
            if (verbose > 2)
                Utils.log.fine("Attribute "+a.name()+" ["+buf.size()+"]");
            writeInt(buf.size());
            buf.writeTo(out);
        } else {
            if (verbose > 2)
                Utils.log.fine("Attribute "+a.name()+" ["+a.size()+"]");
            writeInt(a.size());
            out.write(a.bytes());
        }
    }
}
 
Example 12
Source File: Code.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public Code(Class.Method m) {
    this.m = m;
}
 
Example 13
Source File: ClassWriter.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
void writeAttributes(int ctype, Attribute.Holder h) throws IOException {
    if (h.attributes == null) {
        writeShort(0);  // attribute size
        return;
    }
    // there may be cases if an InnerClass attribute is explicit, then the
    // ordering could be wrong, fix the ordering before we write it out.
    if (h instanceof Package.Class)
        reorderBSMandICS(h);

    writeShort(h.attributes.size());
    for (Attribute a : h.attributes) {
        a.finishRefs(cpIndex);
        writeRef(a.getNameRef());
        if (a.layout() == Package.attrCodeEmpty ||
            a.layout() == Package.attrBootstrapMethodsEmpty ||
            a.layout() == Package.attrInnerClassesEmpty) {
            // These are hardwired.
            DataOutputStream savedOut = out;
            assert(out != bufOut);
            buf.reset();
            out = bufOut;
            if ("Code".equals(a.name())) {
                Class.Method m = (Class.Method) h;
                writeCode(m.code);
            } else if ("BootstrapMethods".equals(a.name())) {
                assert(h == cls);
                writeBootstrapMethods(cls);
            } else if ("InnerClasses".equals(a.name())) {
                assert(h == cls);
                writeInnerClasses(cls);
            } else {
                throw new AssertionError();
            }
            out = savedOut;
            if (verbose > 2)
                Utils.log.fine("Attribute "+a.name()+" ["+buf.size()+"]");
            writeInt(buf.size());
            buf.writeTo(out);
        } else {
            if (verbose > 2)
                Utils.log.fine("Attribute "+a.name()+" ["+a.size()+"]");
            writeInt(a.size());
            out.write(a.bytes());
        }
    }
}
 
Example 14
Source File: ClassWriter.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
void writeAttributes(int ctype, Attribute.Holder h) throws IOException {
    if (h.attributes == null) {
        writeShort(0);  // attribute size
        return;
    }
    // there may be cases if an InnerClass attribute is explicit, then the
    // ordering could be wrong, fix the ordering before we write it out.
    if (h instanceof Package.Class)
        reorderBSMandICS(h);

    writeShort(h.attributes.size());
    for (Attribute a : h.attributes) {
        a.finishRefs(cpIndex);
        writeRef(a.getNameRef());
        if (a.layout() == Package.attrCodeEmpty ||
            a.layout() == Package.attrBootstrapMethodsEmpty ||
            a.layout() == Package.attrInnerClassesEmpty) {
            // These are hardwired.
            DataOutputStream savedOut = out;
            assert(out != bufOut);
            buf.reset();
            out = bufOut;
            if ("Code".equals(a.name())) {
                Class.Method m = (Class.Method) h;
                writeCode(m.code);
            } else if ("BootstrapMethods".equals(a.name())) {
                assert(h == cls);
                writeBootstrapMethods(cls);
            } else if ("InnerClasses".equals(a.name())) {
                assert(h == cls);
                writeInnerClasses(cls);
            } else {
                throw new AssertionError();
            }
            out = savedOut;
            if (verbose > 2)
                Utils.log.fine("Attribute "+a.name()+" ["+buf.size()+"]");
            writeInt(buf.size());
            buf.writeTo(out);
        } else {
            if (verbose > 2)
                Utils.log.fine("Attribute "+a.name()+" ["+a.size()+"]");
            writeInt(a.size());
            out.write(a.bytes());
        }
    }
}
 
Example 15
Source File: Code.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
public Class.Method getMethod() {
    return m;
}
 
Example 16
Source File: ClassWriter.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
void writeAttributes(int ctype, Attribute.Holder h) throws IOException {
    if (h.attributes == null) {
        writeShort(0);  // attribute size
        return;
    }
    // there may be cases if an InnerClass attribute is explicit, then the
    // ordering could be wrong, fix the ordering before we write it out.
    if (h instanceof Package.Class)
        reorderBSMandICS(h);

    writeShort(h.attributes.size());
    for (Attribute a : h.attributes) {
        a.finishRefs(cpIndex);
        writeRef(a.getNameRef());
        if (a.layout() == Package.attrCodeEmpty ||
            a.layout() == Package.attrBootstrapMethodsEmpty ||
            a.layout() == Package.attrInnerClassesEmpty) {
            // These are hardwired.
            DataOutputStream savedOut = out;
            assert(out != bufOut);
            buf.reset();
            out = bufOut;
            if ("Code".equals(a.name())) {
                Class.Method m = (Class.Method) h;
                writeCode(m.code);
            } else if ("BootstrapMethods".equals(a.name())) {
                assert(h == cls);
                writeBootstrapMethods(cls);
            } else if ("InnerClasses".equals(a.name())) {
                assert(h == cls);
                writeInnerClasses(cls);
            } else {
                throw new AssertionError();
            }
            out = savedOut;
            if (verbose > 2)
                Utils.log.fine("Attribute "+a.name()+" ["+buf.size()+"]");
            writeInt(buf.size());
            buf.writeTo(out);
        } else {
            if (verbose > 2)
                Utils.log.fine("Attribute "+a.name()+" ["+a.size()+"]");
            writeInt(a.size());
            out.write(a.bytes());
        }
    }
}
 
Example 17
Source File: ClassWriter.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
void writeAttributes(int ctype, Attribute.Holder h) throws IOException {
    if (h.attributes == null) {
        writeShort(0);  // attribute size
        return;
    }
    // there may be cases if an InnerClass attribute is explicit, then the
    // ordering could be wrong, fix the ordering before we write it out.
    if (h instanceof Package.Class)
        reorderBSMandICS(h);

    writeShort(h.attributes.size());
    for (Attribute a : h.attributes) {
        a.finishRefs(cpIndex);
        writeRef(a.getNameRef());
        if (a.layout() == Package.attrCodeEmpty ||
            a.layout() == Package.attrBootstrapMethodsEmpty ||
            a.layout() == Package.attrInnerClassesEmpty) {
            // These are hardwired.
            DataOutputStream savedOut = out;
            assert(out != bufOut);
            buf.reset();
            out = bufOut;
            if ("Code".equals(a.name())) {
                Class.Method m = (Class.Method) h;
                writeCode(m.code);
            } else if ("BootstrapMethods".equals(a.name())) {
                assert(h == cls);
                writeBootstrapMethods(cls);
            } else if ("InnerClasses".equals(a.name())) {
                assert(h == cls);
                writeInnerClasses(cls);
            } else {
                throw new AssertionError();
            }
            out = savedOut;
            if (verbose > 2)
                Utils.log.fine("Attribute "+a.name()+" ["+buf.size()+"]");
            writeInt(buf.size());
            buf.writeTo(out);
        } else {
            if (verbose > 2)
                Utils.log.fine("Attribute "+a.name()+" ["+a.size()+"]");
            writeInt(a.size());
            out.write(a.bytes());
        }
    }
}
 
Example 18
Source File: ClassWriter.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
void writeAttributes(int ctype, Attribute.Holder h) throws IOException {
    if (h.attributes == null) {
        writeShort(0);  // attribute size
        return;
    }
    // there may be cases if an InnerClass attribute is explicit, then the
    // ordering could be wrong, fix the ordering before we write it out.
    if (h instanceof Package.Class)
        reorderBSMandICS(h);

    writeShort(h.attributes.size());
    for (Attribute a : h.attributes) {
        a.finishRefs(cpIndex);
        writeRef(a.getNameRef());
        if (a.layout() == Package.attrCodeEmpty ||
            a.layout() == Package.attrBootstrapMethodsEmpty ||
            a.layout() == Package.attrInnerClassesEmpty) {
            // These are hardwired.
            DataOutputStream savedOut = out;
            assert(out != bufOut);
            buf.reset();
            out = bufOut;
            if ("Code".equals(a.name())) {
                Class.Method m = (Class.Method) h;
                writeCode(m.code);
            } else if ("BootstrapMethods".equals(a.name())) {
                assert(h == cls);
                writeBootstrapMethods(cls);
            } else if ("InnerClasses".equals(a.name())) {
                assert(h == cls);
                writeInnerClasses(cls);
            } else {
                throw new AssertionError();
            }
            out = savedOut;
            if (verbose > 2)
                Utils.log.fine("Attribute "+a.name()+" ["+buf.size()+"]");
            writeInt(buf.size());
            buf.writeTo(out);
        } else {
            if (verbose > 2)
                Utils.log.fine("Attribute "+a.name()+" ["+a.size()+"]");
            writeInt(a.size());
            out.write(a.bytes());
        }
    }
}
 
Example 19
Source File: Code.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
public Code(Class.Method m) {
    this.m = m;
}
 
Example 20
Source File: Code.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
public Code(Class.Method m) {
    this.m = m;
}