Package com.sun.java.util.jar.pack.Package

Examples of com.sun.java.util.jar.pack.Package.Class


            for (int j = 0; j < interfaces.length; j++) {
                interfaces[j] = (ClassEntry) class_interface.getRef();
            }
            // Packer encoded rare case of null superClass as thisClass:
            if (superClass == thisClasssuperClass = null;
            Class cls = pkg.new Class(NO_FLAGS_YET,
                                      thisClass, superClass, interfaces);
            classes[i] = cls;
        }
        class_this.doneDisbursing();
        class_super.doneDisbursing();
View Full Code Here


        if (verbose > 1Utils.log.fine("expecting #fields="+totalNF+" and #methods="+totalNM+" in #classes="+numClasses);

        ArrayList fields = new ArrayList(totalNF);
        field_descr.readFrom(in);
        for (int i = 0; i < classes.length; i++) {
            Class c = classes[i];
            int nf = class_field_count.getInt();
            for (int j = 0; j < nf; j++) {
                Class.Field f = c.new Field(NO_FLAGS_YET, (DescriptorEntry)
                                            field_descr.getRef());
                fields.add(f);
            }
        }
        class_field_count.doneDisbursing();
        field_descr.doneDisbursing();
        countAndReadAttrs(ATTR_CONTEXT_FIELD, fields);
        fields = null// release to GC

        ArrayList methods = new ArrayList(totalNM);
        method_descr.readFrom(in);
        for (int i = 0; i < classes.length; i++) {
            Class c = classes[i];
            int nm = class_method_count.getInt();
            for (int j = 0; j < nm; j++) {
                Class.Method m = c.new Method(NO_FLAGS_YET, (DescriptorEntry)
                                              method_descr.getRef());
                methods.add(m);
View Full Code Here

        for (int k = 0; k < allCodes.length; k++) {
            Code code = allCodes[k];
            byte[] codeOps = code.bytes;
            code.bytes = null// just for now, while we accumulate bits

            Class curClass = code.thisClass();

            HashSet ldcRefSet = (HashSet) ldcRefMap.get(curClass);
            if (ldcRefSet == null)
                ldcRefMap.put(curClass, ldcRefSet = new HashSet());
View Full Code Here

                toRead -= nr;
            }
            pkg.addFile(file);
            if (file.isClassStub()) {
                assert(file.getFileLength() == 0);
                Class cls = (Class) nextClass.next();
                cls.initFile(file);
            }
        }

        // Do the rest of the classes.
        while (nextClass.hasNext()) {
            Class cls = (Class) nextClass.next();
            cls.initFile(null)// implicitly initialize to a trivial one
            cls.file.modtime = pkg.default_modtime;
        }

        file_name.doneDisbursing();
        file_size_hi.doneDisbursing();
View Full Code Here

        // Decide on default version number (majority rule).
        HashMap verCounts = new HashMap();
        int bestCount = 0;
        int bestVersion = -1;
        for (Iterator i = pkg.classes.iterator(); i.hasNext(); ) {
            Class cls = (Class) i.next();
            int version = cls.getVersion();
            int[] var = (int[]) verCounts.get(new Integer(version));
            if (var == null) {
                var = new int[1];
                verCounts.put(new Integer(version), var);
            }
            int count = (var[0] += 1);
            //System.out.println("version="+version+" count="+count);
            if (bestCount < count) {
                bestCount = count;
                bestVersion = version;
            }
        }
        verCounts.clear();
        if (bestVersion == -1bestVersion = 0// degenerate case
        int bestMajver = (char)(bestVersion >>> 16);
        int bestMinver = (char)(bestVersion);
        pkg.default_class_majver = (short) bestMajver;
        pkg.default_class_minver = (short) bestMinver;
        String bestVerStr = Package.versionStringOf(bestMajver, bestMinver);
        if (verbose > 0)
           Utils.log.info("Consensus version number in segment is "+bestVerStr);
        if (verbose > 0)
            Utils.log.info("Highest version number in segment is "+
                           Package.versionStringOf(pkg.getHighestClassVersion()));

        // Now add explicit pseudo-attrs. to classes with odd versions.
        for (Iterator i = pkg.classes.iterator(); i.hasNext(); ) {
            Class cls = (Class) i.next();

            if (cls.getVersion() != bestVersion) {
                Attribute a = makeClassFileVersionAttr(cls.minver, cls.majver);
                if (verbose > 1) {
                    String clsVer = cls.getVersionString();
                    String pkgVer = bestVerStr;
                    Utils.log.fine("Version "+clsVer+" of "+cls
                                     +" doesn't match package version "
                                     +pkgVer);
                }
                // Note:  Does not add in "natural" order.  (Who cares?)
                cls.addAttribute(a);
            }
        }

        // Decide if we are transmitting a huge resource file:
        for (Iterator i = pkg.files.iterator(); i.hasNext(); ) {
            File file = (File) i.next();
            long len = file.getFileLength();
            if (len != (int)len) {
                archiveOptions |= AO_HAVE_FILE_SIZE_HI;
                if (verbose > 0)
                   Utils.log.info("Note: Huge resource file "+file.getFileName()+" forces 64-bit sizing");
                break;
            }
        }

        // Decide if code attributes typically have sub-attributes.
        // In that case, to preserve compact 1-byte code headers,
        // we must declare unconditional presence of code flags.
        int cost0 = 0;
        int cost1 = 0;
        for (Iterator i = pkg.classes.iterator(); i.hasNext(); ) {
            Class cls = (Class) i.next();
            for (Iterator j = cls.getMethods().iterator(); j.hasNext(); ) {
                Class.Method m = (Class.Method) j.next();
                if (m.code != null) {
                    if (m.code.attributeSize() == 0) {
                        // cost of a useless unconditional flags byte
                        cost1 += 1;
View Full Code Here

        for (int i = 0; i < ATTR_CONTEXT_LIMIT; i++) {
            allLayouts[i] = new HashMap();
        }
        // Collect maxFlags and allLayouts.
        for (Iterator i = pkg.classes.iterator(); i.hasNext(); ) {
            Class cls = (Class) i.next();
            visitAttributeLayoutsIn(ATTR_CONTEXT_CLASS, cls);
            for (Iterator j = cls.getFields().iterator(); j.hasNext(); ) {
                Class.Field f = (Class.Field) j.next();
                visitAttributeLayoutsIn(ATTR_CONTEXT_FIELD, f);
            }
            for (Iterator j = cls.getMethods().iterator(); j.hasNext(); ) {
                Class.Method m = (Class.Method) j.next();
                visitAttributeLayoutsIn(ATTR_CONTEXT_METHOD, m);
                if (m.code != null) {
                    visitAttributeLayoutsIn(ATTR_CONTEXT_CODE, m.code);
                }
View Full Code Here

        }
    }

    void trimClassAttributes() {
        for (Iterator i = pkg.classes.iterator(); i.hasNext(); ) {
            Class cls = (Class) i.next();
            // Replace "obvious" SourceFile attrs by null.
            cls.minimizeSourceFile();
        }
    }
View Full Code Here

        // Capture inner classes, removing them from individual classes.
        // Irregular inner classes must stay local, though.
        HashMap allICMap = new HashMap();
        // First, collect a consistent global set.
        for (Iterator i = pkg.classes.iterator(); i.hasNext(); ) {
            Class cls = (Class) i.next();
            if (!cls.hasInnerClasses())  continue;
            for (Iterator j = cls.getInnerClasses().iterator(); j.hasNext(); ) {
                InnerClass ic = (InnerClass) j.next();
                InnerClass pic = (InnerClass) allICMap.put(ic.thisClass, ic);
                if (pic != null && !pic.equals(ic) && pic.predictable) {
                    // Different ICs.  Choose the better to make global.
                    allICMap.put(pic.thisClass, pic);
                }
            }
        }

        InnerClass[] allICs = new InnerClass[allICMap.size()];
        allICMap.values().toArray(allICs);
        allICMap = null// done with it

        // Note: The InnerClasses attribute must be in a valid order,
        // so that A$B always occurs earlier than A$B$C.  This is an
        // important side-effect of sorting lexically by class name.
        Arrays.sort(allICs)// put in canonical order
        pkg.setAllInnerClasses(Arrays.asList(allICs));

        // Next, empty out of every local set the consistent entries.
        // Calculate whether there is any remaining need to have a local
        // set, and whether it needs to be locked.
        for (Iterator i = pkg.classes.iterator(); i.hasNext(); ) {
            Class cls = (Class) i.next();
            cls.minimizeLocalICs();
        }
    }
View Full Code Here

            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;
View Full Code Here

    protected void visitRefs(int mode, Collection refs) {
        int verbose = getPackage().verbose;
        if (verbose > 2)
            System.out.println("Reference scan "+this);
        Class cls = thisClass();
        Package pkg = cls.getPackage();
        for (int i = 0; i < handler_class.length; i++) {
            refs.add(handler_class[i]);
        }
        if (fixups != null) {
            fixups.visitRefs(refs);
View Full Code Here

TOP

Related Classes of com.sun.java.util.jar.pack.Package.Class

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.