com.sun.java.util.jar.pack.Package.Class Java Examples
The following examples show how to use
com.sun.java.util.jar.pack.Package.Class.
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-8 with GNU General Public License v2.0 | 6 votes |
/** If there are any extra InnerClasses entries to write which are * not already implied by the global table, put them into a * local attribute. This is expected to be rare. */ void writeLocalInnerClasses(Class cls) throws IOException { List<InnerClass> localICs = cls.getInnerClasses(); class_InnerClasses_N.putInt(localICs.size()); for(InnerClass ic : localICs) { class_InnerClasses_RC.putRef(ic.thisClass); // Is it redundant with the global version? if (ic.equals(pkg.getGlobalInnerClass(ic.thisClass))) { // A zero flag means copy a global IC here. class_InnerClasses_F.putInt(0); } else { int flags = ic.flags; if (flags == 0) flags = ACC_IC_LONG_FORM; // force it to be non-zero class_InnerClasses_F.putInt(flags); class_InnerClasses_outer_RCN.putRef(ic.outerClass); class_InnerClasses_name_RUN.putRef(ic.name); } } }
Example #2
Source File: PackageReader.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
void reconstructClass(Class cls) { if (verbose > 1) Utils.log.fine("reconstruct "+cls); // check for local .ClassFile.version Attribute retroVersion = cls.getAttribute(attrClassFileVersion); if (retroVersion != null) { cls.removeAttribute(retroVersion); cls.version = parseClassFileVersionAttr(retroVersion); } else { cls.version = pkg.defaultClassVersion; } // Replace null SourceFile by "obvious" string. cls.expandSourceFile(); // record the local cp: cls.setCPMap(reconstructLocalCPMap(cls)); }
Example #3
Source File: PackageReader.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
void readLocalInnerClasses(Class cls) throws IOException { int nc = class_InnerClasses_N.getInt(); List<InnerClass> localICs = new ArrayList<>(nc); for (int i = 0; i < nc; i++) { ClassEntry thisClass = (ClassEntry) class_InnerClasses_RC.getRef(); int flags = class_InnerClasses_F.getInt(); if (flags == 0) { // A zero flag means copy a global IC here. InnerClass ic = pkg.getGlobalInnerClass(thisClass); assert(ic != null); // must be a valid global IC reference localICs.add(ic); } else { if (flags == ACC_IC_LONG_FORM) flags = 0; // clear the marker bit ClassEntry outer = (ClassEntry) class_InnerClasses_outer_RCN.getRef(); Utf8Entry name = (Utf8Entry) class_InnerClasses_name_RUN.getRef(); localICs.add(new InnerClass(thisClass, outer, name, flags)); } } cls.setInnerClasses(localICs); // cls.expandLocalICs may add more tuples to ics also, // or may even delete tuples. // We cannot do that now, because we do not know the // full contents of the local constant pool yet. }
Example #4
Source File: ClassReader.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
ClassReader(Class cls, InputStream in) throws IOException { this.pkg = cls.getPackage(); this.cls = cls; this.verbose = pkg.verbose; this.in = new DataInputStream(new FilterInputStream(in) { public int read(byte b[], int off, int len) throws IOException { int nr = super.read(b, off, len); if (nr >= 0) inPos += nr; return nr; } public int read() throws IOException { int ch = super.read(); if (ch >= 0) inPos += 1; return ch; } public long skip(long n) throws IOException { long ns = super.skip(n); if (ns >= 0) inPos += ns; return ns; } }); }
Example #5
Source File: PackageWriter.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
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 #6
Source File: PackageWriter.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** If there are any extra InnerClasses entries to write which are * not already implied by the global table, put them into a * local attribute. This is expected to be rare. */ void writeLocalInnerClasses(Class cls) throws IOException { List<InnerClass> localICs = cls.getInnerClasses(); class_InnerClasses_N.putInt(localICs.size()); for(InnerClass ic : localICs) { class_InnerClasses_RC.putRef(ic.thisClass); // Is it redundant with the global version? if (ic.equals(pkg.getGlobalInnerClass(ic.thisClass))) { // A zero flag means copy a global IC here. class_InnerClasses_F.putInt(0); } else { int flags = ic.flags; if (flags == 0) flags = ACC_IC_LONG_FORM; // force it to be non-zero class_InnerClasses_F.putInt(flags); class_InnerClasses_outer_RCN.putRef(ic.outerClass); class_InnerClasses_name_RUN.putRef(ic.name); } } }
Example #7
Source File: PackageReader.java From hottub with GNU General Public License v2.0 | 6 votes |
void readLocalInnerClasses(Class cls) throws IOException { int nc = class_InnerClasses_N.getInt(); List<InnerClass> localICs = new ArrayList<>(nc); for (int i = 0; i < nc; i++) { ClassEntry thisClass = (ClassEntry) class_InnerClasses_RC.getRef(); int flags = class_InnerClasses_F.getInt(); if (flags == 0) { // A zero flag means copy a global IC here. InnerClass ic = pkg.getGlobalInnerClass(thisClass); assert(ic != null); // must be a valid global IC reference localICs.add(ic); } else { if (flags == ACC_IC_LONG_FORM) flags = 0; // clear the marker bit ClassEntry outer = (ClassEntry) class_InnerClasses_outer_RCN.getRef(); Utf8Entry name = (Utf8Entry) class_InnerClasses_name_RUN.getRef(); localICs.add(new InnerClass(thisClass, outer, name, flags)); } } cls.setInnerClasses(localICs); // cls.expandLocalICs may add more tuples to ics also, // or may even delete tuples. // We cannot do that now, because we do not know the // full contents of the local constant pool yet. }
Example #8
Source File: PackageWriter.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
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 #9
Source File: PackageReader.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
void readLocalInnerClasses(Class cls) throws IOException { int nc = class_InnerClasses_N.getInt(); List<InnerClass> localICs = new ArrayList<>(nc); for (int i = 0; i < nc; i++) { ClassEntry thisClass = (ClassEntry) class_InnerClasses_RC.getRef(); int flags = class_InnerClasses_F.getInt(); if (flags == 0) { // A zero flag means copy a global IC here. InnerClass ic = pkg.getGlobalInnerClass(thisClass); assert(ic != null); // must be a valid global IC reference localICs.add(ic); } else { if (flags == ACC_IC_LONG_FORM) flags = 0; // clear the marker bit ClassEntry outer = (ClassEntry) class_InnerClasses_outer_RCN.getRef(); Utf8Entry name = (Utf8Entry) class_InnerClasses_name_RUN.getRef(); localICs.add(new InnerClass(thisClass, outer, name, flags)); } } cls.setInnerClasses(localICs); // cls.expandLocalICs may add more tuples to ics also, // or may even delete tuples. // We cannot do that now, because we do not know the // full contents of the local constant pool yet. }
Example #10
Source File: PackageReader.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
void reconstructClass(Class cls) { if (verbose > 1) Utils.log.fine("reconstruct "+cls); // check for local .ClassFile.version Attribute retroVersion = cls.getAttribute(attrClassFileVersion); if (retroVersion != null) { cls.removeAttribute(retroVersion); cls.version = parseClassFileVersionAttr(retroVersion); } else { cls.version = pkg.defaultClassVersion; } // Replace null SourceFile by "obvious" string. cls.expandSourceFile(); // record the local cp: cls.setCPMap(reconstructLocalCPMap(cls)); }
Example #11
Source File: ClassReader.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
ClassReader(Class cls, InputStream in) throws IOException { this.pkg = cls.getPackage(); this.cls = cls; this.verbose = pkg.verbose; this.in = new DataInputStream(new FilterInputStream(in) { public int read(byte b[], int off, int len) throws IOException { int nr = super.read(b, off, len); if (nr >= 0) inPos += nr; return nr; } public int read() throws IOException { int ch = super.read(); if (ch >= 0) inPos += 1; return ch; } public long skip(long n) throws IOException { long ns = super.skip(n); if (ns >= 0) inPos += ns; return ns; } }); }
Example #12
Source File: PackageReader.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
void readLocalInnerClasses(Class cls) throws IOException { int nc = class_InnerClasses_N.getInt(); List<InnerClass> localICs = new ArrayList<>(nc); for (int i = 0; i < nc; i++) { ClassEntry thisClass = (ClassEntry) class_InnerClasses_RC.getRef(); int flags = class_InnerClasses_F.getInt(); if (flags == 0) { // A zero flag means copy a global IC here. InnerClass ic = pkg.getGlobalInnerClass(thisClass); assert(ic != null); // must be a valid global IC reference localICs.add(ic); } else { if (flags == ACC_IC_LONG_FORM) flags = 0; // clear the marker bit ClassEntry outer = (ClassEntry) class_InnerClasses_outer_RCN.getRef(); Utf8Entry name = (Utf8Entry) class_InnerClasses_name_RUN.getRef(); localICs.add(new InnerClass(thisClass, outer, name, flags)); } } cls.setInnerClasses(localICs); // cls.expandLocalICs may add more tuples to ics also, // or may even delete tuples. // We cannot do that now, because we do not know the // full contents of the local constant pool yet. }
Example #13
Source File: PackageWriter.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
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 #14
Source File: ClassReader.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
ClassReader(Class cls, InputStream in) throws IOException { this.pkg = cls.getPackage(); this.cls = cls; this.verbose = pkg.verbose; this.in = new DataInputStream(new FilterInputStream(in) { public int read(byte b[], int off, int len) throws IOException { int nr = super.read(b, off, len); if (nr >= 0) inPos += nr; return nr; } public int read() throws IOException { int ch = super.read(); if (ch >= 0) inPos += 1; return ch; } public long skip(long n) throws IOException { long ns = super.skip(n); if (ns >= 0) inPos += ns; return ns; } }); }
Example #15
Source File: ClassReader.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
ClassReader(Class cls, InputStream in) throws IOException { this.pkg = cls.getPackage(); this.cls = cls; this.verbose = pkg.verbose; this.in = new DataInputStream(new FilterInputStream(in) { public int read(byte b[], int off, int len) throws IOException { int nr = super.read(b, off, len); if (nr >= 0) inPos += nr; return nr; } public int read() throws IOException { int ch = super.read(); if (ch >= 0) inPos += 1; return ch; } public long skip(long n) throws IOException { long ns = super.skip(n); if (ns >= 0) inPos += ns; return ns; } }); }
Example #16
Source File: PackageWriter.java From hottub with GNU General Public License v2.0 | 6 votes |
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 #17
Source File: PackageReader.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
void reconstructClass(Class cls) { if (verbose > 1) Utils.log.fine("reconstruct "+cls); // check for local .ClassFile.version Attribute retroVersion = cls.getAttribute(attrClassFileVersion); if (retroVersion != null) { cls.removeAttribute(retroVersion); cls.version = parseClassFileVersionAttr(retroVersion); } else { cls.version = pkg.defaultClassVersion; } // Replace null SourceFile by "obvious" string. cls.expandSourceFile(); // record the local cp: cls.setCPMap(reconstructLocalCPMap(cls)); }
Example #18
Source File: PackageWriter.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
/** If there are any extra InnerClasses entries to write which are * not already implied by the global table, put them into a * local attribute. This is expected to be rare. */ void writeLocalInnerClasses(Class cls) throws IOException { List<InnerClass> localICs = cls.getInnerClasses(); class_InnerClasses_N.putInt(localICs.size()); for(InnerClass ic : localICs) { class_InnerClasses_RC.putRef(ic.thisClass); // Is it redundant with the global version? if (ic.equals(pkg.getGlobalInnerClass(ic.thisClass))) { // A zero flag means copy a global IC here. class_InnerClasses_F.putInt(0); } else { int flags = ic.flags; if (flags == 0) flags = ACC_IC_LONG_FORM; // force it to be non-zero class_InnerClasses_F.putInt(flags); class_InnerClasses_outer_RCN.putRef(ic.outerClass); class_InnerClasses_name_RUN.putRef(ic.name); } } }
Example #19
Source File: PackageReader.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
void readLocalInnerClasses(Class cls) throws IOException { int nc = class_InnerClasses_N.getInt(); List<InnerClass> localICs = new ArrayList<>(nc); for (int i = 0; i < nc; i++) { ClassEntry thisClass = (ClassEntry) class_InnerClasses_RC.getRef(); int flags = class_InnerClasses_F.getInt(); if (flags == 0) { // A zero flag means copy a global IC here. InnerClass ic = pkg.getGlobalInnerClass(thisClass); assert(ic != null); // must be a valid global IC reference localICs.add(ic); } else { if (flags == ACC_IC_LONG_FORM) flags = 0; // clear the marker bit ClassEntry outer = (ClassEntry) class_InnerClasses_outer_RCN.getRef(); Utf8Entry name = (Utf8Entry) class_InnerClasses_name_RUN.getRef(); localICs.add(new InnerClass(thisClass, outer, name, flags)); } } cls.setInnerClasses(localICs); // cls.expandLocalICs may add more tuples to ics also, // or may even delete tuples. // We cannot do that now, because we do not know the // full contents of the local constant pool yet. }
Example #20
Source File: PackageReader.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
void reconstructClass(Class cls) { if (verbose > 1) Utils.log.fine("reconstruct "+cls); // check for local .ClassFile.version Attribute retroVersion = cls.getAttribute(attrClassFileVersion); if (retroVersion != null) { cls.removeAttribute(retroVersion); cls.version = parseClassFileVersionAttr(retroVersion); } else { cls.version = pkg.defaultClassVersion; } // Replace null SourceFile by "obvious" string. cls.expandSourceFile(); // record the local cp: cls.setCPMap(reconstructLocalCPMap(cls)); }
Example #21
Source File: ClassWriter.java From hottub with GNU General Public License v2.0 | 5 votes |
ClassWriter(Class cls, OutputStream out) throws IOException { this.pkg = cls.getPackage(); this.cls = cls; this.verbose = pkg.verbose; this.out = new DataOutputStream(new BufferedOutputStream(out)); this.cpIndex = ConstantPool.makeIndex(cls.toString(), cls.getCPMap()); this.cpIndex.flattenSigs = true; if (cls.hasBootstrapMethods()) { this.bsmIndex = ConstantPool.makeIndex(cpIndex.debugName+".BootstrapMethods", cls.getBootstrapMethodMap()); } if (verbose > 1) Utils.log.fine("local CP="+(verbose > 2 ? cpIndex.dumpString() : cpIndex.toString())); }
Example #22
Source File: PackageReader.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
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 #23
Source File: PackageWriter.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
void trimClassAttributes() { for (Class cls : pkg.classes) { // Replace "obvious" SourceFile attrs by null. cls.minimizeSourceFile(); // BootstrapMethods should never have been inserted. assert(cls.getAttribute(Package.attrBootstrapMethodsEmpty) == null); } }
Example #24
Source File: ClassWriter.java From hottub with GNU General Public License v2.0 | 5 votes |
void writeInnerClasses(Class cls) throws IOException { List<InnerClass> ics = cls.getInnerClasses(); writeShort(ics.size()); for (InnerClass ic : ics) { writeRef(ic.thisClass); writeRef(ic.outerClass); writeRef(ic.name); writeShort(ic.flags); } }
Example #25
Source File: PackageWriter.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
void writeClassesAndByteCodes() throws IOException { Class[] classes = new Class[pkg.classes.size()]; pkg.classes.toArray(classes); // Note: This code respects the order in which caller put classes. if (verbose > 0) Utils.log.info(" ...scanning "+classes.length+" classes..."); int nwritten = 0; for (int i = 0; i < classes.length; i++) { // Collect the class body, sans bytecodes. Class cls = classes[i]; if (verbose > 1) Utils.log.fine("Scanning "+cls); ClassEntry thisClass = cls.thisClass; ClassEntry superClass = cls.superClass; ClassEntry[] interfaces = cls.interfaces; // Encode rare case of null superClass as thisClass: assert(superClass != thisClass); // bad class file!? if (superClass == null) superClass = thisClass; class_this.putRef(thisClass); class_super.putRef(superClass); class_interface_count.putInt(cls.interfaces.length); for (int j = 0; j < interfaces.length; j++) { class_interface.putRef(interfaces[j]); } writeMembers(cls); writeAttrs(ATTR_CONTEXT_CLASS, cls, cls); nwritten++; if (verbose > 0 && (nwritten % 1000) == 0) Utils.log.info("Have scanned "+nwritten+" classes..."); } }
Example #26
Source File: ClassWriter.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
void writeInnerClasses(Class cls) throws IOException { List<InnerClass> ics = cls.getInnerClasses(); writeShort(ics.size()); for (InnerClass ic : ics) { writeRef(ic.thisClass); writeRef(ic.outerClass); writeRef(ic.name); writeShort(ic.flags); } }
Example #27
Source File: PackageReader.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
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 #28
Source File: ClassWriter.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
void writeBootstrapMethods(Class cls) throws IOException { List<BootstrapMethodEntry> bsms = cls.getBootstrapMethods(); writeShort(bsms.size()); for (BootstrapMethodEntry e : bsms) { writeRef(e.bsmRef); writeShort(e.argRefs.length); for (Entry argRef : e.argRefs) { writeRef(argRef); } } }
Example #29
Source File: ClassWriter.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
void writeInnerClasses(Class cls) throws IOException { List<InnerClass> ics = cls.getInnerClasses(); writeShort(ics.size()); for (InnerClass ic : ics) { writeRef(ic.thisClass); writeRef(ic.outerClass); writeRef(ic.name); writeShort(ic.flags); } }
Example #30
Source File: ClassReader.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
Entry resolve() { Class cls = ClassReader.this.cls; Entry res; switch (tag) { case CONSTANT_InvokeDynamic: BootstrapMethodEntry iboots = cls.bootstrapMethods.get((Integer) refsOrIndexes[0]); DescriptorEntry idescr = (DescriptorEntry) refsOrIndexes[1]; res = ConstantPool.getInvokeDynamicEntry(iboots, idescr); break; default: throw new AssertionError(); } return res; }