harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sjanu...@apache.org
Subject svn commit: r658191 - in /harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200: ./ bytecode/
Date Tue, 20 May 2008 10:25:23 GMT
Author: sjanuary
Date: Tue May 20 03:25:22 2008
New Revision: 658191

URL: http://svn.apache.org/viewvc?rev=658191&view=rev
Log:
Pack200 - various bug fixes

Modified:
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/BcBands.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/ClassBands.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/NewAttributeBands.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/CodeAttribute.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/EnclosingMethodAttribute.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/LocalVariableTableAttribute.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/LocalVariableTypeTableAttribute.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/NewAttribute.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/SignatureAttribute.java

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/BcBands.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/BcBands.java?rev=658191&r1=658190&r2=658191&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/BcBands.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/BcBands.java
Tue May 20 03:25:22 2008
@@ -29,11 +29,9 @@
 import org.apache.harmony.unpack200.bytecode.ByteCode;
 import org.apache.harmony.unpack200.bytecode.CPClass;
 import org.apache.harmony.unpack200.bytecode.CodeAttribute;
-import org.apache.harmony.unpack200.bytecode.DeprecatedAttribute;
 import org.apache.harmony.unpack200.bytecode.ExceptionTableEntry;
+import org.apache.harmony.unpack200.bytecode.NewAttribute;
 import org.apache.harmony.unpack200.bytecode.OperandManager;
