Author: markt
Date: Fri Sep 12 13:01:37 2014
New Revision: 1624533
URL: http://svn.apache.org/r1624533
Log:
Port removal of unnecesary code from trunk
Removed:
tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/ConstantCP.java
tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/ConstantFieldref.java
tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/ConstantInterfaceMethodref.java
tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/ConstantInvokeDynamic.java
tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/ConstantMethodHandle.java
tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/ConstantMethodType.java
tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/ConstantMethodref.java
tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/ConstantNameAndType.java
tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/ConstantString.java
tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/EnclosingMethod.java
tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/LocalVariableTypeTable.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/AnnotationDefault.java
tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/Annotations.java
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/Constant.java
tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/ConstantPool.java
tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/FieldOrMethod.java
tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/JavaClass.java
tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/Utility.java
Propchange: tomcat/tc7.0.x/trunk/
------------------------------------------------------------------------------
Merged
/tomcat/trunk:r1624132-1624133,1624135,1624139,1624142-1624143,1624147,1624150,1624152,1624155-1624157
Propchange: tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/
------------------------------------------------------------------------------
Merged
/tomcat/trunk/java/org/apache/tomcat/util/bcel:r1624132-1624133,1624135,1624139,1624142-1624143,1624147,1624150,1624152,1624155-1624157
Modified:
tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/AnnotationDefault.java
URL:
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/AnnotationDefault.java?rev=1624533&r1=1624532&r2=1624533&view=diff
==============================================================================
---
tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/AnnotationDefault.java
(original)
+++
tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/AnnotationDefault.java
Fri Sep 12 13:01:37 2014
@@ -45,34 +45,7 @@ public class AnnotationDefault extends A
DataInputStream file, ConstantPool constant_pool)
throws IOException
{
- this(name_index, length, (ElementValue) null,
- constant_pool);
- default_value = ElementValue.readElementValue(file, constant_pool);
- }
-
- /**
- * @param name_index
- * Index pointing to the name <em>Code</em>
- * @param length
- * Content length in bytes
- * @param defaultValue
- * the annotation's default value
- * @param constant_pool
- * Array of constants
- */
- public AnnotationDefault(int name_index, int length,
- ElementValue defaultValue, ConstantPool constant_pool)
- {
super(name_index, length, constant_pool);
- setDefaultValue(defaultValue);
- }
-
- /**
- * @param defaultValue
- * the default value of this methodinfo's annotation
- */
- public final void setDefaultValue(ElementValue defaultValue)
- {
- default_value = defaultValue;
+ default_value = ElementValue.readElementValue(file, constant_pool);
}
}
Modified:
tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/Annotations.java
URL:
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/Annotations.java?rev=1624533&r1=1624532&r2=1624533&view=diff
==============================================================================
---
tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/Annotations.java
(original)
+++
tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/Annotations.java
Fri Sep 12 13:01:37 2014
@@ -30,7 +30,7 @@ public abstract class Annotations extend
private static final long serialVersionUID = 1L;
- private AnnotationEntry[] annotation_table;
+ private final AnnotationEntry[] annotation_table;
/**
* @param name_index Index pointing to the name <em>Code</em>
@@ -38,8 +38,9 @@ public abstract class Annotations extend
* @param file Input stream
* @param constant_pool Array of constants
*/
- public Annotations(int name_index, int length, DataInputStream file,
ConstantPool constant_pool) throws IOException {
- this(name_index, length, (AnnotationEntry[]) null, constant_pool);
+ public Annotations(int name_index, int length, DataInputStream file,
+ ConstantPool constant_pool) throws IOException {
+ super(name_index, length, constant_pool);
final int annotation_table_length = (file.readUnsignedShort());
annotation_table = new AnnotationEntry[annotation_table_length];
for (int i = 0; i < annotation_table_length; i++) {
@@ -49,24 +50,6 @@ public abstract class Annotations extend
/**
- * @param name_index Index pointing to the name <em>Code</em>
- * @param length Content length in bytes
- * @param annotation_table the actual annotations
- * @param constant_pool Array of constants
- */
- public Annotations(int name_index, int length, AnnotationEntry[]
annotation_table, ConstantPool constant_pool) {
- super(name_index, length, constant_pool);
- setAnnotationTable(annotation_table);
- }
-
- /**
- * @param annotation_table the entries to set in this annotation
- */
- public final void setAnnotationTable( AnnotationEntry[] annotation_table )
{
- this.annotation_table = annotation_table;
- }
-
- /**
* returns the array of annotation entries in this annotation
*/
public AnnotationEntry[] getAnnotationEntries() {
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=1624533&r1=1624532&r2=1624533&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 13:01:37 2014
@@ -33,7 +33,7 @@ import org.apache.tomcat.util.bcel.Const
*
* @author <A HREF="mailto:[email protected]">M. Dahm</A>
*/
-public abstract class Attribute implements Cloneable, Serializable
+public abstract class Attribute implements Serializable
{
private static final long serialVersionUID = 1514136303496688899L;
@@ -145,10 +145,11 @@ public abstract class Attribute implemen
return new AnnotationDefault(name_index, length, file,
constant_pool);
case Constants.ATTR_LOCAL_VARIABLE_TYPE_TABLE:
- return new LocalVariableTypeTable(name_index, length, file,
- constant_pool);
+ Utility.swallowLocalVariableTypeTable(file);
+ return null;
case Constants.ATTR_ENCLOSING_METHOD:
- return new EnclosingMethod(name_index, length, file,
constant_pool);
+ Utility.swallowEnclosingMethod(file);
+ return null;
case Constants.ATTR_STACK_MAP_TABLE:
Utility.swallowStackMapTable(file);
return null;
@@ -172,26 +173,4 @@ public abstract class Attribute implemen
Constants.CONSTANT_Utf8);
return c.getBytes();
}
-
-
- /**
- * Use copy() if you want to have a deep copy(), i.e., with all references
- * copied correctly.
- *
- * @return shallow copy of this attribute
- */
- @Override
- public Attribute clone()
- {
- Attribute attr = null;
- try
- {
- attr = (Attribute) super.clone();
- }
- catch (CloneNotSupportedException e)
- {
- throw new Error("Clone Not Supported"); // never happens
- }
- return attr;
- }
}
Modified:
tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/Constant.java
URL:
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/Constant.java?rev=1624533&r1=1624532&r2=1624533&view=diff
==============================================================================
---
tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/Constant.java
(original)
+++
tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/Constant.java
Fri Sep 12 13:01:37 2014
@@ -31,7 +31,7 @@ import org.apache.tomcat.util.bcel.util.
*
* @author <A HREF="mailto:[email protected]">M. Dahm</A>
*/
-public abstract class Constant implements Cloneable, Serializable {
+public abstract class Constant implements Serializable {
private static final long serialVersionUID = 2827409182154809454L;
private static BCELComparator _cmp = new BCELComparator() {
@@ -75,16 +75,6 @@ public abstract class Constant implement
}
- @Override
- public Object clone() {
- try {
- return super.clone();
- } catch (CloneNotSupportedException e) {
- throw new Error("Clone Not Supported"); // never happens
- }
- }
-
-
/**
* Read one constant from the given file, the type depends on a tag byte.
*
@@ -98,13 +88,13 @@ public abstract class Constant implement
case Constants.CONSTANT_Class:
return new ConstantClass(file);
case Constants.CONSTANT_Fieldref:
- return new ConstantFieldref(file);
case Constants.CONSTANT_Methodref:
- return new ConstantMethodref(file);
case Constants.CONSTANT_InterfaceMethodref:
- return new ConstantInterfaceMethodref(file);
+ 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:
@@ -114,15 +104,19 @@ public abstract class Constant implement
case Constants.CONSTANT_Double:
return new ConstantDouble(file);
case Constants.CONSTANT_NameAndType:
- return new ConstantNameAndType(file);
+ Utility.swallowConstantNameAndType(file);
+ return null;
case Constants.CONSTANT_Utf8:
return ConstantUtf8.getInstance(file);
case Constants.CONSTANT_MethodHandle:
- return new ConstantMethodHandle(file);
+ Utility.swallowConstantMethodHandle(file);
+ return null;
case Constants.CONSTANT_MethodType:
- return new ConstantMethodType(file);
+ Utility.swallowConstantMethodType(file);
+ return null;
case Constants.CONSTANT_InvokeDynamic:
- return new ConstantInvokeDynamic(file);
+ Utility.swallowConstantInvokeDynamic(file);
+ return null;
default:
throw new ClassFormatException("Invalid byte tag in constant
pool: " + b);
}
Modified:
tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/ConstantPool.java
URL:
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/ConstantPool.java?rev=1624533&r1=1624532&r2=1624533&view=diff
==============================================================================
---
tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/ConstantPool.java
(original)
+++
tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/ConstantPool.java
Fri Sep 12 13:01:37 2014
@@ -34,7 +34,7 @@ import org.apache.tomcat.util.bcel.Const
* @see Constant
* @author <A HREF="mailto:[email protected]">M. Dahm</A>
*/
-public class ConstantPool implements Cloneable, Serializable {
+public class ConstantPool implements Serializable {
private static final long serialVersionUID = -6765503791185687014L;
private int constant_pool_count;
@@ -49,7 +49,6 @@ public class ConstantPool implements Clo
* @throws ClassFormatException
*/
ConstantPool(DataInputStream file) throws IOException,
ClassFormatException {
- byte tag;
constant_pool_count = file.readUnsignedShort();
constant_pool = new Constant[constant_pool_count];
/* constant_pool[0] is unused by the compiler and may be used freely
@@ -64,9 +63,11 @@ public class ConstantPool implements Clo
*
* Thus we have to increment the index counter.
*/
- tag = constant_pool[i].getTag();
- if ((tag == Constants.CONSTANT_Double) || (tag ==
Constants.CONSTANT_Long)) {
- i++;
+ if (constant_pool[i] != null) {
+ byte tag = constant_pool[i].getTag();
+ if ((tag == Constants.CONSTANT_Double) || (tag ==
Constants.CONSTANT_Long)) {
+ i++;
+ }
}
}
}
@@ -88,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;
@@ -108,19 +104,6 @@ public class ConstantPool implements Clo
case Constants.CONSTANT_Integer:
str = String.valueOf(((ConstantInteger) c).getBytes());
break;
- case Constants.CONSTANT_NameAndType:
- str = (constantToString(((ConstantNameAndType)
c).getNameIndex(),
- Constants.CONSTANT_Utf8)
- + " " + constantToString(((ConstantNameAndType)
c).getSignatureIndex(),
- Constants.CONSTANT_Utf8));
- break;
- case Constants.CONSTANT_InterfaceMethodref:
- case Constants.CONSTANT_Methodref:
- case Constants.CONSTANT_Fieldref:
- str = (constantToString(((ConstantCP) c).getClassIndex(),
Constants.CONSTANT_Class)
- + "." + constantToString(((ConstantCP)
c).getNameAndTypeIndex(),
- Constants.CONSTANT_NameAndType));
- break;
default: // Never reached
throw new RuntimeException("Unknown constant type " + tag);
}
@@ -128,35 +111,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.
@@ -221,30 +175,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/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/FieldOrMethod.java
URL:
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/FieldOrMethod.java?rev=1624533&r1=1624532&r2=1624533&view=diff
==============================================================================
---
tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/FieldOrMethod.java
(original)
+++
tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/FieldOrMethod.java
Fri Sep 12 13:01:37 2014
@@ -28,7 +28,7 @@ import org.apache.tomcat.util.bcel.util.
*
* @author <A HREF="mailto:[email protected]">M. Dahm</A>
*/
-public class FieldOrMethod extends AccessFlags implements Cloneable {
+public class FieldOrMethod extends AccessFlags {
private static final long serialVersionUID = -3383525930205542157L;
private static BCELComparator _cmp = new BCELComparator() {
Modified:
tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/JavaClass.java
URL:
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/JavaClass.java?rev=1624533&r1=1624532&r2=1624533&view=diff
==============================================================================
---
tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/JavaClass.java
(original)
+++
tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/JavaClass.java
Fri Sep 12 13:01:37 2014
@@ -33,8 +33,7 @@ import org.apache.tomcat.util.bcel.util.
* @author <A HREF="mailto:[email protected]">M. Dahm</A>
*/
-public class JavaClass extends AccessFlags
- implements Cloneable, Comparable<JavaClass> {
+public class JavaClass extends AccessFlags implements Comparable<JavaClass> {
private static final long serialVersionUID = 7029227708237523236L;
private String class_name;
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=1624533&r1=1624532&r2=1624533&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 13:01:37 2014
@@ -238,6 +238,13 @@ final class Utility {
}
}
+ static void swallowLocalVariableTypeTable(DataInput file) throws
IOException {
+ int local_variable_type_table_length = (file.readUnsignedShort());
+ for(int i=0; i < local_variable_type_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++) {
@@ -255,4 +262,37 @@ final class Utility {
file.readUnsignedShort(); // Unused pmg_index
file.readUnsignedShort(); // Unused pmg_class_index
}
+
+ static void swallowEnclosingMethod(DataInput file) throws IOException {
+ file.readUnsignedShort(); // Unused class index
+ file.readUnsignedShort(); // Unused method index
+ }
+
+ static void swallowConstantCP(DataInput file) throws IOException {
+ file.readUnsignedShort(); // Unused class index
+ file.readUnsignedShort(); // Unused name and type index
+ }
+
+ static void swallowConstantMethodHandle(DataInput file) throws IOException
{
+ file.readUnsignedByte(); // Unused reference_kind
+ file.readUnsignedShort(); // Unused reference_index
+ }
+
+ static void swallowConstantString(DataInput file) throws IOException {
+ file.readUnsignedShort(); // Unused string index
+ }
+
+ static void swallowConstantNameAndType(DataInput file) throws IOException {
+ file.readUnsignedShort(); // Unused name index
+ file.readUnsignedShort(); // Unused signature index
+ }
+
+ static void swallowConstantMethodType(DataInput file) throws IOException {
+ file.readUnsignedShort(); // Unused descriptor_index
+ }
+
+ static void swallowConstantInvokeDynamic(DataInput file) throws
IOException {
+ file.readUnsignedShort(); // Unused bootstrap_method_attr_index
+ file.readUnsignedShort(); // Unused name_and_type_index
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]