You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2013/11/09 22:35:04 UTC

svn commit: r1540396 - in /tomcat/trunk/java/org/apache/tomcat/util/bcel/classfile: StackMap.java StackMapEntry.java StackMapTable.java StackMapTableEntry.java StackMapType.java Utility.java

Author: markt
Date: Sat Nov  9 21:35:03 2013
New Revision: 1540396

URL: http://svn.apache.org/r1540396
Log:
Remove StackMapType.
Swallow associated values as they are never used.

Removed:
    tomcat/trunk/java/org/apache/tomcat/util/bcel/classfile/StackMapType.java
Modified:
    tomcat/trunk/java/org/apache/tomcat/util/bcel/classfile/StackMap.java
    tomcat/trunk/java/org/apache/tomcat/util/bcel/classfile/StackMapEntry.java
    tomcat/trunk/java/org/apache/tomcat/util/bcel/classfile/StackMapTable.java
    tomcat/trunk/java/org/apache/tomcat/util/bcel/classfile/StackMapTableEntry.java
    tomcat/trunk/java/org/apache/tomcat/util/bcel/classfile/Utility.java

Modified: tomcat/trunk/java/org/apache/tomcat/util/bcel/classfile/StackMap.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/bcel/classfile/StackMap.java?rev=1540396&r1=1540395&r2=1540396&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/bcel/classfile/StackMap.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/bcel/classfile/StackMap.java Sat Nov  9 21:35:03 2013
@@ -33,7 +33,6 @@ import java.io.IOException;
  * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
  * @see     Code
  * @see     StackMapEntry
