harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sjanu...@apache.org
Subject svn commit: r633865 - in /harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/forms: ClassRefForm.java NewClassRefForm.java
Date Wed, 05 Mar 2008 14:52:05 GMT
Author: sjanuary
Date: Wed Mar  5 06:52:02 2008
New Revision: 633865

URL: http://svn.apache.org/viewvc?rev=633865&view=rev
Log:
Apply patch for HARMONY-5572 ([classlib][pack200] Checkcast bytecode has incorrect class)

Modified:
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/forms/ClassRefForm.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/forms/NewClassRefForm.java

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/forms/ClassRefForm.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/forms/ClassRefForm.java?rev=633865&r1=633864&r2=633865&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/forms/ClassRefForm.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/forms/ClassRefForm.java
Wed Mar  5 06:52:02 2008
@@ -16,7 +16,10 @@
  */
 package org.apache.harmony.pack200.bytecode.forms;
 
+import org.apache.harmony.pack200.Pack200Exception;
 import org.apache.harmony.pack200.SegmentConstantPool;
+import org.apache.harmony.pack200.bytecode.ByteCode;
+import org.apache.harmony.pack200.bytecode.ClassFileEntry;
 import org.apache.harmony.pack200.bytecode.OperandManager;
 
 /**
@@ -38,6 +41,26 @@
         this.widened = widened;
     }
 
+    protected void setNestedEntries(ByteCode byteCode, OperandManager operandManager, int
offset) throws Pack200Exception {
+        // If the offset is not zero, proceed normally.
+        if(offset != 0) {
+            super.setNestedEntries(byteCode, operandManager, offset - 1);
+            return;
+        }
+        // If the offset is 0, ClassRefForms refer to
+        // the current class. Add that as the nested class.
+        // (This is true for all bc_classref forms in
+        // the spec except for multianewarray, which has
+        // its own form.)
+        SegmentConstantPool globalPool = operandManager.globalConstantPool();
+        ClassFileEntry[] nested = null;
+        // How do I get this class? 
+        nested = new ClassFileEntry[] {
+                globalPool.getClassPoolEntry(operandManager.getCurrentClass())
+            };
+        byteCode.setNested(nested);
+        byteCode.setNestedPositions(new int[][] {{0,2}});
+    }
     public int getOperandType() {
         return TYPE_CLASSREF;
     }

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/forms/NewClassRefForm.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/forms/NewClassRefForm.java?rev=633865&r1=633864&r2=633865&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/forms/NewClassRefForm.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/forms/NewClassRefForm.java
Wed Mar  5 06:52:02 2008
@@ -58,7 +58,9 @@
         } else {
             // Look up the class in the classpool
             try {
-                setNestedEntries(byteCode, operandManager, offset - 1);
+                // Parent takes care of subtracting one from offset
+                // to adjust for 1-based global pool
+                setNestedEntries(byteCode, operandManager, offset);
             } catch (Pack200Exception ex) {
                 throw new Error("Got a pack200 exception. What to do?");
             }



Mime
View raw message