harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sjanu...@apache.org
Subject svn commit: r736640 - /harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/ClassBands.java
Date Thu, 22 Jan 2009 13:54:12 GMT
Author: sjanuary
Date: Thu Jan 22 05:54:11 2009
New Revision: 736640

URL: http://svn.apache.org/viewvc?rev=736640&view=rev
Log:
Unpack200 - bug fix to correct ordering of method and field attributes

Modified:
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/ClassBands.java

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/ClassBands.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/ClassBands.java?rev=736640&r1=736639&r2=736640&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/ClassBands.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/ClassBands.java
Thu Jan 22 05:54:11 2009
@@ -207,39 +207,6 @@
                 Codec.UNSIGNED5, signatureCount);
         int signatureIndex = 0;
 
-        int backwardsCallsUsed = parseFieldMetadataBands(in, fieldAttrCalls);
-
-        // Parse non-predefined attribute bands
-        int backwardsCallIndex = backwardsCallsUsed;
-        int limit = options.hasFieldFlagsHi() ? 62 : 31;
-        AttributeLayout[] otherLayouts = new AttributeLayout[limit + 1];
-        int[] counts = new int[limit + 1];
-        List[] otherAttributes = new List[limit + 1];
-        for (int i = 0; i < limit; i++) {
-            AttributeLayout layout = attrMap.getAttributeLayout(i,
-                    AttributeLayout.CONTEXT_FIELD);
-            if (layout != null && !(layout.isDefaultLayout())) {
-                otherLayouts[i] = layout;
-                counts[i] = SegmentUtils.countMatches(fieldFlags, layout);
-            }
-        }
-        for (int i = 0; i < counts.length; i++) {
-            if (counts[i] > 0) {
-                NewAttributeBands bands = attrMap
-                        .getAttributeBands(otherLayouts[i]);
-                otherAttributes[i] = bands.parseAttributes(in, counts[i]);
-                int numBackwardsCallables = otherLayouts[i]
-                        .numBackwardsCallables();
-                if (numBackwardsCallables > 0) {
-                    int[] backwardsCalls = new int[numBackwardsCallables];
-                    System.arraycopy(fieldAttrCalls, backwardsCallIndex,
-                            backwardsCalls, 0, numBackwardsCallables);
-                    bands.setBackwardsCalls(backwardsCalls);
-                    backwardsCallIndex += numBackwardsCallables;
-                }
-            }
-        }
-
         AttributeLayout deprecatedLayout = attrMap.getAttributeLayout(
                 AttributeLayout.ATTRIBUTE_DEPRECATED,
                 AttributeLayout.CONTEXT_FIELD);
@@ -276,12 +243,56 @@
                     fieldAttributes[i][j].add(new SignatureAttribute(value));
                     signatureIndex++;
                 }
