Author: markt
Date: Fri Sep 12 12:42:21 2014
New Revision: 1624523
URL: http://svn.apache.org/r1624523
Log:
Port more simplifications from trunk
Removed:
tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/StackMapEntry.java
tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/StackMapTableEntry.java
tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/StackMapType.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/JavaClass.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/Utility.java
Propchange: tomcat/tc7.0.x/trunk/
------------------------------------------------------------------------------
Merged /tomcat/trunk:r1540396-1540398,1540400-1540402
Propchange: tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/
------------------------------------------------------------------------------
Merged
/tomcat/trunk/java/org/apache/tomcat/util/bcel:r1540396-1540398,1540400-1540402
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=1624523&r1=1624522&r2=1624523&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:42:21 2014
@@ -112,19 +112,12 @@ public class JavaClass extends AccessFla
}
- /**
- * @return Attributes of the class.
- */
- public Attribute[] getAttributes() {
- return attributes;
- }
-
public AnnotationEntry[] getAnnotationEntries() {
if (annotationsOutOfDate) {
// Find attributes that contain annotation data
- Attribute[] attrs = getAttributes();
List<AnnotationEntry> accumulatedAnnotations = new
ArrayList<AnnotationEntry>();
- for (Attribute attribute : attrs) {
+ for (int i = 0; i < attributes.length; i++) {
+ Attribute attribute = attributes[i];
if (attribute instanceof Annotations) {
Annotations runtimeAnnotations = (Annotations)attribute;
for(int j = 0; j <
runtimeAnnotations.getAnnotationEntries().length; j++)
Modified:
tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/StackMap.java
URL:
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/StackMap.java?rev=1624523&r1=1624522&r2=1624523&view=diff
==============================================================================
---
tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/StackMap.java
(original)
+++
tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/StackMap.java
Fri Sep 12 12:42:21 2014
@@ -31,27 +31,10 @@ import java.io.IOException;
*
* @author <A HREF="mailto:[email protected]">M. Dahm</A>
* @see Code
- * @see StackMapEntry
- * @see StackMapType
*/
public final class StackMap extends Attribute {
private static final long serialVersionUID = 264958819110329590L;
- private int map_length;
- private StackMapEntry[] map; // Table of stack map entries
-
-
- /*
- * @param name_index Index of name
- * @param length Content length in bytes
- * @param map Table of stack map entries
- * @param constant_pool Array of constants
- */
- public StackMap(int name_index, int length, StackMapEntry[] map,
ConstantPool constant_pool) {
- super(name_index, length, constant_pool);
- setStackMap(map);
- }
-
/**
* Construct object from file stream.
@@ -63,20 +46,10 @@ public final class StackMap extends Attr
*/
StackMap(int name_index, int length, DataInputStream file, ConstantPool
constant_pool)
throws IOException {
- this(name_index, length, (StackMapEntry[]) null, constant_pool);
- map_length = file.readUnsignedShort();
- map = new StackMapEntry[map_length];
+ super(name_index, length, constant_pool);
+ int map_length = file.readUnsignedShort();
for (int i = 0; i < map_length; i++) {
- map[i] = new StackMapEntry(file);
+ Utility.swallowStackMapEntry(file);
}
}
-
-
- /**
- * @param map Array of stack map entries
- */
- public final void setStackMap( StackMapEntry[] map ) {
- this.map = map;
- map_length = (map == null) ? 0 : map.length;
- }
}
Modified:
tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/StackMapTable.java
URL:
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/StackMapTable.java?rev=1624523&r1=1624522&r2=1624523&view=diff
==============================================================================
---
tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/StackMapTable.java
(original)
+++
tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/StackMapTable.java
Fri Sep 12 12:42:21 2014
@@ -31,14 +31,10 @@ import java.io.IOException;
*
* @author <A HREF="mailto:[email protected]">M. Dahm</A>
* @see Code
- * @see StackMapEntry
- * @see StackMapType
*/
public final class StackMapTable extends Attribute {
private static final long serialVersionUID = -2931695092763099621L;
- private final int map_length;
- private final StackMapTableEntry[] map; // Table of stack map entries
/**
@@ -52,10 +48,9 @@ public final class StackMapTable extends
StackMapTable(int name_index, int length, DataInputStream file,
ConstantPool constant_pool)
throws IOException {
super(name_index, length, constant_pool);
- map_length = file.readUnsignedShort();
- map = new StackMapTableEntry[map_length];
+ int map_length = file.readUnsignedShort();
for (int i = 0; i < map_length; i++) {
- map[i] = new StackMapTableEntry(file);
+ Utility.swallowStackMapTableEntry(file);
}
}
}
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=1624523&r1=1624522&r2=1624523&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:42:21 2014
@@ -18,8 +18,11 @@
package org.apache.tomcat.util.bcel.classfile;
import java.io.DataInput;
+import java.io.DataInputStream;
import java.io.IOException;
+import org.apache.tomcat.util.bcel.Constants;
+
/**
* Utility functions that do not really belong to any class in particular.
@@ -109,16 +112,14 @@ public abstract class Utility {
}
}
- protected static void swallowCodeException(DataInput file)
- throws IOException {
+ protected 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 {
+ protected 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
@@ -130,12 +131,74 @@ public abstract class Utility {
file.readUnsignedShort(); // Unused line_number
}
- protected static void swallowLocalVariable(DataInput file)
- throws IOException {
+ protected static void swallowLocalVariable(DataInput file) throws
IOException {
file.readUnsignedShort(); // Unused start_pc
file.readUnsignedShort(); // Unused length
file.readUnsignedShort(); // Unused name_index
file.readUnsignedShort(); // Unused signature_index
file.readUnsignedShort(); // Unused index
}
+
+ protected 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);
+ }
+ // Check to see if type has an index
+ if ((type == Constants.ITEM_Object) || (type ==
Constants.ITEM_NewObject)) {
+ file.readShort(); // Unused index
+ }
+ }
+
+ protected 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++) {
+ Utility.swallowStackMapType(file);
+ }
+ int number_of_stack_items = file.readShort();
+ for (int i = 0; i < number_of_stack_items; i++) {
+ Utility.swallowStackMapType(file);
+ }
+ }
+
+ protected static void swallowStackMapTableEntry(DataInputStream file)
throws IOException {
+ int frame_type = file.read();
+
+ if (frame_type >= Constants.SAME_FRAME && frame_type <=
Constants.SAME_FRAME_MAX) {
+ // NO-OP
+ } else if (frame_type >= Constants.SAME_LOCALS_1_STACK_ITEM_FRAME &&
+ frame_type <= Constants.SAME_LOCALS_1_STACK_ITEM_FRAME_MAX) {
+ Utility.swallowStackMapType(file); // Unused single stack item
+ } else if (frame_type ==
Constants.SAME_LOCALS_1_STACK_ITEM_FRAME_EXTENDED) {
+ file.readShort(); // Unused byte_code_offset_delta
+ Utility.swallowStackMapType(file); // Unused single stack item
+ } else if (frame_type >= Constants.CHOP_FRAME &&
+ frame_type <= Constants.CHOP_FRAME_MAX) {
+ file.readShort(); // Unused byte_code_offset_delta
+ } else if (frame_type == Constants.SAME_FRAME_EXTENDED) {
+ file.readShort(); // Unused byte_code_offset_delta
+ } else if (frame_type >= Constants.APPEND_FRAME &&
+ frame_type <= Constants.APPEND_FRAME_MAX) {
+ file.readShort(); // Unused byte_code_offset_delta
+ int number_of_locals = frame_type - 251;
+ for (int i = 0; i < number_of_locals; i++) {
+ Utility.swallowStackMapType(file);
+ }
+ } else if (frame_type == Constants.FULL_FRAME) {
+ file.readShort(); // Unused byte_code_offset_delta
+ int number_of_locals = file.readShort();
+ for (int i = 0; i < number_of_locals; i++) {
+ Utility.swallowStackMapType(file);
+ }
+ int number_of_stack_items = file.readShort();
+ for (int i = 0; i < number_of_stack_items; i++) {
+ Utility.swallowStackMapType(file);
+ }
+ } else {
+ /* Can't happen */
+ throw new ClassFormatException (
+ "Invalid frame type found while parsing stack map table: "
+ frame_type);
+ }
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]