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 2014/09/12 14:54:11 UTC

svn commit: r1624529 - in /tomcat/tc7.0.x/trunk: ./ java/org/apache/tomcat/util/bcel/ java/org/apache/tomcat/util/bcel/classfile/

Author: markt
Date: Fri Sep 12 12:54:11 2014
New Revision: 1624529

URL: http://svn.apache.org/r1624529
Log:
Port removal of unused code from trunk

Removed:
    tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/Code.java
    tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/ConstantValue.java
    tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/Deprecated.java
    tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/ExceptionTable.java
    tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/InnerClasses.java
    tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/LineNumberTable.java
    tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/LocalVariableTable.java
    tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/PMGClass.java
    tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/SourceFile.java
Modified:
    tomcat/tc7.0.x/trunk/   (props changed)
    tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/   (props changed)
    tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/Attribute.java
    tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/Utility.java

Propchange: tomcat/tc7.0.x/trunk/
------------------------------------------------------------------------------
  Merged /tomcat/trunk:r1624110,1624112,1624115-1624116,1624119,1624122,1624124,1624126,1624129-1624130

Propchange: tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/
------------------------------------------------------------------------------
  Merged /tomcat/trunk/java/org/apache/tomcat/util/bcel:r1624110,1624112,1624115-1624116,1624119,1624122,1624124,1624126,1624129-1624130

Modified: tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/Attribute.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/Attribute.java?rev=1624529&r1=1624528&r2=1624529&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/Attribute.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/Attribute.java Fri Sep 12 12:54:11 2014
@@ -32,14 +32,6 @@ import org.apache.tomcat.util.bcel.Const
  * attribute stands for non-standard-attributes.
  * 
  * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
- * @see ConstantValue
- * @see SourceFile
- * @see Code
- * @see ExceptionTable
- * @see LineNumberTable
- * @see LocalVariableTable
- * @see InnerClasses
- * @see Deprecated
  */
 public abstract class Attribute implements Cloneable, Serializable
 {
@@ -102,27 +94,35 @@ public abstract class Attribute implemen
             Utility.swallowUnknownAttribute(file, length);
             return null;
         case Constants.ATTR_CONSTANT_VALUE:
-            return new ConstantValue(name_index, length, file, constant_pool);
+            Utility.swallowConstantValue(file);
+            return null;
         case Constants.ATTR_SOURCE_FILE:
-            return new SourceFile(name_index, length, file, constant_pool);
+            Utility.swallowSourceFile(file);
+            return null;
         case Constants.ATTR_CODE:
-            return new Code(name_index, length, file, constant_pool);
+            Utility.swallowCode(file, constant_pool);
+            return null;
         case Constants.ATTR_EXCEPTIONS:
-            return new ExceptionTable(name_index, length, file, constant_pool);
+            Utility.swallowExceptionTable(file);
+            return null;
         case Constants.ATTR_LINE_NUMBER_TABLE:
-            return new LineNumberTable(name_index, length, file, constant_pool);
+            Utility.swallowLineNumberTable(file);
+            return null;
         case Constants.ATTR_LOCAL_VARIABLE_TABLE:
-            return new LocalVariableTable(name_index, length, file,
-                    constant_pool);
+            Utility.swallowLocalVariableTable(file);
+            return null;
         case Constants.ATTR_INNER_CLASSES:
-            return new InnerClasses(name_index, length, file, constant_pool);
+            Utility.swallowInnerClasses(file);
+            return null;
         case Constants.ATTR_SYNTHETIC:
-            Utility.swallowSynthetic(file, length);
+            Utility.swallowSynthetic(length);
             return null;
         case Constants.ATTR_DEPRECATED:
-            return new Deprecated(name_index, length, file, constant_pool);
+            Utility.swallowDeprecated(length);
+            return null;
         case Constants.ATTR_PMG:
-            return new PMGClass(name_index, length, file, constant_pool);
+            Utility.swallowPMCClass(file);
+            return null;
         case Constants.ATTR_SIGNATURE:
             Utility.swallowSignature(file);
             return null;

Modified: tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/Utility.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/Utility.java?rev=1624529&r1=1624528&r2=1624529&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/Utility.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/Utility.java Fri Sep 12 12:54:11 2014
@@ -181,11 +181,78 @@ final class Utility {
         file.readUnsignedShort();   // Unused signature_index
     }
 
-    static void swallowSynthetic(DataInput file, int length) throws IOException {
+    static void swallowSynthetic(int length) {
         if (length > 0) {
-            byte[] bytes = new byte[length];
-            file.readFully(bytes);
             throw new ClassFormatException("Synthetic attribute with length > 0");
         }
     }
+
+    static void swallowSourceFile(DataInput file) throws IOException {
+        file.readUnsignedShort();   // Unused sourcefile_index
+    }
+
+    static void swallowConstantValue(DataInput file) throws IOException {
+        file.readUnsignedShort();   // Unused constantvalue_index
+    }
+
+    static void swallowCode(DataInputStream file, ConstantPool constant_pool) throws IOException {
+        file.readUnsignedShort();   // Unused max_stack
+        file.readUnsignedShort();   // Unused max_locals
+        int code_length = file.readInt();
+        byte[] code = new byte[code_length]; // Read byte code
+        file.readFully(code);
+        /* Read exception table that contains all regions where an exception
+         * handler is active, i.e., a try { ... } catch() block.
+         */
+        int exception_table_length = file.readUnsignedShort();
+        for (int i = 0; i < exception_table_length; i++) {
+            Utility.swallowCodeException(file);
+        }
+        /* Read all attributes, currently `LineNumberTable' and
+         * `LocalVariableTable'
+         */
+        int attributes_count = file.readUnsignedShort();
+        for (int i = 0; i < attributes_count; i++) {
+            Attribute.readAttribute(file, constant_pool);
+        }
+    }
+
+    static void swallowExceptionTable(DataInput file) throws IOException {
+        int number_of_exceptions = file.readUnsignedShort();
+        for (int i = 0; i < number_of_exceptions; i++) {
+            file.readUnsignedShort(); // Unused exception index
+        }
+    }
+
+    static void swallowLineNumberTable(DataInput file) throws IOException {
+        int line_number_table_length = (file.readUnsignedShort());
+        for (int i = 0; i < line_number_table_length; i++) {
+            Utility.swallowLineNumber(file);
+        }
+    }
+
+    static void swallowLocalVariableTable(DataInput file) throws IOException {
+        int local_variable_table_length = (file.readUnsignedShort());
+        for (int i = 0; i < local_variable_table_length; i++) {
+            Utility.swallowLocalVariable(file);
+        }
+    }
+
+    static void swallowInnerClasses(DataInput file) throws IOException {
+        int number_of_classes = file.readUnsignedShort();
+        for (int i = 0; i < number_of_classes; i++) {
+            Utility.swallowInnerClass(file);
+        }
+    }
+
+    static void swallowDeprecated(int length) {
+        if (length > 0) {
+            throw new ClassFormatException("Deprecated attribute with length > 0");
+        }
+    }
+
+    static void swallowPMCClass(DataInput file) throws IOException {
+        file.readUnsignedShort();   // Unused pmg_index
+        file.readUnsignedShort();   // Unused pmg_class_index
+    }
 }



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