-import org.apache.harmony.unpack200.bytecode.RuntimeVisibleorInvisibleAnnotationsAttribute;
-import org.apache.harmony.unpack200.bytecode.SignatureAttribute;
 
 /**
  * Bytecode bands
@@ -434,9 +432,7 @@
                     for (Iterator iterator = methodAttributesList.iterator(); iterator
                             .hasNext();) {
                         Attribute attribute = (Attribute) iterator.next();
-                        if(attribute instanceof SignatureAttribute ||
-                                attribute instanceof DeprecatedAttribute ||
-                                attribute instanceof RuntimeVisibleorInvisibleAnnotationsAttribute)
{
+                        if((attribute instanceof NewAttribute && ((NewAttribute)attribute).getLayoutIndex()
< 15)) {
                             indexForCodeAttr ++;
                         } else {
                             break;

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=658191&r1=658190&r2=658191&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
Tue May 20 03:25:22 2008
@@ -379,6 +379,16 @@
         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 (deprecatedLayout.matches(flag)) {
                     methodAttributes[i][j].add(new DeprecatedAttribute());
                 }
@@ -404,16 +414,17 @@
                     // be e.g. KIB or KIH
                     if (type.equals("B") || type.equals("H"))
                         type = "I";
-                    ClassFileEntry value = methodSignatureLayout.getValue(
+                    CPUTF8 value = (CPUTF8) methodSignatureLayout.getValue(
                             result, type, cpBands.getConstantPool());
                     methodAttributes[i][j]
-                            .add(new ConstantValueAttribute(value));
+                            .add(new SignatureAttribute(value));
                     methodSignatureIndex++;
                 }
                 // Non-predefined attributes
                 for (int k = 0; k < otherLayouts.length; k++) {
                     if (otherLayouts[k] != null
-                            && otherLayouts[k].matches(flag)) {
+                            && otherLayouts[k].matches(flag)
+                            && otherLayouts[k].getIndex() >= 15) {
                         // Add the next attribute
                         methodAttributes[i][j].add(otherAttributes[k].get(0));
                         otherAttributes[k].remove(0);
@@ -613,7 +624,7 @@
                         className = className.substring(0, index);
                     }
                     // Add .java to the end
-                    value = cpBands.cpUTF8Value(className + ".java", ClassConstantPool.DOMAIN_ATTRIBUTEASCIIZ,
false);
+                    value = cpBands.cpUTF8Value(className + ".java", ClassConstantPool.DOMAIN_ATTRIBUTEASCIIZ,
true);
                 }
                 classAttributes[i].add(new SourceFileAttribute((CPUTF8)value));
                 sourceFileIndex++;
@@ -621,17 +632,20 @@
             if (enclosingMethodLayout.matches(flag)) {
                 CPClass theClass = cpBands
                         .cpClassValue(enclosingMethodRC[enclosingMethodIndex]);
-                CPNameAndType theMethod = cpBands
-                        .cpNameAndTypeValue(enclosingMethodRDN[enclosingMethodIndex]);
+                CPNameAndType theMethod = null;
+                if(enclosingMethodRDN[enclosingMethodIndex] != 0) {
+                    theMethod = cpBands
+                            .cpNameAndTypeValue(enclosingMethodRDN[enclosingMethodIndex]
- 1);
+                }
                 classAttributes[i].add(new EnclosingMethodAttribute(theClass,
                         theMethod));
                 enclosingMethodIndex++;
             }
             if (signatureLayout.matches(flag)) {
                 long result = classSignature[signatureIndex];
-                ClassFileEntry value = signatureLayout.getValue(result, cpBands
+                CPUTF8 value = (CPUTF8) signatureLayout.getValue(result, cpBands
                         .getConstantPool());
-                classAttributes[i].add(new ConstantValueAttribute(value));
+                classAttributes[i].add(new SignatureAttribute(value));
                 signatureIndex++;
             }
             if (innerClassLayout.matches(flag)) {

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/NewAttributeBands.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/NewAttributeBands.java?rev=658191&r1=658190&r2=658191&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/NewAttributeBands.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/NewAttributeBands.java
Tue May 20 03:25:22 2008
@@ -100,7 +100,8 @@
     private Attribute getOneAttribute(int index, List elements) {
         NewAttribute attribute = new NewAttribute(segment.getCpBands()
                 .cpUTF8Value(attributeLayout.getName(),
-                        ClassConstantPool.DOMAIN_ATTRIBUTEASCIIZ));
+                        ClassConstantPool.DOMAIN_ATTRIBUTEASCIIZ),
+                attributeLayout.getIndex());
         for (Iterator iter = elements.iterator(); iter.hasNext();) {
             AttributeLayoutElement element = (AttributeLayoutElement) iter
                     .next();

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/CodeAttribute.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/CodeAttribute.java?rev=658191&r1=658190&r2=658191&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/CodeAttribute.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/CodeAttribute.java
Tue May 20 03:25:22 2008
@@ -169,6 +169,12 @@
 
     public void addAttribute(Attribute attribute) {
         attributes.add(attribute);
+        if(attribute instanceof LocalVariableTableAttribute) {
+            ((LocalVariableTableAttribute)attribute).setCodeLength(codeLength);
+        }
+        if(attribute instanceof LocalVariableTypeTableAttribute) {
+            ((LocalVariableTypeTableAttribute)attribute).setCodeLength(codeLength);
+        }
     }
 
     public List attributes() {

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/EnclosingMethodAttribute.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/EnclosingMethodAttribute.java?rev=658191&r1=658190&r2=658191&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/EnclosingMethodAttribute.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/EnclosingMethodAttribute.java
Tue May 20 03:25:22 2008
@@ -37,6 +37,14 @@
         this.method = method;
     }
 
+    protected ClassFileEntry[] getNestedClassFileEntries() {
+        if(method != null) {
+            return new ClassFileEntry[] {attributeName, cpClass, method};
+        } else {
+            return new ClassFileEntry[] {attributeName, cpClass};
+        }
+    }
+
     /*
      * (non-Javadoc)
      * 
@@ -50,8 +58,12 @@
         super.resolve(pool);
         cpClass.resolve(pool);
         class_index = pool.indexOf(cpClass);
-        method.resolve(pool);
-        method_index = pool.indexOf(method);
+        if(method != null) {
+            method.resolve(pool);
+            method_index = pool.indexOf(method);
+        } else {
+            method_index = 0;
+        }
     }
 
     /*

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/LocalVariableTableAttribute.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/LocalVariableTableAttribute.java?rev=658191&r1=658190&r2=658191&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/LocalVariableTableAttribute.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/LocalVariableTableAttribute.java
Tue May 20 03:25:22 2008
@@ -36,6 +36,7 @@
     private final int[] indexes;
     private final CPUTF8[] names;
     private final CPUTF8[] descriptors;
+    private int codeLength;
     private static final CPUTF8 attributeName = new CPUTF8(
             "LocalVariableTable", ClassConstantPool.DOMAIN_ATTRIBUTEASCIIZ); //$NON-NLS-1$
 
@@ -51,6 +52,11 @@
         this.indexes = indexes;
     }
 
+
+    public void setCodeLength(int length) {
+        codeLength = length;
+    }
+
     protected int getLength() {
         return 2 + (10 * local_variable_table_length);
     }
@@ -123,10 +129,7 @@
         // real length = end_pc - start_pc
         // special case if end_pc is beyond end of bytecode array
 
-        // First figure out the maximum size of the byteCodeOffsets array
-        int lastInstruction = ((Integer) byteCodeOffsets.get(byteCodeOffsets
-                .size() - 1)).intValue();
-        int maxSize = lastInstruction + 1;
+        int maxSize = codeLength;
 
         // Iterate through the lengths and update each in turn.
         // This is done in place in the lengths array.

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/LocalVariableTypeTableAttribute.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/LocalVariableTypeTableAttribute.java?rev=658191&r1=658190&r2=658191&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/LocalVariableTypeTableAttribute.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/LocalVariableTypeTableAttribute.java
Tue May 20 03:25:22 2008
@@ -36,6 +36,7 @@
     private final int[] indexes;
     private final CPUTF8[] names;
     private final CPUTF8[] signatures;
+    private int codeLength;
     private static final CPUTF8 attributeName = new CPUTF8(
             "LocalVariableTypeTable", ClassConstantPool.DOMAIN_ATTRIBUTEASCIIZ); //$NON-NLS-1$
 
@@ -51,6 +52,10 @@
         this.indexes = indexes;
     }
 
+    public void setCodeLength(int length) {
+        codeLength = length;
+    }
+
     protected int getLength() {
         return 2 + (10 * local_variable_type_table_length);
     }
@@ -118,10 +123,7 @@
         // real length = end_pc - start_pc
         // special case if end_pc is beyond end of bytecode array
 
-        // First figure out the maximum size of the byteCodeOffsets array
-        int lastInstruction = ((Integer) byteCodeOffsets.get(byteCodeOffsets
-                .size() - 1)).intValue();
-        int maxSize = lastInstruction + 1;
+        int maxSize = codeLength;
 
         // Iterate through the lengths and update each in turn.
         // This is done in place in the lengths array.

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/NewAttribute.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/NewAttribute.java?rev=658191&r1=658190&r2=658191&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/NewAttribute.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/NewAttribute.java
Tue May 20 03:25:22 2008
@@ -30,9 +30,15 @@
     private final List lengths = new ArrayList(); // List of Integers
     private final List body = new ArrayList();
     private ClassConstantPool pool;
+    private final int layoutIndex;
 
-    public NewAttribute(CPUTF8 attributeName) {
+    public NewAttribute(CPUTF8 attributeName, int layoutIndex) {
         super(attributeName);
+        this.layoutIndex = layoutIndex;
+    }
+
+    public int getLayoutIndex() {
+        return layoutIndex;
     }
 
     /*

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/SignatureAttribute.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/SignatureAttribute.java?rev=658191&r1=658190&r2=658191&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/SignatureAttribute.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/SignatureAttribute.java
Tue May 20 03:25:22 2008
@@ -44,6 +44,10 @@
         return 2;
     }
 
+    protected ClassFileEntry[] getNestedClassFileEntries() {
+        return new ClassFileEntry[] { getAttributeName(), signature };
+    }
+
     protected void resolve(ClassConstantPool pool) {
         super.resolve(pool);
         signature.resolve(pool);



Mime
View raw message