harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r612054 - in /harmony/enhanced/classlib/trunk/modules/pack200/src: main/java/org/apache/harmony/pack200/bytecode/ main/java/org/apache/harmony/pack200/bytecode/forms/ test/java/org/apache/harmony/pack200/tests/
Date Tue, 15 Jan 2008 09:18:07 GMT
Author: tellison
Date: Tue Jan 15 01:18:06 2008
New Revision: 612054

URL: http://svn.apache.org/viewvc?rev=612054&view=rev
Log:
Apply patch HARMONY-5388 ([pack200][classlib] Label bytecode offsets can be incorrect)

Modified:
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ClassConstantPool.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CodeAttribute.java
    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/LabelForm.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/SegmentTest.java

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ClassConstantPool.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ClassConstantPool.java?rev=612054&r1=612053&r2=612054&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ClassConstantPool.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ClassConstantPool.java
Tue Jan 15 01:18:06 2008
@@ -17,16 +17,10 @@
 package org.apache.harmony.pack200.bytecode;
 
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.Comparator;
-import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
-import java.util.SortedSet;
-import java.util.TreeSet;
-import org.apache.harmony.pack200.bytecode.ConstantPoolEntry;
 
-import org.apache.harmony.pack200.Pack200Exception;
 import org.apache.harmony.pack200.Segment;
 import org.apache.harmony.pack200.SegmentUtils;
 

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CodeAttribute.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CodeAttribute.java?rev=612054&r1=612053&r2=612054&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CodeAttribute.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CodeAttribute.java
Tue Jan 15 01:18:06 2008
@@ -42,11 +42,13 @@
         this.codeLength = 0;
         this.exceptionTable = exceptionTable;
         byteCodeOffsets.add(new Integer(0));
+        int byteCodeIndex = 0;
         for (int i = 0; i < codePacked.length; i++) {
             ByteCode byteCode = ByteCode.getByteCode(codePacked[i] & 0xff);
             // Setting the offset must happen before extracting operands
             // because label bytecodes need to know their offsets.
-            byteCode.setByteCodeIndex(i);
+            byteCode.setByteCodeIndex(byteCodeIndex);
+            byteCodeIndex++;
             byteCode.extractOperands(operandManager, segment, codeLength);
             byteCodes.add(byteCode);
             codeLength += byteCode.getLength();
@@ -57,6 +59,7 @@
             // another bytecode.
             if (byteCode.hasMultipleByteCodes()) {
                 byteCodeOffsets.add(new Integer(lastBytecodePosition + 1));
+                byteCodeIndex++;
             }
             // I've already added the first element (at 0) before
             // entering this loop, so make sure I don't add one

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=612054&r1=612053&r2=612054&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
Tue Jan 15 01:18:06 2008
@@ -16,10 +16,7 @@
  */
 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;
 
 /**

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/forms/LabelForm.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/forms/LabelForm.java?rev=612054&r1=612053&r2=612054&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/forms/LabelForm.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/forms/LabelForm.java
Tue Jan 15 01:18:06 2008
@@ -59,7 +59,6 @@
         int sourceValue = ((Integer)codeAttribute.byteCodeOffsets.get(sourceIndex)).intValue();
         // The operand is the difference between the source instruction
         // and the destination instruction.
-        // TODO: Probably have to do something other than setOperandInt if this is widened.
         byteCode.setOperandSigned2Bytes(targetValue - sourceValue, 0);
         if(widened) {
             byteCode.setNestedPositions(new int[][] {{0,4}});

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/SegmentTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/SegmentTest.java?rev=612054&r1=612053&r2=612054&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/SegmentTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/SegmentTest.java
Tue Jan 15 01:18:06 2008
@@ -64,27 +64,22 @@
     
     // Test with an archive containing Harmony's SQL module, packed with -E1
     public void testWithSqlE1() throws Exception {
-    	// This test will not pass until we handle inner classes
-    	// correctly.
-     	if(!handlingInnerClasses) return;
         in = Segment.class
                 .getResourceAsStream("/org/apache/harmony/pack200/tests/sql-e1.pack.gz");
         Segment segment = Segment.parse(in);
         assertNotNull(segment);
-        out = new JarOutputStream(new FileOutputStream(File.createTempFile("s", "ql-e1.jar")));
+        out = new JarOutputStream(new FileOutputStream(File.createTempFile("sql", "-e1.jar")));
         segment.writeJar(out);
     }
     
     // Test with an archive containing Harmony's SQL module
     public void testWithSql() throws Exception {
-    	// This test will not pass until we handle inner classes
-    	// correctly.
      	if(!handlingInnerClasses) return;
         in = Segment.class
                 .getResourceAsStream("/org/apache/harmony/pack200/tests/sql.pack.gz");
         Segment segment = Segment.parse(in);
         assertNotNull(segment);
-        out = new JarOutputStream(new FileOutputStream(File.createTempFile("s", "ql.jar")));
+        out = new JarOutputStream(new FileOutputStream(File.createTempFile("sql", ".jar")));
         segment.writeJar(out);
     }
     
@@ -115,7 +110,7 @@
                 .getResourceAsStream("/org/apache/harmony/pack200/tests/jndi-e1.pack.gz");
         Segment segment = Segment.parse(in);
         assertNotNull(segment);
-        out = new JarOutputStream(new FileOutputStream(File.createTempFile("jn", "di-e1.jar")));
+        out = new JarOutputStream(new FileOutputStream(File.createTempFile("jndi", "-e1.jar")));
         segment.writeJar(out);
     }
     



Mime
View raw message