Author: kkolinko
Date: Fri Sep 12 11:15:44 2014
New Revision: 1624498

URL: http://svn.apache.org/r1624498
Log:
Simplify Constant.readConstant()
and remove swallow methods that are no longer used from Utility class.

Modified:
    tomcat/trunk/java/org/apache/tomcat/util/bcel/classfile/Constant.java
    tomcat/trunk/java/org/apache/tomcat/util/bcel/classfile/Utility.java

Modified: tomcat/trunk/java/org/apache/tomcat/util/bcel/classfile/Constant.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/bcel/classfile/Constant.java?rev=1624498&r1=1624497&r2=1624498&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/bcel/classfile/Constant.java 
(original)
+++ tomcat/trunk/java/org/apache/tomcat/util/bcel/classfile/Constant.java Fri 
Sep 12 11:15:44 2014
@@ -68,17 +68,10 @@ public abstract class Constant implement
     static Constant readConstant( DataInputStream file ) throws IOException,
             ClassFormatException {
         byte b = file.readByte(); // Read tag byte
+        int skipSize;
         switch (b) {
             case Constants.CONSTANT_Class:
                 return new ConstantClass(file);
-            case Constants.CONSTANT_Fieldref:
-            case Constants.CONSTANT_Methodref:
-            case Constants.CONSTANT_InterfaceMethodref:
-                Utility.swallowConstantCP(file);
-                return null;
-            case Constants.CONSTANT_String:
-                Utility.swallowConstantString(file);
-                return null;
             case Constants.CONSTANT_Integer:
                 return new ConstantInteger(file);
             case Constants.CONSTANT_Float:
@@ -87,23 +80,27 @@ public abstract class Constant implement
                 return new ConstantLong(file);
             case Constants.CONSTANT_Double:
                 return new ConstantDouble(file);
-            case Constants.CONSTANT_NameAndType:
-                Utility.swallowConstantNameAndType(file);
-                return null;
             case Constants.CONSTANT_Utf8:
                 return ConstantUtf8.getInstance(file);
-            case Constants.CONSTANT_MethodHandle:
-                Utility.swallowConstantMethodHandle(file);
-                return null;
+            case Constants.CONSTANT_String:
             case Constants.CONSTANT_MethodType:
-                Utility.swallowConstantMethodType(file);
-                return null;
+                skipSize = 2; // unsigned short
+                break;
+            case Constants.CONSTANT_MethodHandle:
+                skipSize = 3; // unsigned byte, unsigned short
+                break;
+            case Constants.CONSTANT_Fieldref:
+            case Constants.CONSTANT_Methodref:
+            case Constants.CONSTANT_InterfaceMethodref:
+            case Constants.CONSTANT_NameAndType:
             case Constants.CONSTANT_InvokeDynamic:
-                Utility.swallowConstantInvokeDynamic(file);
-                return null;
+                skipSize = 4; // unsigned short, unsigned short
+                break;
             default:
                 throw new ClassFormatException("Invalid byte tag in constant 
pool: " + b);
         }
+        Utility.skipFully(file, skipSize);
+        return null;
     }
 
 

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=1624498&r1=1624497&r2=1624498&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 Fri 
Sep 12 11:15:44 2014
@@ -52,40 +52,6 @@ final class Utility {
         }
     }
 
-    static void swallowConstantCP(DataInput file) throws IOException {
-        // file.readUnsignedShort(); // Unused class index
-        // file.readUnsignedShort(); // Unused name and type index
-        skipFully(file, 4);
-    }
-
-    static void swallowConstantMethodHandle(DataInput file) throws IOException 
{
-        // file.readUnsignedByte();  // Unused reference_kind
-        // file.readUnsignedShort(); // Unused reference_index
-        skipFully(file, 3);
-    }
-
-    static void swallowConstantString(DataInput file) throws IOException {
-        // file.readUnsignedShort(); // Unused string index
-        skipFully(file, 2);
-    }
-
-    static void swallowConstantNameAndType(DataInput file) throws IOException {
-        // file.readUnsignedShort(); // Unused name index
-        // file.readUnsignedShort(); // Unused signature index
-        skipFully(file, 4);
-    }
-
-    static void swallowConstantMethodType(DataInput file) throws IOException {
-        // file.readUnsignedShort(); // Unused descriptor_index
-        skipFully(file, 2);
-    }
-
-    static void swallowConstantInvokeDynamic(DataInput file) throws 
IOException {
-        // file.readUnsignedShort(); // Unused bootstrap_method_attr_index
-        // file.readUnsignedShort(); // Unused name_and_type_index
-        skipFully(file, 4);
-    }
-
     static void swallowFieldOrMethod(DataInput file)
             throws IOException {
         // file.readUnsignedShort(); // Unused access flags



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

Reply via email to