Author: markt
Date: Fri Sep 12 12:46:55 2014
New Revision: 1624526
URL: http://svn.apache.org/r1624526
Log:
Merge more simplification from trunk
Removed:
tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/Signature.java
tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/StackMap.java
tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/StackMapTable.java
tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/Unknown.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/ConstantPool.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:r1540403-1540410
Propchange: tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/
------------------------------------------------------------------------------
Merged /tomcat/trunk/java/org/apache/tomcat/util/bcel:r1540403-1540410
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=1624526&r1=1624525&r2=1624526&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:46:55 2014
@@ -26,7 +26,7 @@ import org.apache.tomcat.util.bcel.Const
/**
* Abstract super class for <em>Attribute</em> objects. Currently the
* <em>ConstantValue</em>, <em>SourceFile</em>, <em>Code</em>,
- * <em>Exceptiontable</em>, <em>LineNumberTable</em>,
+ * <em>ExceptionTable</em>, <em>LineNumberTable</em>,
* <em>LocalVariableTable</em>, <em>InnerClasses</em> and
* <em>Synthetic</em> attributes are supported. The <em>Unknown</em>
* attribute stands for non-standard-attributes.
@@ -35,14 +35,12 @@ import org.apache.tomcat.util.bcel.Const
* @see ConstantValue
* @see SourceFile
* @see Code
- * @see Unknown
* @see ExceptionTable
* @see LineNumberTable
* @see LocalVariableTable
* @see InnerClasses
* @see Synthetic
* @see Deprecated
- * @see Signature
*/
public abstract class Attribute implements Cloneable, Serializable
{
@@ -102,7 +100,8 @@ public abstract class Attribute implemen
switch (tag)
{
case Constants.ATTR_UNKNOWN:
- return new Unknown(name_index, length, file, constant_pool);
+ Utility.swallowUnknownAttribute(file, length);
+ return null;
case Constants.ATTR_CONSTANT_VALUE:
return new ConstantValue(name_index, length, file, constant_pool);
case Constants.ATTR_SOURCE_FILE:
@@ -125,9 +124,11 @@ public abstract class Attribute implemen
case Constants.ATTR_PMG:
return new PMGClass(name_index, length, file, constant_pool);
case Constants.ATTR_SIGNATURE:
- return new Signature(name_index, length, file, constant_pool);
+ Utility.swallowSignature(file);
+ return null;
case Constants.ATTR_STACK_MAP:
- return new StackMap(name_index, length, file, constant_pool);
+ Utility.swallowStackMap(file);
+ return null;
case Constants.ATTR_RUNTIME_VISIBLE_ANNOTATIONS:
return new RuntimeVisibleAnnotations(name_index, length, file,
constant_pool);
@@ -149,7 +150,8 @@ public abstract class Attribute implemen
case Constants.ATTR_ENCLOSING_METHOD:
return new EnclosingMethod(name_index, length, file,
constant_pool);
case Constants.ATTR_STACK_MAP_TABLE:
- return new StackMapTable(name_index, length, file, constant_pool);
+ Utility.swallowStackMapTable(file);
+ return null;
case Constants.ATTR_BOOTSTRAP_METHODS:
Utility.swallowBootstrapMethods(file);
return null;
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=1624526&r1=1624525&r2=1624526&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 12:46:55 2014
@@ -86,7 +86,7 @@ public class ConstantPool implements Clo
case Constants.CONSTANT_Class:
i = ((ConstantClass) c).getNameIndex();
c = getConstant(i, Constants.CONSTANT_Utf8);
- str = Utility.compactClassName(((ConstantUtf8) c).getBytes(),
false);
+ str = Utility.compactClassName(((ConstantUtf8) c).getBytes());
break;
case Constants.CONSTANT_String:
i = ((ConstantString) c).getStringIndex();
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=1624526&r1=1624525&r2=1624526&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 12:46:55 2014
@@ -95,19 +95,19 @@ public class JavaClass extends AccessFla
* `ConstPool.getConstant' method.
*/
class_name = constant_pool.getConstantString(class_name_index,
Constants.CONSTANT_Class);
- class_name = Utility.compactClassName(class_name, false);
+ class_name = Utility.compactClassName(class_name);
if (superclass_name_index > 0) {
// May be zero -> class is java.lang.Object
superclass_name =
constant_pool.getConstantString(superclass_name_index,
Constants.CONSTANT_Class);
- superclass_name = Utility.compactClassName(superclass_name, false);
+ superclass_name = Utility.compactClassName(superclass_name);
} else {
superclass_name = "java.lang.Object";
}
interface_names = new String[interfaces.length];
for (int i = 0; i < interfaces.length; i++) {
String str = constant_pool.getConstantString(interfaces[i],
Constants.CONSTANT_Class);
- interface_names[i] = Utility.compactClassName(str, false);
+ interface_names[i] = Utility.compactClassName(str);
}
}
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=1624526&r1=1624525&r2=1624526&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:46:55 2014
@@ -23,13 +23,16 @@ import java.io.IOException;
import org.apache.tomcat.util.bcel.Constants;
-
/**
* Utility functions that do not really belong to any class in particular.
*
* @author <A HREF="mailto:[email protected]">M. Dahm</A>
*/
-public abstract class Utility {
+final class Utility {
+
+ private Utility() {
+ // Hide default constructor
+ }
/**
* Shorten long class name <em>str</em>, i.e., chop off the
<em>prefix</em>,
@@ -38,59 +41,10 @@ public abstract class Utility {
* Slashes <em>/</em> are converted to dots <em>.</em>.
*
* @param str The long class name
- * @param prefix The prefix the get rid off
- * @param chopit Flag that determines whether chopping is executed or not
- * @return Compacted class name
- */
- public static final String compactClassName( String str, String prefix,
boolean chopit ) {
- int len = prefix.length();
- str = str.replace('/', '.'); // Is `/' on all systems, even DOS
- if (chopit) {
- // If string starts with `prefix' and contains no further dots
- if (str.startsWith(prefix) && (str.substring(len).indexOf('.') ==
-1)) {
- str = str.substring(len);
- }
- }
- return str;
- }
-
-
- /**
- * Shorten long class names, <em>java/lang/String</em> becomes
- * <em>java.lang.String</em>,
- * e.g.. If <em>chopit</em> is <em>true</em> the prefix <em>java.lang</em>
- * is also removed.
- *
- * @param str The long class name
- * @param chopit Flag that determines whether chopping is executed or not
* @return Compacted class name
*/
- public static final String compactClassName( String str, boolean chopit ) {
- return compactClassName(str, "java.lang.", chopit);
- }
-
-
- // A-Z, g-z, _, $
- private static final int FREE_CHARS = 48;
- static int[] CHAR_MAP = new int[FREE_CHARS];
- static int[] MAP_CHAR = new int[256]; // Reverse map
- static {
- int j = 0;
- for (int i = 'A'; i <= 'Z'; i++) {
- CHAR_MAP[j] = i;
- MAP_CHAR[i] = j;
- j++;
- }
- for (int i = 'g'; i <= 'z'; i++) {
- CHAR_MAP[j] = i;
- MAP_CHAR[i] = j;
- j++;
- }
- CHAR_MAP[j] = '$';
- MAP_CHAR['$'] = j;
- j++;
- CHAR_MAP[j] = '_';
- MAP_CHAR['_'] = j;
+ static String compactClassName(String str) {
+ return str.replace('/', '.'); // Is `/' on all systems, even DOS
}
static void swallowBootstrapMethods(DataInput file) throws IOException {
@@ -112,26 +66,26 @@ public abstract class Utility {
}
}
- protected static void swallowCodeException(DataInput file) throws
IOException {
+ 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
{
+ 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
file.readUnsignedShort(); // Unused inner_access_flags
}
- protected static void swallowLineNumber(DataInput file) throws IOException
{
+ static void swallowLineNumber(DataInput file) throws IOException {
file.readUnsignedShort(); // Unused start_pc
file.readUnsignedShort(); // Unused line_number
}
- protected static void swallowLocalVariable(DataInput file) throws
IOException {
+ static void swallowLocalVariable(DataInput file) throws IOException {
file.readUnsignedShort(); // Unused start_pc
file.readUnsignedShort(); // Unused length
file.readUnsignedShort(); // Unused name_index
@@ -139,7 +93,21 @@ public abstract class Utility {
file.readUnsignedShort(); // Unused index
}
- protected static void swallowStackMapType(DataInput file) throws
IOException {
+ static void swallowStackMap(DataInput file) throws IOException {
+ int map_length = file.readUnsignedShort();
+ for (int i = 0; i < map_length; i++) {
+ Utility.swallowStackMapEntry(file);
+ }
+ }
+
+ static void swallowStackMapTable(DataInputStream file) throws IOException {
+ int map_length = file.readUnsignedShort();
+ for (int i = 0; i < map_length; i++) {
+ Utility.swallowStackMapTableEntry(file);
+ }
+ }
+
+ 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);
@@ -150,7 +118,7 @@ public abstract class Utility {
}
}
- protected static void swallowStackMapEntry(DataInput file) throws
IOException {
+ static void swallowStackMapEntry(DataInput file) throws IOException {
file.readShort(); // Unused byte_code_offset
int number_of_locals = file.readShort();
for (int i = 0; i < number_of_locals; i++) {
@@ -162,7 +130,7 @@ public abstract class Utility {
}
}
- protected static void swallowStackMapTableEntry(DataInputStream file)
throws IOException {
+ static void swallowStackMapTableEntry(DataInputStream file) throws
IOException {
int frame_type = file.read();
if (frame_type >= Constants.SAME_FRAME && frame_type <=
Constants.SAME_FRAME_MAX) {
@@ -201,4 +169,15 @@ public abstract class Utility {
"Invalid frame type found while parsing stack map table: "
+ frame_type);
}
}
+
+ static void swallowUnknownAttribute(DataInput file, int length) throws
IOException {
+ if (length > 0) {
+ byte[] bytes = new byte[length];
+ file.readFully(bytes);
+ }
+ }
+
+ static void swallowSignature(DataInput file) throws IOException {
+ file.readUnsignedShort(); // Unused signature_index
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]