- * @see     StackMapType
  */
 public final class StackMap extends Attribute {
 

Modified: tomcat/trunk/java/org/apache/tomcat/util/bcel/classfile/StackMapEntry.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/bcel/classfile/StackMapEntry.java?rev=1540396&r1=1540395&r2=1540396&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/bcel/classfile/StackMapEntry.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/bcel/classfile/StackMapEntry.java Sat Nov  9 21:35:03 2013
@@ -29,7 +29,6 @@ import java.io.Serializable;
  * @version $Id$
  * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
  * @see     StackMap
- * @see     StackMapType
  */
 public final class StackMapEntry implements Cloneable, Serializable {
 
@@ -43,16 +42,12 @@ public final class StackMapEntry impleme
     StackMapEntry(DataInputStream file) throws IOException {
         file.readShort();   // Unused byte_code_offset
         int number_of_locals = file.readShort();
-        StackMapType[] types_of_locals = null;
-        StackMapType[] types_of_stack_items = null;
-        types_of_locals = new StackMapType[number_of_locals];
         for (int i = 0; i < number_of_locals; i++) {
-            types_of_locals[i] = new StackMapType(file);
+            Utility.swallowStackMapType(file);
         }
         int number_of_stack_items = file.readShort();
-        types_of_stack_items = new StackMapType[number_of_stack_items];
         for (int i = 0; i < number_of_stack_items; i++) {
-            types_of_stack_items[i] = new StackMapType(file);
+            Utility.swallowStackMapType(file);
         }
     }
 }

Modified: tomcat/trunk/java/org/apache/tomcat/util/bcel/classfile/StackMapTable.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/bcel/classfile/StackMapTable.java?rev=1540396&r1=1540395&r2=1540396&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/bcel/classfile/StackMapTable.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/bcel/classfile/StackMapTable.java Sat Nov  9 21:35:03 2013
@@ -33,7 +33,6 @@ import java.io.IOException;
  * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
  * @see     Code
  * @see     StackMapEntry
- * @see     StackMapType
  */
 public final class StackMapTable extends Attribute {
 

Modified: tomcat/trunk/java/org/apache/tomcat/util/bcel/classfile/StackMapTableEntry.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/bcel/classfile/StackMapTableEntry.java?rev=1540396&r1=1540395&r2=1540396&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/bcel/classfile/StackMapTableEntry.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/bcel/classfile/StackMapTableEntry.java Sat Nov  9 21:35:03 2013
@@ -31,7 +31,6 @@ import org.apache.tomcat.util.bcel.Const
  * @version $Id$
  * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
  * @see     StackMap
- * @see     StackMapType
  */
 public final class StackMapTableEntry implements Cloneable, Serializable {
 
@@ -39,9 +38,7 @@ public final class StackMapTableEntry im
 
     private int frame_type;
     private int number_of_locals;
-    private StackMapType[] types_of_locals;
     private int number_of_stack_items;
-    private StackMapType[] types_of_stack_items;
 
 
     /**
@@ -52,21 +49,17 @@ public final class StackMapTableEntry im
     StackMapTableEntry(DataInputStream file) throws IOException {
         this.frame_type = file.read();
         this.number_of_locals = -1;
-        this.types_of_locals = null;
         this.number_of_stack_items = -1;
-        this.types_of_stack_items = null;
 
         if (frame_type >= Constants.SAME_FRAME && frame_type <= Constants.SAME_FRAME_MAX) {
             // NO-OP
         } else if (frame_type >= Constants.SAME_LOCALS_1_STACK_ITEM_FRAME && frame_type <= Constants.SAME_LOCALS_1_STACK_ITEM_FRAME_MAX) {
             number_of_stack_items = 1;
-            types_of_stack_items = new StackMapType[1];
-            types_of_stack_items[0] = new StackMapType(file);
+            Utility.swallowStackMapType(file);
         } else if (frame_type == Constants.SAME_LOCALS_1_STACK_ITEM_FRAME_EXTENDED) {
             file.readShort(); // Unused byte_code_offset_delta
             number_of_stack_items = 1;
-            types_of_stack_items = new StackMapType[1];
-            types_of_stack_items[0] = new StackMapType(file);
+            Utility.swallowStackMapType(file);
         } else if (frame_type >= Constants.CHOP_FRAME && frame_type <= Constants.CHOP_FRAME_MAX) {
             file.readShort(); // Unused byte_code_offset_delta
         } else if (frame_type == Constants.SAME_FRAME_EXTENDED) {
@@ -74,21 +67,18 @@ public final class StackMapTableEntry im
         } else if (frame_type >= Constants.APPEND_FRAME && frame_type <= Constants.APPEND_FRAME_MAX) {
             file.readShort(); // Unused byte_code_offset_delta
             number_of_locals = frame_type - 251;
-            types_of_locals = new StackMapType[number_of_locals];
             for (int i = 0; i < number_of_locals; i++) {
-                types_of_locals[i] = new StackMapType(file);
+                Utility.swallowStackMapType(file);
             }
         } else if (frame_type == Constants.FULL_FRAME) {
             file.readShort(); // Unused byte_code_offset_delta
             number_of_locals = file.readShort();
-            types_of_locals = new StackMapType[number_of_locals];
             for (int i = 0; i < number_of_locals; i++) {
-                types_of_locals[i] = new StackMapType(file);
+                Utility.swallowStackMapType(file);
             }
             number_of_stack_items = file.readShort();
-            types_of_stack_items = new StackMapType[number_of_stack_items];
             for (int i = 0; i < number_of_stack_items; i++) {
-                types_of_stack_items[i] = new StackMapType(file);
+                Utility.swallowStackMapType(file);
             }
         } else {
             /* Can't happen */

Modified: tomcat/trunk/java/org/apache/tomcat/util/bcel/classfile/Utility.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/bcel/classfile/Utility.java?rev=1540396&r1=1540395&r2=1540396&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/bcel/classfile/Utility.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/bcel/classfile/Utility.java Sat Nov  9 21:35:03 2013
@@ -20,6 +20,8 @@ package org.apache.tomcat.util.bcel.clas
 import java.io.DataInput;
 import java.io.IOException;
 
+import org.apache.tomcat.util.bcel.Constants;
+
 
 /**
  * Utility functions that do not really belong to any class in particular.
@@ -91,16 +93,14 @@ public abstract class Utility {
         MAP_CHAR['_'] = j;
     }
 
-    protected static void swallowCodeException(DataInput file)
-            throws IOException {
+    protected static void swallowCodeException(DataInput file) throws IOException {
         file.readUnsignedShort();   // Unused start_pc
         file.readUnsignedShort();   // Unused end_pc
         file.readUnsignedShort();   // Unused handler_pc
         file.readUnsignedShort();   // Unused catch_type
     }
 
-    protected static void swallowInnerClass(DataInput file)
-            throws IOException {
+    protected static void swallowInnerClass(DataInput file) throws IOException {
         file.readUnsignedShort();   // Unused inner_class_index
         file.readUnsignedShort();   // Unused outer_class_index
         file.readUnsignedShort();   // Unused inner_name_index
@@ -112,12 +112,22 @@ public abstract class Utility {
         file.readUnsignedShort();   // Unused line_number
     }
 
-    protected static void swallowLocalVariable(DataInput file)
-            throws IOException {
+    protected static void swallowLocalVariable(DataInput file) throws IOException {
         file.readUnsignedShort();   // Unused start_pc
         file.readUnsignedShort();   // Unused length
         file.readUnsignedShort();   // Unused name_index
         file.readUnsignedShort();   // Unused signature_index
         file.readUnsignedShort();   // Unused index
     }
+
+    protected static void swallowStackMapType(DataInput file) throws IOException {
+        byte type = file.readByte();
+        if ((type < Constants.ITEM_Bogus) || (type > Constants.ITEM_NewObject)) {
+            throw new RuntimeException("Illegal type for StackMapType: " + type);
+        }
+        // Check to see if type has an index
+        if ((type == Constants.ITEM_Object) || (type == Constants.ITEM_NewObject)) {
+            file.readShort();   // Unused index
+        }
+    }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org