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/11 00:14:26 UTC
svn commit: r1624147 - in
/tomcat/trunk/java/org/apache/tomcat/util/bcel/classfile: Constant.java
ConstantPool.java ConstantString.java Utility.java
Author: markt
Date: Wed Sep 10 22:14:25 2014
New Revision: 1624147
URL: http://svn.apache.org/r1624147
Log:
Remove unused code (ConstantString)
Removed:
tomcat/trunk/java/org/apache/tomcat/util/bcel/classfile/ConstantString.java
Modified:
tomcat/trunk/java/org/apache/tomcat/util/bcel/classfile/Constant.java
tomcat/trunk/java/org/apache/tomcat/util/bcel/classfile/ConstantPool.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=1624147&r1=1624146&r2=1624147&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 Wed Sep 10 22:14:25 2014
@@ -103,7 +103,8 @@ public abstract class Constant implement
Utility.swallowConstantCP(file);
return null;
case Constants.CONSTANT_String:
- return new ConstantString(file);
+ Utility.swallowConstantString(file);
+ return null;
case Constants.CONSTANT_Integer:
return new ConstantInteger(file);
case Constants.CONSTANT_Float:
Modified: tomcat/trunk/java/org/apache/tomcat/util/bcel/classfile/ConstantPool.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/bcel/classfile/ConstantPool.java?rev=1624147&r1=1624146&r2=1624147&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/bcel/classfile/ConstantPool.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/bcel/classfile/ConstantPool.java Wed Sep 10 22:14:25 2014
@@ -89,11 +89,6 @@ public class ConstantPool implements Clo
c = getConstant(i, Constants.CONSTANT_Utf8);
str = Utility.compactClassName(((ConstantUtf8) c).getBytes());
break;
- case Constants.CONSTANT_String:
- i = ((ConstantString) c).getStringIndex();
- c = getConstant(i, Constants.CONSTANT_Utf8);
- str = "\"" + escape(((ConstantUtf8) c).getBytes()) + "\"";
- break;
case Constants.CONSTANT_Utf8:
str = ((ConstantUtf8) c).getBytes();
break;
@@ -122,35 +117,6 @@ public class ConstantPool implements Clo
}
- private static String escape( String str ) {
- int len = str.length();
- StringBuilder buf = new StringBuilder(len + 5);
- char[] ch = str.toCharArray();
- for (int i = 0; i < len; i++) {
- switch (ch[i]) {
- case '\n':
- buf.append("\\n");
- break;
- case '\r':
- buf.append("\\r");
- break;
- case '\t':
- buf.append("\\t");
- break;
- case '\b':
- buf.append("\\b");
- break;
- case '"':
- buf.append("\\\"");
- break;
- default:
- buf.append(ch[i]);
- }
- }
- return buf.toString();
- }
-
-
/**
* Retrieve constant at `index' from constant pool and resolve it to
* a string representation.
@@ -215,30 +181,17 @@ public class ConstantPool implements Clo
* @param tag Tag of expected constant, either ConstantClass or ConstantString
* @return Contents of string reference
* @see ConstantClass
- * @see ConstantString
* @throws ClassFormatException
*/
public String getConstantString( int index, byte tag ) throws ClassFormatException {
- Constant c;
- int i;
- c = getConstant(index, tag);
- /* This switch() is not that elegant, since the two classes have the
- * same contents, they just differ in the name of the index
- * field variable.
- * But we want to stick to the JVM naming conventions closely though
- * we could have solved these more elegantly by using the same
- * variable name or by subclassing.
- */
- switch (tag) {
- case Constants.CONSTANT_Class:
- i = ((ConstantClass) c).getNameIndex();
- break;
- case Constants.CONSTANT_String:
- i = ((ConstantString) c).getStringIndex();
- break;
- default:
- throw new RuntimeException("getConstantString called with illegal tag " + tag);
+ Constant c = getConstant(index, tag);
+
+ if (Constants.CONSTANT_Class != tag) {
+ throw new RuntimeException("getConstantString called with illegal tag " + tag);
}
+
+ int i = ((ConstantClass) c).getNameIndex();
+
// Finally get the string from the constant pool
c = getConstant(i, Constants.CONSTANT_Utf8);
return ((ConstantUtf8) c).getBytes();
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=1624147&r1=1624146&r2=1624147&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 Wed Sep 10 22:14:25 2014
@@ -277,4 +277,8 @@ final class Utility {
file.readUnsignedByte(); // Unused reference_kind
file.readUnsignedShort(); // Unused reference_index
}
+
+ static void swallowConstantString(DataInput file) throws IOException {
+ file.readUnsignedShort(); // Unused string index
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org