harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sjanu...@apache.org
Subject svn commit: r633879 - in /harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200: BcBands.java bytecode/CodeAttribute.java bytecode/ExceptionTableEntry.java
Date Wed, 05 Mar 2008 15:39:20 GMT
Author: sjanuary
Date: Wed Mar  5 07:39:18 2008
New Revision: 633879

URL: http://svn.apache.org/viewvc?rev=633879&view=rev
Log:
Apply patch for HARMONY-5573 ([classlib][pack200] Caught exceptions may not resolve correctly)

Modified:
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/BcBands.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/ExceptionTableEntry.java

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/BcBands.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/BcBands.java?rev=633879&r1=633878&r2=633879&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/BcBands.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/BcBands.java
Wed Mar  5 07:39:18 2008
@@ -386,7 +386,13 @@
                     if(handlerCount != null) {
                         for (int j = 0; j < handlerCount[i]; j++) {
                             String handlerClass = handlerClassTypes[i][j];
-                            CPClass cpHandlerClass = segment.getCpBands().cpClassValue(handlerClass);
+                            CPClass cpHandlerClass = null;
+                            if(handlerClass != null) {
+                                // The handlerClass will be null if the
+                                // catch is a finally (that is, the
+                                // exception table catch_type should be 0
+                                cpHandlerClass = segment.getCpBands().cpClassValue(handlerClass);
+                            }
                             ExceptionTableEntry entry = new ExceptionTableEntry(
                                     handlerStartPCs[i][j], handlerEndPCs[i][j],
                                     handlerCatchPCs[i][j], cpHandlerClass);

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=633879&r1=633878&r2=633879&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
Wed Mar  5 07:39:18 2008
@@ -101,9 +101,18 @@
         ArrayList nestedEntries = new ArrayList();
         nestedEntries.add(getAttributeName());
         nestedEntries.addAll(byteCodes);
-        // TODO: Is this the right place to add code attribute
-        // attributes?
         nestedEntries.addAll(attributes);
+        // Don't forget to add the ExceptionTable catch_types
+        for (Iterator iter = exceptionTable.iterator(); iter.hasNext();) {
+            ExceptionTableEntry entry = (ExceptionTableEntry) iter.next();
+            CPClass catchType = entry.getCatchType();
+            // If the catch type is null, this is a finally
+            // block. If it's not null, we need to add the
+            // CPClass to the list of nested class file entries.
+            if(catchType != null) {
+                nestedEntries.add(catchType);
+            }
+        }
         ClassFileEntry[] nestedEntryArray = new ClassFileEntry[nestedEntries
                 .size()];
         nestedEntries.toArray(nestedEntryArray);

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ExceptionTableEntry.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ExceptionTableEntry.java?rev=633879&r1=633878&r2=633879&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ExceptionTableEntry.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ExceptionTableEntry.java
Wed Mar  5 07:39:18 2008
@@ -32,6 +32,22 @@
     private int handlerPcRenumbered;
     private int catchTypeIndex;
 
+    /**
+     * Create a new ExceptionTableEntry. Exception tables are
+     * of two kinds: either a normal one (with a Throwable as
+     * the catch_type) or a finally clause (which has no
+     * catch_type). In the class file, the finally clause is
+     * represented as catch_type == 0.
+     * 
+     * To create a finally clause with this method, pass in
+     * null for the catchType.
+     * 
+     * @param startPC int
+     * @param endPC int
+     * @param handlerPC int
+     * @param catchType CPClass (if it's a normal catch) or null
+     *  (if it's a finally clause).
+     */
     public ExceptionTableEntry(int startPC, int endPC, int handlerPC, CPClass catchType)
{
         this.startPC = startPC;
         this.endPC = endPC;
@@ -54,7 +70,17 @@
         handlerPcRenumbered = ((Integer)byteCodeOffsets.get(handlerPcIndex)).intValue();
     }
 
+    public CPClass getCatchType() {
+        return catchType;
+    }
+    
     public void resolve(ClassConstantPool pool) {
+        if(catchType == null) {
+            // If the catch type is a finally clause
+            // the index is always 0.
+            catchTypeIndex = 0;
+            return;
+        }
         catchType.resolve(pool);
         catchTypeIndex = pool.indexOf(catchType);
     }



Mime
View raw message