-                // Non-predefined attributes
+            }
+        }
+
+        int backwardsCallsUsed = parseFieldMetadataBands(in, fieldAttrCalls);
+
+        // Parse non-predefined attribute bands
+        int backwardsCallIndex = backwardsCallsUsed;
+        int limit = options.hasFieldFlagsHi() ? 62 : 31;
+        AttributeLayout[] otherLayouts = new AttributeLayout[limit + 1];
+        int[] counts = new int[limit + 1];
+        List[] otherAttributes = new List[limit + 1];
+        for (int i = 0; i < limit; i++) {
+            AttributeLayout layout = attrMap.getAttributeLayout(i,
+                    AttributeLayout.CONTEXT_FIELD);
+            if (layout != null && !(layout.isDefaultLayout())) {
+                otherLayouts[i] = layout;
+                counts[i] = SegmentUtils.countMatches(fieldFlags, layout);
+            }
+        }
+        for (int i = 0; i < counts.length; i++) {
+            if (counts[i] > 0) {
+                NewAttributeBands bands = attrMap
+                        .getAttributeBands(otherLayouts[i]);
+                otherAttributes[i] = bands.parseAttributes(in, counts[i]);
+                int numBackwardsCallables = otherLayouts[i]
+                        .numBackwardsCallables();
+                if (numBackwardsCallables > 0) {
+                    int[] backwardsCalls = new int[numBackwardsCallables];
+                    System.arraycopy(fieldAttrCalls, backwardsCallIndex,
+                            backwardsCalls, 0, numBackwardsCallables);
+                    bands.setBackwardsCalls(backwardsCalls);
+                    backwardsCallIndex += numBackwardsCallables;
+                }
+            }
+        }
+
+        // Non-predefined attributes
+        for (int i = 0; i < classCount; i++) {
+            for (int j = 0; j < fieldFlags[i].length; j++) {
+                long flag = fieldFlags[i][j];
+                int othersAddedAtStart = 0;
                 for (int k = 0; k < otherLayouts.length; k++) {
                     if (otherLayouts[k] != null
                             && otherLayouts[k].matches(flag)) {
                         // Add the next attribute
-                        fieldAttributes[i][j].add(otherAttributes[k].get(0));
+                        if(otherLayouts[k].getIndex()<15) {
+                            fieldAttributes[i][j].add(othersAddedAtStart++, otherAttributes[k].get(0));
+                        } else {
+                            fieldAttributes[i][j].add(otherAttributes[k].get(0));
+                        }
                         otherAttributes[k].remove(0);
                     }
                 }
@@ -340,40 +351,6 @@
         long[] methodSignatureRS = decodeBandLong("method_signature_RS", in,
                 Codec.UNSIGNED5, count1);
 
-        // Parse method metadata bands
-        int backwardsCallsUsed = parseMethodMetadataBands(in, methodAttrCalls);
-
-        // Parse non-predefined attribute bands
-        int backwardsCallIndex = backwardsCallsUsed;
-        int limit = options.hasMethodFlagsHi() ? 62 : 31;
-        AttributeLayout[] otherLayouts = new AttributeLayout[limit + 1];
-        int[] counts = new int[limit + 1];
-        List[] otherAttributes = new List[limit + 1];
-        for (int i = 0; i < limit; i++) {
-            AttributeLayout layout = attrMap.getAttributeLayout(i,
-                    AttributeLayout.CONTEXT_METHOD);
-            if (layout != null && !(layout.isDefaultLayout())) {
-                otherLayouts[i] = layout;
-                counts[i] = SegmentUtils.countMatches(methodFlags, layout);
-            }
-        }
-        for (int i = 0; i < counts.length; i++) {
-            if (counts[i] > 0) {
-                NewAttributeBands bands = attrMap
-                        .getAttributeBands(otherLayouts[i]);
-                otherAttributes[i] = bands.parseAttributes(in, counts[i]);
-                int numBackwardsCallables = otherLayouts[i]
-                        .numBackwardsCallables();
-                if (numBackwardsCallables > 0) {
-                    int[] backwardsCalls = new int[numBackwardsCallables];
-                    System.arraycopy(methodAttrCalls, backwardsCallIndex,
-                            backwardsCalls, 0, numBackwardsCallables);
-                    bands.setBackwardsCalls(backwardsCalls);
-                    backwardsCallIndex += numBackwardsCallables;
-                }
-            }
-        }
-
         AttributeLayout deprecatedLayout = attrMap.getAttributeLayout(
                 AttributeLayout.ATTRIBUTE_DEPRECATED,
                 AttributeLayout.CONTEXT_METHOD);
@@ -384,16 +361,6 @@
         for (int i = 0; i < methodAttributes.length; i++) {
             for (int j = 0; j < methodAttributes[i].length; j++) {
                 long flag = methodFlags[i][j];
-             // Non-predefined attributes
-                for (int k = 0; k < otherLayouts.length; k++) {
-                    if (otherLayouts[k] != null
-                            && otherLayouts[k].matches(flag)
-                            && otherLayouts[k].getIndex() < 15) {
-                        // Add the next attribute
-                        methodAttributes[i][j].add(otherAttributes[k].get(0));
-                        otherAttributes[k].remove(0);
-                    }
-                }
                 if (methodExceptionsLayout.matches(flag)) {
                     int n = numExceptions[methodExceptionsIndex];
                     int[] exceptions = methodExceptionsRS[methodExceptionsIndex];
@@ -425,13 +392,57 @@
                 if (deprecatedLayout.matches(flag)) {
                     methodAttributes[i][j].add(new DeprecatedAttribute());
                 }
-                // Non-predefined attributes
+            }
+        }
+
+        // Parse method metadata bands
+        int backwardsCallsUsed = parseMethodMetadataBands(in, methodAttrCalls);
+
+        // Parse non-predefined attribute bands
+        int backwardsCallIndex = backwardsCallsUsed;
+        int limit = options.hasMethodFlagsHi() ? 62 : 31;
+        AttributeLayout[] otherLayouts = new AttributeLayout[limit + 1];
+        int[] counts = new int[limit + 1];
+        List[] otherAttributes = new List[limit + 1];
+        for (int i = 0; i < limit; i++) {
+            AttributeLayout layout = attrMap.getAttributeLayout(i,
+                    AttributeLayout.CONTEXT_METHOD);
+            if (layout != null && !(layout.isDefaultLayout())) {
+                otherLayouts[i] = layout;
+                counts[i] = SegmentUtils.countMatches(methodFlags, layout);
+            }
+        }
+        for (int i = 0; i < counts.length; i++) {
+            if (counts[i] > 0) {
+                NewAttributeBands bands = attrMap
+                        .getAttributeBands(otherLayouts[i]);
+                otherAttributes[i] = bands.parseAttributes(in, counts[i]);
+                int numBackwardsCallables = otherLayouts[i]
+                        .numBackwardsCallables();
+                if (numBackwardsCallables > 0) {
+                    int[] backwardsCalls = new int[numBackwardsCallables];
+                    System.arraycopy(methodAttrCalls, backwardsCallIndex,
+                            backwardsCalls, 0, numBackwardsCallables);
+                    bands.setBackwardsCalls(backwardsCalls);
+                    backwardsCallIndex += numBackwardsCallables;
+                }
+            }
+        }
+
+        // Non-predefined attributes
+        for (int i = 0; i < methodAttributes.length; i++) {
+            for (int j = 0; j < methodAttributes[i].length; j++) {
+                long flag = methodFlags[i][j];
+                int othersAddedAtStart = 0;
                 for (int k = 0; k < otherLayouts.length; k++) {
                     if (otherLayouts[k] != null
-                            && otherLayouts[k].matches(flag)
-                            && otherLayouts[k].getIndex() >= 15) {
+                            && otherLayouts[k].matches(flag)) {
                         // Add the next attribute
-                        methodAttributes[i][j].add(otherAttributes[k].get(0));
+                        if(otherLayouts[k].getIndex() < 15) {
+                            methodAttributes[i][j].add(othersAddedAtStart++, otherAttributes[k].get(0));
+                        } else {
+                            methodAttributes[i][j].add(otherAttributes[k].get(0));
+                        }
                         otherAttributes[k].remove(0);
                     }
                 }



Mime
View raw message