|
|
2877c9c |
|
|
|
2877c9c |
Property changes on: /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2
|
|
|
2877c9c |
___________________________________________________________________
|
|
|
2877c9c |
Name: svn:ignore
|
|
|
2877c9c |
- bin
|
|
|
2877c9c |
velocity.log
|
|
|
2877c9c |
*~
|
|
|
2877c9c |
+ bin
|
|
|
2877c9c |
velocity.log
|
|
|
2877c9c |
*~
|
|
|
2877c9c |
bcel.jar
|
|
|
2877c9c |
|
|
|
2877c9c |
|
|
|
2877c9c |
Index: /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/.classpath
|
|
|
2877c9c |
===================================================================
|
|
|
2877c9c |
--- /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/.classpath (revision 510968)
|
|
|
2877c9c |
+++ /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/.classpath (working copy)
|
|
|
2877c9c |
@@ -1,7 +1,6 @@
|
|
|
2877c9c |
|
|
|
2877c9c |
<classpath>
|
|
|
2877c9c |
<classpathentry kind="src" path="src/java"/>
|
|
|
2877c9c |
- <classpathentry kind="src" path="examples"/>
|
|
|
2877c9c |
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
|
|
2877c9c |
<classpathentry kind="output" path="eclipse"/>
|
|
|
2877c9c |
</classpath>
|
|
|
2877c9c |
Index: /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/.settings/org.eclipse.jdt.core.prefs
|
|
|
2877c9c |
===================================================================
|
|
|
2877c9c |
--- /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/.settings/org.eclipse.jdt.core.prefs (revision 510968)
|
|
|
2877c9c |
+++ /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/.settings/org.eclipse.jdt.core.prefs (working copy)
|
|
|
2877c9c |
@@ -1,12 +1,12 @@
|
|
|
2877c9c |
-#Tue Jan 24 00:19:24 EST 2006
|
|
|
2877c9c |
+#Fri Feb 23 10:19:35 EST 2007
|
|
|
2877c9c |
eclipse.preferences.version=1
|
|
|
2877c9c |
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled
|
|
|
2877c9c |
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2
|
|
|
2877c9c |
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
|
|
2877c9c |
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
|
|
|
2877c9c |
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
|
|
2877c9c |
-org.eclipse.jdt.core.compiler.compliance=1.4
|
|
|
2877c9c |
+org.eclipse.jdt.core.compiler.compliance=1.5
|
|
|
2877c9c |
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
|
|
2877c9c |
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
|
|
2877c9c |
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
|
|
2877c9c |
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning
|
|
|
2877c9c |
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
|
|
|
2877c9c |
-org.eclipse.jdt.core.compiler.source=1.3
|
|
|
2877c9c |
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
|
|
2877c9c |
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
|
|
2877c9c |
+org.eclipse.jdt.core.compiler.source=1.5
|
|
|
2877c9c |
Index: /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/build.xml
|
|
|
2877c9c |
===================================================================
|
|
|
2877c9c |
--- /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/build.xml (revision 0)
|
|
|
2877c9c |
+++ /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/build.xml (revision 0)
|
|
|
2877c9c |
@@ -0,0 +1,39 @@
|
|
|
2877c9c |
+<project name="bcel" default="jar">
|
|
|
2877c9c |
+
|
|
|
2877c9c |
+ <property name="src.dir" value="src/java"/>
|
|
|
2877c9c |
+ <property name="classes.dir" value="eclipse"/>
|
|
|
2877c9c |
+ <property name="jar.dir" value="."/>
|
|
|
2877c9c |
+
|
|
|
2877c9c |
+ <target name="jar" depends="clean,classes">
|
|
|
2877c9c |
+
|
|
|
2877c9c |
+ <jar destfile="${jar.dir}/bcel.jar" >
|
|
|
2877c9c |
+
|
|
|
2877c9c |
+ <fileset dir="${classes.dir}">
|
|
|
2877c9c |
+ <include name="**/*.class"/>
|
|
|
2877c9c |
+ </fileset>
|
|
|
2877c9c |
+ </jar>
|
|
|
2877c9c |
+ </target>
|
|
|
2877c9c |
+
|
|
|
2877c9c |
+
|
|
|
2877c9c |
+ images, html, XSL stylesheets) that need to be part of the codebase. -->
|
|
|
2877c9c |
+ <target name="classes">
|
|
|
2877c9c |
+ <mkdir dir="${classes.dir}"/>
|
|
|
2877c9c |
+
|
|
|
2877c9c |
+
|
|
|
2877c9c |
+ destdir="${classes.dir}"
|
|
|
2877c9c |
+ source="1.5"
|
|
|
2877c9c |
+ target="jsr14"
|
|
|
2877c9c |
+ deprecation="on"
|
|
|
2877c9c |
+ debug="on">
|
|
|
2877c9c |
+ </javac>
|
|
|
2877c9c |
+ </target>
|
|
|
2877c9c |
+
|
|
|
2877c9c |
+ <target name="clean">
|
|
|
2877c9c |
+ <delete file="${classes.dir}"/>
|
|
|
2877c9c |
+ <mkdir dir="${classes.dir}"/>
|
|
|
2877c9c |
+ </target>
|
|
|
2877c9c |
+
|
|
|
2877c9c |
+
|
|
|
2877c9c |
+</project>
|
|
|
2877c9c |
+
|
|
|
2877c9c |
+
|
|
|
2877c9c |
Index: /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/classfile/AbstractLocalVariableTable.java
|
|
|
2877c9c |
===================================================================
|
|
|
2877c9c |
--- /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/classfile/AbstractLocalVariableTable.java (revision 0)
|
|
|
2877c9c |
+++ /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/classfile/AbstractLocalVariableTable.java (revision 0)
|
|
|
2877c9c |
@@ -0,0 +1,187 @@
|
|
|
2877c9c |
+/*
|
|
|
2877c9c |
+ * Copyright 2000-2004 The Apache Software Foundation
|
|
|
2877c9c |
+ *
|
|
|
2877c9c |
+ * Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
2877c9c |
+ * you may not use this file except in compliance with the License.
|
|
|
2877c9c |
+ * You may obtain a copy of the License at
|
|
|
2877c9c |
+ *
|
|
|
2877c9c |
+ * http://www.apache.org/licenses/LICENSE-2.0
|
|
|
2877c9c |
+ *
|
|
|
2877c9c |
+ * Unless required by applicable law or agreed to in writing, software
|
|
|
2877c9c |
+ * distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
2877c9c |
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
2877c9c |
+ * See the License for the specific language governing permissions and
|
|
|
2877c9c |
+ * limitations under the License.
|
|
|
2877c9c |
+ *
|
|
|
2877c9c |
+ */
|
|
|
2877c9c |
+package org.apache.bcel.classfile;
|
|
|
2877c9c |
+
|
|
|
2877c9c |
+import java.io.DataInputStream;
|
|
|
2877c9c |
+import java.io.DataOutputStream;
|
|
|
2877c9c |
+import java.io.IOException;
|
|
|
2877c9c |
+import org.apache.bcel.Constants;
|
|
|
2877c9c |
+
|
|
|
2877c9c |
+/**
|
|
|
2877c9c |
+ * This class represents colection of local variables in a
|
|
|
2877c9c |
+ * method. This attribute is contained in the Code attribute.
|
|
|
2877c9c |
+ *
|
|
|
2877c9c |
+ * @version $Id: bcel.diff,v 1.1 2009/01/29 03:54:23 jjames Exp $
|
|
|
2877c9c |
+ * @author M. Dahm
|
|
|
2877c9c |
+ * @see Code
|
|
|
2877c9c |
+ * @see LocalVariable
|
|
|
2877c9c |
+ */
|
|
|
2877c9c |
+abstract public class AbstractLocalVariableTable extends Attribute {
|
|
|
2877c9c |
+
|
|
|
2877c9c |
+ private int local_variable_table_length; // Table of local
|
|
|
2877c9c |
+ private LocalVariable[] local_variable_table; // variables
|
|
|
2877c9c |
+
|
|
|
2877c9c |
+
|
|
|
2877c9c |
+ /**
|
|
|
2877c9c |
+ * Initialize from another object. Note that both objects use the same
|
|
|
2877c9c |
+ * references (shallow copy). Use copy() for a physical copy.
|
|
|
2877c9c |
+ */
|
|
|
2877c9c |
+ public AbstractLocalVariableTable(AbstractLocalVariableTable c) {
|
|
|
2877c9c |
+ this(c.getNameIndex(), c.getLength(), c.getLocalVariableTable(), c.getConstantPool());
|
|
|
2877c9c |
+ }
|
|
|
2877c9c |
+
|
|
|
2877c9c |
+
|
|
|
2877c9c |
+ /**
|
|
|
2877c9c |
+ * @param name_index Index in constant pool to `LocalVariableTable'
|
|
|
2877c9c |
+ * @param length Content length in bytes
|
|
|
2877c9c |
+ * @param local_variable_table Table of local variables
|
|
|
2877c9c |
+ * @param constant_pool Array of constants
|
|
|
2877c9c |
+ */
|
|
|
2877c9c |
+ public AbstractLocalVariableTable(int name_index, int length, LocalVariable[] local_variable_table,
|
|
|
2877c9c |
+ ConstantPool constant_pool) {
|
|
|
2877c9c |
+ super(Constants.ATTR_LOCAL_VARIABLE_TABLE, name_index, length, constant_pool);
|
|
|
2877c9c |
+ setLocalVariableTable(local_variable_table);
|
|
|
2877c9c |
+ }
|
|
|
2877c9c |
+
|
|
|
2877c9c |
+
|
|
|
2877c9c |
+ /**
|
|
|
2877c9c |
+ * Construct object from file stream.
|
|
|
2877c9c |
+ * @param name_index Index in constant pool
|
|
|
2877c9c |
+ * @param length Content length in bytes
|
|
|
2877c9c |
+ * @param file Input stream
|
|
|
2877c9c |
+ * @param constant_pool Array of constants
|
|
|
2877c9c |
+ * @throws IOException
|
|
|
2877c9c |
+ */
|
|
|
2877c9c |
+ AbstractLocalVariableTable(int name_index, int length, DataInputStream file, ConstantPool constant_pool)
|
|
|
2877c9c |
+ throws IOException {
|
|
|
2877c9c |
+ this(name_index, length, (LocalVariable[]) null, constant_pool);
|
|
|
2877c9c |
+ local_variable_table_length = (file.readUnsignedShort());
|
|
|
2877c9c |
+ local_variable_table = new LocalVariable[local_variable_table_length];
|
|
|
2877c9c |
+ for (int i = 0; i < local_variable_table_length; i++) {
|
|
|
2877c9c |
+ local_variable_table[i] = new LocalVariable(file, constant_pool);
|
|
|
2877c9c |
+ }
|
|
|
2877c9c |
+ }
|
|
|
2877c9c |
+
|
|
|
2877c9c |
+
|
|
|
2877c9c |
+
|
|
|
2877c9c |
+
|
|
|
2877c9c |
+ /**
|
|
|
2877c9c |
+ * Dump local variable table attribute to file stream in binary format.
|
|
|
2877c9c |
+ *
|
|
|
2877c9c |
+ * @param file Output file stream
|
|
|
2877c9c |
+ * @throws IOException
|
|
|
2877c9c |
+ */
|
|
|
2877c9c |
+ public final void dump( DataOutputStream file ) throws IOException {
|
|
|
2877c9c |
+ super.dump(file);
|
|
|
2877c9c |
+ file.writeShort(local_variable_table_length);
|
|
|
2877c9c |
+ for (int i = 0; i < local_variable_table_length; i++) {
|
|
|
2877c9c |
+ local_variable_table[i].dump(file);
|
|
|
2877c9c |
+ }
|
|
|
2877c9c |
+ }
|
|
|
2877c9c |
+
|
|
|
2877c9c |
+
|
|
|
2877c9c |
+ /**
|
|
|
2877c9c |
+ * @return Array of local variables of method.
|
|
|
2877c9c |
+ */
|
|
|
2877c9c |
+ public final LocalVariable[] getLocalVariableTable() {
|
|
|
2877c9c |
+ return local_variable_table;
|
|
|
2877c9c |
+ }
|
|
|
2877c9c |
+
|
|
|
2877c9c |
+
|
|
|
2877c9c |
+ /**
|
|
|
2877c9c |
+ * @return first matching variable using index
|
|
|
2877c9c |
+ *
|
|
|
2877c9c |
+ * @param index the variable slot
|
|
|
2877c9c |
+ *
|
|
|
2877c9c |
+ * @return the first LocalVariable that matches the slot or null if not found
|
|
|
2877c9c |
+ *
|
|
|
2877c9c |
+ * @deprecated since 5.2 because multiple variables can share the
|
|
|
2877c9c |
+ * same slot, use getLocalVariable(int index, int pc) instead.
|
|
|
2877c9c |
+ */
|
|
|
2877c9c |
+ public final LocalVariable getLocalVariable( int index ) {
|
|
|
2877c9c |
+ for (int i = 0; i < local_variable_table_length; i++) {
|
|
|
2877c9c |
+ if (local_variable_table[i].getIndex() == index) {
|
|
|
2877c9c |
+ return local_variable_table[i];
|
|
|
2877c9c |
+ }
|
|
|
2877c9c |
+ }
|
|
|
2877c9c |
+ return null;
|
|
|
2877c9c |
+ }
|
|
|
2877c9c |
+
|
|
|
2877c9c |
+
|
|
|
2877c9c |
+ /**
|
|
|
2877c9c |
+ * @return matching variable using index when variable is used at supplied pc
|
|
|
2877c9c |
+ *
|
|
|
2877c9c |
+ * @param index the variable slot
|
|
|
2877c9c |
+ * @param pc the current pc that this variable is alive
|
|
|
2877c9c |
+ *
|
|
|
2877c9c |
+ * @return the LocalVariable that matches or null if not found
|
|
|
2877c9c |
+ */
|
|
|
2877c9c |
+ public final LocalVariable getLocalVariable( int index, int pc ) {
|
|
|
2877c9c |
+ for (int i = 0; i < local_variable_table_length; i++) {
|
|
|
2877c9c |
+ if (local_variable_table[i].getIndex() == index) {
|
|
|
2877c9c |
+ int start_pc = local_variable_table[i].getStartPC();
|
|
|
2877c9c |
+ int end_pc = start_pc + local_variable_table[i].getLength();
|
|
|
2877c9c |
+ if ((pc >= start_pc) && (pc < end_pc)) {
|
|
|
2877c9c |
+ return local_variable_table[i];
|
|
|
2877c9c |
+ }
|
|
|
2877c9c |
+ }
|
|
|
2877c9c |
+ }
|
|
|
2877c9c |
+ return null;
|
|
|
2877c9c |
+ }
|
|
|
2877c9c |
+
|
|
|
2877c9c |
+
|
|
|
2877c9c |
+ public final void setLocalVariableTable( LocalVariable[] local_variable_table ) {
|
|
|
2877c9c |
+ this.local_variable_table = local_variable_table;
|
|
|
2877c9c |
+ local_variable_table_length = (local_variable_table == null)
|
|
|
2877c9c |
+ ? 0
|
|
|
2877c9c |
+ : local_variable_table.length;
|
|
|
2877c9c |
+ }
|
|
|
2877c9c |
+
|
|
|
2877c9c |
+
|
|
|
2877c9c |
+ /**
|
|
|
2877c9c |
+ * @return String representation.
|
|
|
2877c9c |
+ */
|
|
|
2877c9c |
+ public final String toString() {
|
|
|
2877c9c |
+ StringBuffer buf = new StringBuffer("");
|
|
|
2877c9c |
+ for (int i = 0; i < local_variable_table_length; i++) {
|
|
|
2877c9c |
+ buf.append(local_variable_table[i].toString());
|
|
|
2877c9c |
+ if (i < local_variable_table_length - 1) {
|
|
|
2877c9c |
+ buf.append('\n');
|
|
|
2877c9c |
+ }
|
|
|
2877c9c |
+ }
|
|
|
2877c9c |
+ return buf.toString();
|
|
|
2877c9c |
+ }
|
|
|
2877c9c |
+
|
|
|
2877c9c |
+
|
|
|
2877c9c |
+ /**
|
|
|
2877c9c |
+ * @return deep copy of this attribute
|
|
|
2877c9c |
+ */
|
|
|
2877c9c |
+ public Attribute copy( ConstantPool _constant_pool ) {
|
|
|
2877c9c |
+ AbstractLocalVariableTable c = (AbstractLocalVariableTable) clone();
|
|
|
2877c9c |
+ c.local_variable_table = new LocalVariable[local_variable_table_length];
|
|
|
2877c9c |
+ for (int i = 0; i < local_variable_table_length; i++) {
|
|
|
2877c9c |
+ c.local_variable_table[i] = local_variable_table[i].copy();
|
|
|
2877c9c |
+ }
|
|
|
2877c9c |
+ c.constant_pool = _constant_pool;
|
|
|
2877c9c |
+ return c;
|
|
|
2877c9c |
+ }
|
|
|
2877c9c |
+
|
|
|
2877c9c |
+
|
|
|
2877c9c |
+ public final int getTableLength() {
|
|
|
2877c9c |
+ return local_variable_table_length;
|
|
|
2877c9c |
+ }
|
|
|
2877c9c |
+}
|
|
|
2877c9c |
Index: /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/classfile/Attribute.java
|
|
|
2877c9c |
===================================================================
|
|
|
2877c9c |
--- /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/classfile/Attribute.java (revision 510968)
|
|
|
2877c9c |
+++ /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/classfile/Attribute.java (working copy)
|
|
|
2877c9c |
@@ -159,7 +159,9 @@
|
|
|
2877c9c |
return new LineNumberTable(name_index, length, file, constant_pool);
|
|
|
2877c9c |
case Constants.ATTR_LOCAL_VARIABLE_TABLE:
|
|
|
2877c9c |
return new LocalVariableTable(name_index, length, file, constant_pool);
|
|
|
2877c9c |
- case Constants.ATTR_INNER_CLASSES:
|
|
|
2877c9c |
+ case Constants.ATTR_LOCAL_VARIABLE_TYPE_TABLE:
|
|
|
2877c9c |
+ return new LocalVariableTypeTable(name_index, length, file, constant_pool);
|
|
|
2877c9c |
+ case Constants.ATTR_INNER_CLASSES:
|
|
|
2877c9c |
return new InnerClasses(name_index, length, file, constant_pool);
|
|
|
2877c9c |
case Constants.ATTR_SYNTHETIC:
|
|
|
2877c9c |
return new Synthetic(name_index, length, file, constant_pool);
|
|
|
2877c9c |
Index: /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/classfile/Constant.java
|
|
|
2877c9c |
===================================================================
|
|
|
2877c9c |
--- /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/classfile/Constant.java (revision 510968)
|
|
|
2877c9c |
+++ /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/classfile/Constant.java (working copy)
|
|
|
2877c9c |
@@ -141,7 +141,7 @@
|
|
|
2877c9c |
case Constants.CONSTANT_NameAndType:
|
|
|
2877c9c |
return new ConstantNameAndType(file);
|
|
|
2877c9c |
case Constants.CONSTANT_Utf8:
|
|
|
2877c9c |
- return new ConstantUtf8(file);
|
|
|
2877c9c |
+ return ConstantUtf8.getInstance(file);
|
|
|
2877c9c |
default:
|
|
|
2877c9c |
throw new ClassFormatException("Invalid byte tag in constant pool: " + b);
|
|
|
2877c9c |
}
|
|
|
2877c9c |
Index: /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/classfile/ConstantUtf8.java
|
|
|
2877c9c |
===================================================================
|
|
|
2877c9c |
--- /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/classfile/ConstantUtf8.java (revision 510968)
|
|
|
2877c9c |
+++ /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/classfile/ConstantUtf8.java (working copy)
|
|
|
2877c9c |
@@ -19,7 +19,14 @@
|
|
|
2877c9c |
import java.io.DataInputStream;
|
|
|
2877c9c |
import java.io.DataOutputStream;
|
|
|
2877c9c |
import java.io.IOException;
|
|
|
2877c9c |
+import java.util.HashMap;
|
|
|
2877c9c |
+import java.util.LinkedHashMap;
|
|
|
2877c9c |
+import java.util.Map;
|
|
|
2877c9c |
+
|
|
|
2877c9c |
import org.apache.bcel.Constants;
|
|
|
2877c9c |
+import org.apache.bcel.generic.ObjectType;
|
|
|
2877c9c |
+
|
|
|
2877c9c |
+import com.sun.org.apache.xerces.internal.impl.io.UTF8Reader;
|
|
|
2877c9c |
|
|
|
2877c9c |
/**
|
|
|
2877c9c |
* This class is derived from the abstract
|
|
|
2877c9c |
@@ -32,9 +39,60 @@
|
|
|
2877c9c |
*/
|
|
|
2877c9c |
public final class ConstantUtf8 extends Constant {
|
|
|
2877c9c |
|
|
|
2877c9c |
- private String bytes;
|
|
|
2877c9c |
+ private final String bytes;
|
|
|
2877c9c |
+
|
|
|
2877c9c |
+ private static final int MAX_CACHE_ENTRIES = 20000;
|
|
|
2877c9c |
+ private static final int INITIAL_CACHE_CAPACITY = (int)(MAX_CACHE_ENTRIES/0.75);
|
|
|
2877c9c |
+ private static HashMap<String, ConstantUtf8> cache;
|
|
|
2877c9c |
+ private static int considered = 0;
|
|
|
2877c9c |
+ private static int hits = 0;
|
|
|
2877c9c |
+ private static int skipped = 0;
|
|
|
2877c9c |
+ private static int created = 0;
|
|
|
2877c9c |
+ final static boolean BCEL_STATISTICS = Boolean.getBoolean("bcel.statistics");
|
|
|
2877c9c |
+ final static boolean BCEL_DONT_CACHE = Boolean.getBoolean("bcel.dontCache");
|
|
|
2877c9c |
+
|
|
|
2877c9c |
+ static {
|
|
|
2877c9c |
+ if (BCEL_STATISTICS)
|
|
|
2877c9c |
+ Runtime.getRuntime().addShutdownHook(new Thread() {
|
|
|
2877c9c |
+ public void run() {
|
|
|
2877c9c |
+ System.err.println("Cache hit " + hits + "/" + considered +", "
|
|
|
2877c9c |
+ + skipped + " skipped");
|
|
|
2877c9c |
+ System.err.println("Total of " + created + " ConstantUtf8 objects created");
|
|
|
2877c9c |
+ }
|
|
|
2877c9c |
+ });
|
|
|
2877c9c |
+ }
|
|
|
2877c9c |
+ public static synchronized ConstantUtf8 getCachedInstance(String s) {
|
|
|
2877c9c |
+ if (BCEL_DONT_CACHE || s.length() > 200) {
|
|
|
2877c9c |
+ skipped++;
|
|
|
2877c9c |
+ return new ConstantUtf8(s);
|
|
|
2877c9c |
+ }
|
|
|
2877c9c |
+ considered++;
|
|
|
2877c9c |
+ if (cache == null) {
|
|
|
2877c9c |
+ cache = new LinkedHashMap<String, ConstantUtf8>(INITIAL_CACHE_CAPACITY, 0.75f, true) {
|
|
|
2877c9c |
+
|
|
|
2877c9c |
+ protected boolean removeEldestEntry(Map.Entry eldest) {
|
|
|
2877c9c |
+ return size() > MAX_CACHE_ENTRIES;
|
|
|
2877c9c |
+ }
|
|
|
2877c9c |
+
|
|
|
2877c9c |
+ };
|
|
|
2877c9c |
+ }
|
|
|
2877c9c |
+ ConstantUtf8 result = cache.get(s);
|
|
|
2877c9c |
+ if (result != null) {
|
|
|
2877c9c |
+ hits++;
|
|
|
2877c9c |
+ return result;
|
|
|
2877c9c |
+ }
|
|
|
2877c9c |
+ result = new ConstantUtf8(s);
|
|
|
2877c9c |
+ cache.put(s, result);
|
|
|
2877c9c |
+ return result;
|
|
|
2877c9c |
+ }
|
|
|
2877c9c |
|
|
|
2877c9c |
+ public static ConstantUtf8 getInstance(String s) {
|
|
|
2877c9c |
+ return getCachedInstance(s);
|
|
|
2877c9c |
+ }
|
|
|
2877c9c |
|
|
|
2877c9c |
+ public static ConstantUtf8 getInstance (DataInputStream file) throws IOException {
|
|
|
2877c9c |
+ return getInstance(file.readUTF());
|
|
|
2877c9c |
+ }
|
|
|
2877c9c |
/**
|
|
|
2877c9c |
* Initialize from another object.
|
|
|
2877c9c |
*/
|
|
|
2877c9c |
@@ -52,6 +110,7 @@
|
|
|
2877c9c |
ConstantUtf8(DataInputStream file) throws IOException {
|
|
|
2877c9c |
super(Constants.CONSTANT_Utf8);
|
|
|
2877c9c |
bytes = file.readUTF();
|
|
|
2877c9c |
+ created++;
|
|
|
2877c9c |
}
|
|
|
2877c9c |
|
|
|
2877c9c |
|
|
|
2877c9c |
@@ -64,6 +123,7 @@
|
|
|
2877c9c |
throw new IllegalArgumentException("bytes must not be null!");
|
|
|
2877c9c |
}
|
|
|
2877c9c |
this.bytes = bytes;
|
|
|
2877c9c |
+ created++;
|
|
|
2877c9c |
}
|
|
|
2877c9c |
|
|
|
2877c9c |
|
|
|
2877c9c |
@@ -101,9 +161,10 @@
|
|
|
2877c9c |
|
|
|
2877c9c |
/**
|
|
|
2877c9c |
* @param bytes the raw bytes of this Utf-8
|
|
|
2877c9c |
+ * @deprecated
|
|
|
2877c9c |
*/
|
|
|
2877c9c |
public final void setBytes( String bytes ) {
|
|
|
2877c9c |
- this.bytes = bytes;
|
|
|
2877c9c |
+ throw new UnsupportedOperationException();
|
|
|
2877c9c |
}
|
|
|
2877c9c |
|
|
|
2877c9c |
|
|
|
2877c9c |
Index: /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/classfile/DescendingVisitor.java
|
|
|
2877c9c |
===================================================================
|
|
|
2877c9c |
--- /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/classfile/DescendingVisitor.java (revision 510968)
|
|
|
2877c9c |
+++ /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/classfile/DescendingVisitor.java (working copy)
|
|
|
2877c9c |
@@ -185,6 +185,9 @@
|
|
|
2877c9c |
}
|
|
|
2877c9c |
stack.pop();
|
|
|
2877c9c |
}
|
|
|
2877c9c |
+ public void visitLocalVariableTypeTable( LocalVariableTypeTable table ) {
|
|
|
2877c9c |
+
|
|
|
2877c9c |
+ }
|
|
|
2877c9c |
|
|
|
2877c9c |
|
|
|
2877c9c |
public void visitStackMap( StackMap table ) {
|
|
|
2877c9c |
Index: /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/classfile/EmptyVisitor.java
|
|
|
2877c9c |
===================================================================
|
|
|
2877c9c |
--- /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/classfile/EmptyVisitor.java (revision 510968)
|
|
|
2877c9c |
+++ /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/classfile/EmptyVisitor.java (working copy)
|
|
|
2877c9c |
@@ -158,4 +158,10 @@
|
|
|
2877c9c |
|
|
|
2877c9c |
public void visitStackMapEntry( StackMapEntry obj ) {
|
|
|
2877c9c |
}
|
|
|
2877c9c |
+
|
|
|
2877c9c |
+
|
|
|
2877c9c |
+ public void visitLocalVariableTypeTable(LocalVariableTypeTable obj) {
|
|
|
2877c9c |
+ // TODO Auto-generated method stub
|
|
|
2877c9c |
+
|
|
|
2877c9c |
+ }
|
|
|
2877c9c |
}
|
|
|
2877c9c |
Index: /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/classfile/LineNumber.java
|
|
|
2877c9c |
===================================================================
|
|
|
2877c9c |
--- /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/classfile/LineNumber.java (revision 510968)
|
|
|
2877c9c |
+++ /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/classfile/LineNumber.java (working copy)
|
|
|
2877c9c |
@@ -32,8 +32,8 @@
|
|
|
2877c9c |
*/
|
|
|
2877c9c |
public final class LineNumber implements Cloneable, Node, Serializable {
|
|
|
2877c9c |
|
|
|
2877c9c |
- private int start_pc; // Program Counter (PC) corresponds to line
|
|
|
2877c9c |
- private int line_number; // number in source file
|
|
|
2877c9c |
+ private short start_pc; // Program Counter (PC) corresponds to line
|
|
|
2877c9c |
+ private short line_number; // number in source file
|
|
|
2877c9c |
|
|
|
2877c9c |
|
|
|
2877c9c |
/**
|
|
|
2877c9c |
@@ -59,8 +59,8 @@
|
|
|
2877c9c |
* @param line_number line number in source file
|
|
|
2877c9c |
*/
|
|
|
2877c9c |
public LineNumber(int start_pc, int line_number) {
|
|
|
2877c9c |
- this.start_pc = start_pc;
|
|
|
2877c9c |
- this.line_number = line_number;
|
|
|
2877c9c |
+ this.start_pc = (short) start_pc;
|
|
|
2877c9c |
+ this.line_number = (short)line_number;
|
|
|
2877c9c |
}
|
|
|
2877c9c |
|
|
|
2877c9c |
|
|
|
2877c9c |
@@ -92,7 +92,7 @@
|
|
|
2877c9c |
* @return Corresponding source line
|
|
|
2877c9c |
*/
|
|
|
2877c9c |
public final int getLineNumber() {
|
|
|
2877c9c |
- return line_number;
|
|
|
2877c9c |
+ return 0xffff & line_number;
|
|
|
2877c9c |
}
|
|
|
2877c9c |
|
|
|
2877c9c |
|
|
|
2877c9c |
@@ -100,7 +100,7 @@
|
|
|
2877c9c |
* @return PC in code
|
|
|
2877c9c |
*/
|
|
|
2877c9c |
public final int getStartPC() {
|
|
|
2877c9c |
- return start_pc;
|
|
|
2877c9c |
+ return 0xffff & start_pc;
|
|
|
2877c9c |
}
|
|
|
2877c9c |
|
|
|
2877c9c |
|
|
|
2877c9c |
@@ -108,7 +108,7 @@
|
|
|
2877c9c |
* @param line_number the source line number
|
|
|
2877c9c |
*/
|
|
|
2877c9c |
public final void setLineNumber( int line_number ) {
|
|
|
2877c9c |
- this.line_number = line_number;
|
|
|
2877c9c |
+ this.line_number = (short) line_number;
|
|
|
2877c9c |
}
|
|
|
2877c9c |
|
|
|
2877c9c |
|
|
|
2877c9c |
@@ -116,7 +116,7 @@
|
|
|
2877c9c |
* @param start_pc the pc for this line number
|
|
|
2877c9c |
*/
|
|
|
2877c9c |
public final void setStartPC( int start_pc ) {
|
|
|
2877c9c |
- this.start_pc = start_pc;
|
|
|
2877c9c |
+ this.start_pc = (short) start_pc;
|
|
|
2877c9c |
}
|
|
|
2877c9c |
|
|
|
2877c9c |
|
|
|
2877c9c |
Index: /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/classfile/LocalVariableTable.java
|
|
|
2877c9c |
===================================================================
|
|
|
2877c9c |
--- /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/classfile/LocalVariableTable.java (revision 510968)
|
|
|
2877c9c |
+++ /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/classfile/LocalVariableTable.java (working copy)
|
|
|
2877c9c |
@@ -30,11 +30,7 @@
|
|
|
2877c9c |
* @see Code
|
|
|
2877c9c |
* @see LocalVariable
|
|
|
2877c9c |
*/
|
|
|
2877c9c |
-public class LocalVariableTable extends Attribute {
|
|
|
2877c9c |
-
|
|
|
2877c9c |
- private int local_variable_table_length; // Table of local
|
|
|
2877c9c |
- private LocalVariable[] local_variable_table; // variables
|
|
|
2877c9c |
-
|
|
|
2877c9c |
+public class LocalVariableTable extends AbstractLocalVariableTable {
|
|
|
2877c9c |
|
|
|
2877c9c |
/**
|
|
|
2877c9c |
* Initialize from another object. Note that both objects use the same
|
|
|
2877c9c |
@@ -53,8 +49,7 @@
|
|
|
2877c9c |
*/
|
|
|
2877c9c |
public LocalVariableTable(int name_index, int length, LocalVariable[] local_variable_table,
|
|
|
2877c9c |
ConstantPool constant_pool) {
|
|
|
2877c9c |
- super(Constants.ATTR_LOCAL_VARIABLE_TABLE, name_index, length, constant_pool);
|
|
|
2877c9c |
- setLocalVariableTable(local_variable_table);
|
|
|
2877c9c |
+ super(name_index,length, local_variable_table, constant_pool);
|
|
|
2877c9c |
}
|
|
|
2877c9c |
|
|
|
2877c9c |
|
|
|
2877c9c |
@@ -68,12 +63,7 @@
|
|
|
2877c9c |
*/
|
|
|
2877c9c |
LocalVariableTable(int name_index, int length, DataInputStream file, ConstantPool constant_pool)
|
|
|
2877c9c |
throws IOException {
|
|
|
2877c9c |
- this(name_index, length, (LocalVariable[]) null, constant_pool);
|
|
|
2877c9c |
- local_variable_table_length = (file.readUnsignedShort());
|
|
|
2877c9c |
- local_variable_table = new LocalVariable[local_variable_table_length];
|
|
|
2877c9c |
- for (int i = 0; i < local_variable_table_length; i++) {
|
|
|
2877c9c |
- local_variable_table[i] = new LocalVariable(file, constant_pool);
|
|
|
2877c9c |
- }
|
|
|
2877c9c |
+ super(name_index,length, file, constant_pool);
|
|
|
2877c9c |
}
|
|
|
2877c9c |
|
|
|
2877c9c |
|
|
|
2877c9c |
@@ -87,111 +77,4 @@
|
|
|
2877c9c |
public void accept( Visitor v ) {
|
|
|
2877c9c |
v.visitLocalVariableTable(this);
|
|
|
2877c9c |
}
|
|
|
2877c9c |
-
|
|
|
2877c9c |
-
|
|
|
2877c9c |
- /**
|
|
|
2877c9c |
- * Dump local variable table attribute to file stream in binary format.
|
|
|
2877c9c |
- *
|
|
|
2877c9c |
- * @param file Output file stream
|
|
|
2877c9c |
- * @throws IOException
|
|
|
2877c9c |
- */
|
|
|
2877c9c |
- public final void dump( DataOutputStream file ) throws IOException {
|
|
|
2877c9c |
- super.dump(file);
|
|
|
2877c9c |
- file.writeShort(local_variable_table_length);
|
|
|
2877c9c |
- for (int i = 0; i < local_variable_table_length; i++) {
|
|
|
2877c9c |
- local_variable_table[i].dump(file);
|
|
|
2877c9c |
- }
|
|
|
2877c9c |
- }
|
|
|
2877c9c |
-
|
|
|
2877c9c |
-
|
|
|
2877c9c |
- /**
|
|
|
2877c9c |
- * @return Array of local variables of method.
|
|
|
2877c9c |
- */
|
|
|
2877c9c |
- public final LocalVariable[] getLocalVariableTable() {
|
|
|
2877c9c |
- return local_variable_table;
|
|
|
2877c9c |
- }
|
|
|
2877c9c |
-
|
|
|
2877c9c |
-
|
|
|
2877c9c |
- /**
|
|
|
2877c9c |
- * @return first matching variable using index
|
|
|
2877c9c |
- *
|
|
|
2877c9c |
- * @param index the variable slot
|
|
|
2877c9c |
- *
|
|
|
2877c9c |
- * @return the first LocalVariable that matches the slot or null if not found
|
|
|
2877c9c |
- *
|
|
|
2877c9c |
- * @deprecated since 5.2 because multiple variables can share the
|
|
|
2877c9c |
- * same slot, use getLocalVariable(int index, int pc) instead.
|
|
|
2877c9c |
- */
|
|
|
2877c9c |
- public final LocalVariable getLocalVariable( int index ) {
|
|
|
2877c9c |
- for (int i = 0; i < local_variable_table_length; i++) {
|
|
|
2877c9c |
- if (local_variable_table[i].getIndex() == index) {
|
|
|
2877c9c |
- return local_variable_table[i];
|
|
|
2877c9c |
- }
|
|
|
2877c9c |
- }
|
|
|
2877c9c |
- return null;
|
|
|
2877c9c |
- }
|
|
|
2877c9c |
-
|
|
|
2877c9c |
-
|
|
|
2877c9c |
- /**
|
|
|
2877c9c |
- * @return matching variable using index when variable is used at supplied pc
|
|
|
2877c9c |
- *
|
|
|
2877c9c |
- * @param index the variable slot
|
|
|
2877c9c |
- * @param pc the current pc that this variable is alive
|
|
|
2877c9c |
- *
|
|
|
2877c9c |
- * @return the LocalVariable that matches or null if not found
|
|
|
2877c9c |
- */
|
|
|
2877c9c |
- public final LocalVariable getLocalVariable( int index, int pc ) {
|
|
|
2877c9c |
- for (int i = 0; i < local_variable_table_length; i++) {
|
|
|
2877c9c |
- if (local_variable_table[i].getIndex() == index) {
|
|
|
2877c9c |
- int start_pc = local_variable_table[i].getStartPC();
|
|
|
2877c9c |
- int end_pc = start_pc + local_variable_table[i].getLength();
|
|
|
2877c9c |
- if ((pc >= start_pc) && (pc < end_pc)) {
|
|
|
2877c9c |
- return local_variable_table[i];
|
|
|
2877c9c |
- }
|
|
|
2877c9c |
- }
|
|
|
2877c9c |
- }
|
|
|
2877c9c |
- return null;
|
|
|
2877c9c |
- }
|
|
|
2877c9c |
-
|
|
|
2877c9c |
-
|
|
|
2877c9c |
- public final void setLocalVariableTable( LocalVariable[] local_variable_table ) {
|
|
|
2877c9c |
- this.local_variable_table = local_variable_table;
|
|
|
2877c9c |
- local_variable_table_length = (local_variable_table == null)
|
|
|
2877c9c |
- ? 0
|
|
|
2877c9c |
- : local_variable_table.length;
|
|
|
2877c9c |
- }
|
|
|
2877c9c |
-
|
|
|
2877c9c |
-
|
|
|
2877c9c |
- /**
|
|
|
2877c9c |
- * @return String representation.
|
|
|
2877c9c |
- */
|
|
|
2877c9c |
- public final String toString() {
|
|
|
2877c9c |
- StringBuffer buf = new StringBuffer("");
|
|
|
2877c9c |
- for (int i = 0; i < local_variable_table_length; i++) {
|
|
|
2877c9c |
- buf.append(local_variable_table[i].toString());
|
|
|
2877c9c |
- if (i < local_variable_table_length - 1) {
|
|
|
2877c9c |
- buf.append('\n');
|
|
|
2877c9c |
- }
|
|
|
2877c9c |
- }
|
|
|
2877c9c |
- return buf.toString();
|
|
|
2877c9c |
- }
|
|
|
2877c9c |
-
|
|
|
2877c9c |
-
|
|
|
2877c9c |
- /**
|
|
|
2877c9c |
- * @return deep copy of this attribute
|
|
|
2877c9c |
- */
|
|
|
2877c9c |
- public Attribute copy( ConstantPool _constant_pool ) {
|
|
|
2877c9c |
- LocalVariableTable c = (LocalVariableTable) clone();
|
|
|
2877c9c |
- c.local_variable_table = new LocalVariable[local_variable_table_length];
|
|
|
2877c9c |
- for (int i = 0; i < local_variable_table_length; i++) {
|
|
|
2877c9c |
- c.local_variable_table[i] = local_variable_table[i].copy();
|
|
|
2877c9c |
- }
|
|
|
2877c9c |
- c.constant_pool = _constant_pool;
|
|
|
2877c9c |
- return c;
|
|
|
2877c9c |
- }
|
|
|
2877c9c |
-
|
|
|
2877c9c |
-
|
|
|
2877c9c |
- public final int getTableLength() {
|
|
|
2877c9c |
- return local_variable_table_length;
|
|
|
2877c9c |
- }
|
|
|
2877c9c |
}
|
|
|
2877c9c |
Index: /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/classfile/LocalVariableTypeTable.java
|
|
|
2877c9c |
===================================================================
|
|
|
2877c9c |
--- /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/classfile/LocalVariableTypeTable.java (revision 0)
|
|
|
2877c9c |
+++ /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/classfile/LocalVariableTypeTable.java (revision 0)
|
|
|
2877c9c |
@@ -0,0 +1,22 @@
|
|
|
2877c9c |
+package org.apache.bcel.classfile;
|
|
|
2877c9c |
+
|
|
|
2877c9c |
+import java.io.DataInputStream;
|
|
|
2877c9c |
+import java.io.IOException;
|
|
|
2877c9c |
+
|
|
|
2877c9c |
+public class LocalVariableTypeTable extends AbstractLocalVariableTable {
|
|
|
2877c9c |
+
|
|
|
2877c9c |
+ public LocalVariableTypeTable(int name_index, int length, DataInputStream file, ConstantPool constant_pool) throws IOException {
|
|
|
2877c9c |
+ super(name_index, length, file, constant_pool);
|
|
|
2877c9c |
+ }
|
|
|
2877c9c |
+
|
|
|
2877c9c |
+ /**
|
|
|
2877c9c |
+ * Called by objects that are traversing the nodes of the tree implicitely
|
|
|
2877c9c |
+ * defined by the contents of a Java class. I.e., the hierarchy of methods,
|
|
|
2877c9c |
+ * fields, attributes, etc. spawns a tree of objects.
|
|
|
2877c9c |
+ *
|
|
|
2877c9c |
+ * @param v Visitor object
|
|
|
2877c9c |
+ */
|
|
|
2877c9c |
+ public void accept( Visitor v ) {
|
|
|
2877c9c |
+ v.visitLocalVariableTypeTable(this);
|
|
|
2877c9c |
+ }
|
|
|
2877c9c |
+}
|
|
|
2877c9c |
Index: /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/classfile/Visitor.java
|
|
|
2877c9c |
===================================================================
|
|
|
2877c9c |
--- /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/classfile/Visitor.java (revision 510968)
|
|
|
2877c9c |
+++ /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/classfile/Visitor.java (working copy)
|
|
|
2877c9c |
@@ -103,6 +103,7 @@
|
|
|
2877c9c |
|
|
|
2877c9c |
|
|
|
2877c9c |
public void visitLocalVariableTable( LocalVariableTable obj );
|
|
|
2877c9c |
+ public void visitLocalVariableTypeTable( LocalVariableTypeTable obj );
|
|
|
2877c9c |
|
|
|
2877c9c |
|
|
|
2877c9c |
public void visitMethod( Method obj );
|
|
|
2877c9c |
Index: /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/Constants.java
|
|
|
2877c9c |
===================================================================
|
|
|
2877c9c |
--- /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/Constants.java (revision 510968)
|
|
|
2877c9c |
+++ /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/Constants.java (working copy)
|
|
|
2877c9c |
@@ -729,13 +729,16 @@
|
|
|
2877c9c |
public static final byte ATTR_PMG = 9;
|
|
|
2877c9c |
public static final byte ATTR_SIGNATURE = 10;
|
|
|
2877c9c |
public static final byte ATTR_STACK_MAP = 11;
|
|
|
2877c9c |
- public static final byte ATTR_RUNTIMEVISIBLE_ANNOTATIONS = 12;
|
|
|
2877c9c |
- public static final byte ATTR_RUNTIMEINVISIBLE_ANNOTATIONS = 13;
|
|
|
2877c9c |
- public static final byte ATTR_RUNTIMEVISIBLE_PARAMETER_ANNOTATIONS = 14;
|
|
|
2877c9c |
- public static final byte ATTR_RUNTIMEINVISIBLE_PARAMETER_ANNOTATIONS = 15;
|
|
|
2877c9c |
- public static final byte ATTR_ANNOTATION_DEFAULT = 16;
|
|
|
2877c9c |
+ public static final byte ATTR_LOCAL_VARIABLE_TYPE_TABLE = 12;
|
|
|
2877c9c |
+ public static final byte ATTR_RUNTIMEVISIBLE_ANNOTATIONS = 13;
|
|
|
2877c9c |
+ public static final byte ATTR_RUNTIMEINVISIBLE_ANNOTATIONS = 14;
|
|
|
2877c9c |
+ public static final byte ATTR_RUNTIMEVISIBLE_PARAMETER_ANNOTATIONS = 15;
|
|
|
2877c9c |
+ public static final byte ATTR_RUNTIMEINVISIBLE_PARAMETER_ANNOTATIONS = 16;
|
|
|
2877c9c |
+ public static final byte ATTR_ANNOTATION_DEFAULT = 17;
|
|
|
2877c9c |
+
|
|
|
2877c9c |
+
|
|
|
2877c9c |
|
|
|
2877c9c |
- public static final short KNOWN_ATTRIBUTES = 12;//should be 17
|
|
|
2877c9c |
+ public static final short KNOWN_ATTRIBUTES = 13;//should be 17
|
|
|
2877c9c |
|
|
|
2877c9c |
public static final String[] ATTRIBUTE_NAMES = {
|
|
|
2877c9c |
"SourceFile", "ConstantValue", "Code", "Exceptions",
|
|
|
2877c9c |
@@ -741,7 +744,7 @@
|
|
|
2877c9c |
"SourceFile", "ConstantValue", "Code", "Exceptions",
|
|
|
2877c9c |
"LineNumberTable", "LocalVariableTable",
|
|
|
2877c9c |
"InnerClasses", "Synthetic", "Deprecated",
|
|
|
2877c9c |
- "PMGClass", "Signature", "StackMap",
|
|
|
2877c9c |
+ "PMGClass", "Signature", "StackMap", "LocalVariableTypeTable",
|
|
|
2877c9c |
"RuntimeVisibleAnnotations", "RuntimeInvisibleAnnotations",
|
|
|
2877c9c |
"RuntimeVisibleParameterAnnotations", "RuntimeInvisibleParameterAnnotations",
|
|
|
2877c9c |
"AnnotationDefault"
|
|
|
2877c9c |
Index: /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/generic/ArrayType.java
|
|
|
2877c9c |
===================================================================
|
|
|
2877c9c |
--- /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/generic/ArrayType.java (revision 510968)
|
|
|
2877c9c |
+++ /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/generic/ArrayType.java (working copy)
|
|
|
2877c9c |
@@ -46,7 +46,7 @@
|
|
|
2877c9c |
* @param class_name complete name of class (java.lang.String, e.g.)
|
|
|
2877c9c |
*/
|
|
|
2877c9c |
public ArrayType(String class_name, int dimensions) {
|
|
|
2877c9c |
- this(new ObjectType(class_name), dimensions);
|
|
|
2877c9c |
+ this(ObjectType.getInstance(class_name), dimensions);
|
|
|
2877c9c |
}
|
|
|
2877c9c |
|
|
|
2877c9c |
|
|
|
2877c9c |
Index: /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/generic/FieldGen.java
|
|
|
2877c9c |
===================================================================
|
|
|
2877c9c |
--- /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/generic/FieldGen.java (revision 510968)
|
|
|
2877c9c |
+++ /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/generic/FieldGen.java (working copy)
|
|
|
2877c9c |
@@ -107,7 +107,7 @@
|
|
|
2877c9c |
* by the JVM automatically.
|
|
|
2877c9c |
*/
|
|
|
2877c9c |
public void setInitValue( String str ) {
|
|
|
2877c9c |
- checkType(new ObjectType("java.lang.String"));
|
|
|
2877c9c |
+ checkType( ObjectType.getInstance("java.lang.String"));
|
|
|
2877c9c |
if (str != null) {
|
|
|
2877c9c |
value = str;
|
|
|
2877c9c |
}
|
|
|
2877c9c |
Index: /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/generic/FieldOrMethod.java
|
|
|
2877c9c |
===================================================================
|
|
|
2877c9c |
--- /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/generic/FieldOrMethod.java (revision 510968)
|
|
|
2877c9c |
+++ /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/generic/FieldOrMethod.java (working copy)
|
|
|
2877c9c |
@@ -94,7 +94,7 @@
|
|
|
2877c9c |
* getReferenceType() instead.
|
|
|
2877c9c |
*/
|
|
|
2877c9c |
public ObjectType getClassType( ConstantPoolGen cpg ) {
|
|
|
2877c9c |
- return new ObjectType(getClassName(cpg));
|
|
|
2877c9c |
+ return ObjectType.getInstance(getClassName(cpg));
|
|
|
2877c9c |
}
|
|
|
2877c9c |
|
|
|
2877c9c |
|
|
|
2877c9c |
@@ -115,7 +115,7 @@
|
|
|
2877c9c |
return (ArrayType) Type.getType(className);
|
|
|
2877c9c |
} else {
|
|
|
2877c9c |
className = className.replace('/', '.');
|
|
|
2877c9c |
- return new ObjectType(className);
|
|
|
2877c9c |
+ return ObjectType.getInstance(className);
|
|
|
2877c9c |
}
|
|
|
2877c9c |
}
|
|
|
2877c9c |
|
|
|
2877c9c |
Index: /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/generic/InstructionFactory.java
|
|
|
2877c9c |
===================================================================
|
|
|
2877c9c |
--- /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/generic/InstructionFactory.java (revision 510968)
|
|
|
2877c9c |
+++ /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/generic/InstructionFactory.java (working copy)
|
|
|
2877c9c |
@@ -616,7 +616,7 @@
|
|
|
2877c9c |
|
|
|
2877c9c |
|
|
|
2877c9c |
public NEW createNew( String s ) {
|
|
|
2877c9c |
- return createNew(new ObjectType(s));
|
|
|
2877c9c |
+ return createNew(ObjectType.getInstance(s));
|
|
|
2877c9c |
}
|
|
|
2877c9c |
|
|
|
2877c9c |
|
|
|
2877c9c |
Index: /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/generic/MethodGen.java
|
|
|
2877c9c |
===================================================================
|
|
|
2877c9c |
--- /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/generic/MethodGen.java (revision 510968)
|
|
|
2877c9c |
+++ /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/generic/MethodGen.java (working copy)
|
|
|
2877c9c |
@@ -122,7 +122,7 @@
|
|
|
2877c9c |
/* Add local variables, namely the implicit `this' and the arguments
|
|
|
2877c9c |
*/
|
|
|
2877c9c |
if (!isStatic() && (class_name != null)) { // Instance method -> `this' is local var 0
|
|
|
2877c9c |
- addLocalVariable("this", new ObjectType(class_name), start, end);
|
|
|
2877c9c |
+ addLocalVariable("this", ObjectType.getInstance(class_name), start, end);
|
|
|
2877c9c |
}
|
|
|
2877c9c |
}
|
|
|
2877c9c |
if (arg_types != null) {
|
|
|
2877c9c |
@@ -183,7 +183,7 @@
|
|
|
2877c9c |
if (type > 0) {
|
|
|
2877c9c |
String cen = m.getConstantPool().getConstantString(type,
|
|
|
2877c9c |
Constants.CONSTANT_Class);
|
|
|
2877c9c |
- c_type = new ObjectType(cen);
|
|
|
2877c9c |
+ c_type = ObjectType.getInstance(cen);
|
|
|
2877c9c |
}
|
|
|
2877c9c |
int end_pc = ce.getEndPC();
|
|
|
2877c9c |
int length = m.getCode().getCode().length;
|
|
|
2877c9c |
Index: /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/generic/ObjectType.java
|
|
|
2877c9c |
===================================================================
|
|
|
2877c9c |
--- /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/generic/ObjectType.java (revision 510968)
|
|
|
2877c9c |
+++ /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/generic/ObjectType.java (working copy)
|
|
|
2877c9c |
@@ -16,6 +16,10 @@
|
|
|
2877c9c |
*/
|
|
|
2877c9c |
package org.apache.bcel.generic;
|
|
|
2877c9c |
|
|
|
2877c9c |
+import java.util.HashMap;
|
|
|
2877c9c |
+import java.util.LinkedHashMap;
|
|
|
2877c9c |
+import java.util.Map;
|
|
|
2877c9c |
+
|
|
|
2877c9c |
import org.apache.bcel.Constants;
|
|
|
2877c9c |
import org.apache.bcel.Repository;
|
|
|
2877c9c |
import org.apache.bcel.classfile.JavaClass;
|
|
|
2877c9c |
@@ -20,6 +24,7 @@
|
|
|
2877c9c |
import org.apache.bcel.Repository;
|
|
|
2877c9c |
import org.apache.bcel.classfile.JavaClass;
|
|
|
2877c9c |
|
|
|
2877c9c |
+
|
|
|
2877c9c |
/**
|
|
|
2877c9c |
* Denotes reference such as java.lang.String.
|
|
|
2877c9c |
*
|
|
|
2877c9c |
@@ -28,8 +33,27 @@
|
|
|
2877c9c |
*/
|
|
|
2877c9c |
public class ObjectType extends ReferenceType {
|
|
|
2877c9c |
|
|
|
2877c9c |
- private String class_name; // Class name of type
|
|
|
2877c9c |
+ private static final int MAX_CACHE_ENTRIES = 200;
|
|
|
2877c9c |
+ private static final int INITIAL_CACHE_CAPACITY = (int)(MAX_CACHE_ENTRIES/0.75);
|
|
|
2877c9c |
+ private static HashMap<String, ObjectType> cache;
|
|
|
2877c9c |
+ public synchronized static ObjectType getInstance(String class_name) {
|
|
|
2877c9c |
+ if (cache == null)
|
|
|
2877c9c |
+ cache = new LinkedHashMap<String, ObjectType>(INITIAL_CACHE_CAPACITY, 0.75f, true) {
|
|
|
2877c9c |
+
|
|
|
2877c9c |
+
|
|
|
2877c9c |
+ protected boolean removeEldestEntry(Map.Entry eldest) {
|
|
|
2877c9c |
+ return size() > MAX_CACHE_ENTRIES;
|
|
|
2877c9c |
+ }
|
|
|
2877c9c |
+
|
|
|
2877c9c |
+ };
|
|
|
2877c9c |
+ ObjectType result = cache.get(class_name);
|
|
|
2877c9c |
+ if (result != null) return result;
|
|
|
2877c9c |
+ result = new ObjectType(class_name);
|
|
|
2877c9c |
+ cache.put(class_name, result);
|
|
|
2877c9c |
+ return result;
|
|
|
2877c9c |
+ }
|
|
|
2877c9c |
|
|
|
2877c9c |
+ final private String class_name; // Class name of type
|
|
|
2877c9c |
|
|
|
2877c9c |
/**
|
|
|
2877c9c |
* @param class_name fully qualified class name, e.g. java.lang.String
|
|
|
2877c9c |
Index: /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/generic/ReferenceType.java
|
|
|
2877c9c |
===================================================================
|
|
|
2877c9c |
--- /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/generic/ReferenceType.java (revision 510968)
|
|
|
2877c9c |
+++ /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/generic/ReferenceType.java (working copy)
|
|
|
2877c9c |
@@ -162,7 +162,7 @@
|
|
|
2877c9c |
// 'java.io.Serializable'"
|
|
|
2877c9c |
if ((T instanceof ObjectType) && (((ObjectType) T).referencesInterfaceExact())) {
|
|
|
2877c9c |
for (int ii = 0; ii < Constants.INTERFACES_IMPLEMENTED_BY_ARRAYS.length; ii++) {
|
|
|
2877c9c |
- if (T.equals(new ObjectType(Constants.INTERFACES_IMPLEMENTED_BY_ARRAYS[ii]))) {
|
|
|
2877c9c |
+ if (T.equals(ObjectType.getInstance(Constants.INTERFACES_IMPLEMENTED_BY_ARRAYS[ii]))) {
|
|
|
2877c9c |
return true;
|
|
|
2877c9c |
}
|
|
|
2877c9c |
}
|
|
|
2877c9c |
@@ -248,7 +248,7 @@
|
|
|
2877c9c |
for (int i = 0; i < t_sups.length; i++) {
|
|
|
2877c9c |
for (int j = 0; j < this_sups.length; j++) {
|
|
|
2877c9c |
if (this_sups[j].equals(t_sups[i])) {
|
|
|
2877c9c |
- return new ObjectType(this_sups[j].getClassName());
|
|
|
2877c9c |
+ return ObjectType.getInstance(this_sups[j].getClassName());
|
|
|
2877c9c |
}
|
|
|
2877c9c |
}
|
|
|
2877c9c |
}
|
|
|
2877c9c |
@@ -320,7 +320,7 @@
|
|
|
2877c9c |
for (int i = 0; i < t_sups.length; i++) {
|
|
|
2877c9c |
for (int j = 0; j < this_sups.length; j++) {
|
|
|
2877c9c |
if (this_sups[j].equals(t_sups[i])) {
|
|
|
2877c9c |
- return new ObjectType(this_sups[j].getClassName());
|
|
|
2877c9c |
+ return ObjectType.getInstance(this_sups[j].getClassName());
|
|
|
2877c9c |
}
|
|
|
2877c9c |
}
|
|
|
2877c9c |
}
|
|
|
2877c9c |
Index: /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/generic/Type.java
|
|
|
2877c9c |
===================================================================
|
|
|
2877c9c |
--- /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/generic/Type.java (revision 510968)
|
|
|
2877c9c |
+++ /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/generic/Type.java (working copy)
|
|
|
2877c9c |
@@ -31,7 +31,7 @@
|
|
|
2877c9c |
*/
|
|
|
2877c9c |
public abstract class Type implements java.io.Serializable {
|
|
|
2877c9c |
|
|
|
2877c9c |
- protected byte type;
|
|
|
2877c9c |
+ final protected byte type;
|
|
|
2877c9c |
protected String signature; // signature for the type
|
|
|
2877c9c |
/** Predefined constants
|
|
|
2877c9c |
*/
|
|
|
2877c9c |
@@ -44,11 +44,11 @@
|
|
|
2877c9c |
public static final BasicType DOUBLE = new BasicType(Constants.T_DOUBLE);
|
|
|
2877c9c |
public static final BasicType FLOAT = new BasicType(Constants.T_FLOAT);
|
|
|
2877c9c |
public static final BasicType CHAR = new BasicType(Constants.T_CHAR);
|
|
|
2877c9c |
- public static final ObjectType OBJECT = new ObjectType("java.lang.Object");
|
|
|
2877c9c |
- public static final ObjectType CLASS = new ObjectType("java.lang.Class");
|
|
|
2877c9c |
- public static final ObjectType STRING = new ObjectType("java.lang.String");
|
|
|
2877c9c |
- public static final ObjectType STRINGBUFFER = new ObjectType("java.lang.StringBuffer");
|
|
|
2877c9c |
- public static final ObjectType THROWABLE = new ObjectType("java.lang.Throwable");
|
|
|
2877c9c |
+ public static final ObjectType OBJECT = ObjectType.getInstance("java.lang.Object");
|
|
|
2877c9c |
+ public static final ObjectType CLASS = ObjectType.getInstance("java.lang.Class");
|
|
|
2877c9c |
+ public static final ObjectType STRING = ObjectType.getInstance("java.lang.String");
|
|
|
2877c9c |
+ public static final ObjectType STRINGBUFFER = ObjectType.getInstance("java.lang.StringBuffer");
|
|
|
2877c9c |
+ public static final ObjectType THROWABLE = ObjectType.getInstance("java.lang.Throwable");
|
|
|
2877c9c |
public static final Type[] NO_ARGS = new Type[0];
|
|
|
2877c9c |
public static final ReferenceType NULL = new ReferenceType() {
|
|
|
2877c9c |
};
|
|
|
2877c9c |
@@ -190,7 +190,7 @@
|
|
|
2877c9c |
}
|
|
|
2877c9c |
//corrected concurrent private static field acess
|
|
|
2877c9c |
wrap(consumed_chars, index + 1); // "Lblabla;" `L' and `;' are removed
|
|
|
2877c9c |
- return new ObjectType(signature.substring(1, index).replace('/', '.'));
|
|
|
2877c9c |
+ return ObjectType.getInstance(signature.substring(1, index).replace('/', '.'));
|
|
|
2877c9c |
}
|
|
|
2877c9c |
}
|
|
|
2877c9c |
|
|
|
2877c9c |
@@ -278,7 +278,7 @@
|
|
|
2877c9c |
throw new IllegalStateException("Ooops, what primitive type is " + cl);
|
|
|
2877c9c |
}
|
|
|
2877c9c |
} else { // "Real" class
|
|
|
2877c9c |
- return new ObjectType(cl.getName());
|
|
|
2877c9c |
+ return ObjectType.getInstance(cl.getName());
|
|
|
2877c9c |
}
|
|
|
2877c9c |
}
|
|
|
2877c9c |
|
|
|
2877c9c |
Index: /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/verifier/structurals/InstConstraintVisitor.java
|
|
|
2877c9c |
===================================================================
|
|
|
2877c9c |
--- /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/verifier/structurals/InstConstraintVisitor.java (revision 510968)
|
|
|
2877c9c |
+++ /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/verifier/structurals/InstConstraintVisitor.java (working copy)
|
|
|
2877c9c |
@@ -52,7 +52,7 @@
|
|
|
2877c9c |
*/
|
|
|
2877c9c |
public class InstConstraintVisitor extends EmptyVisitor implements org.apache.bcel.generic.Visitor{
|
|
|
2877c9c |
|
|
|
2877c9c |
- private static ObjectType GENERIC_ARRAY = new ObjectType("org.apache.bcel.verifier.structurals.GenericArray");
|
|
|
2877c9c |
+ private static ObjectType GENERIC_ARRAY = ObjectType.getInstance("org.apache.bcel.verifier.structurals.GenericArray");
|
|
|
2877c9c |
|
|
|
2877c9c |
/**
|
|
|
2877c9c |
* The constructor. Constructs a new instance of this class.
|
|
|
2877c9c |
@@ -1207,7 +1207,7 @@
|
|
|
2877c9c |
|
|
|
2877c9c |
if (f.isProtected()){
|
|
|
2877c9c |
ObjectType classtype = o.getClassType(cpg);
|
|
|
2877c9c |
- ObjectType curr = new ObjectType(mg.getClassName());
|
|
|
2877c9c |
+ ObjectType curr = ObjectType.getInstance(mg.getClassName());
|
|
|
2877c9c |
|
|
|
2877c9c |
if ( classtype.equals(curr) ||
|
|
|
2877c9c |
curr.subclassOf(classtype) ){
|
|
|
2877c9c |
@@ -2531,7 +2531,7 @@
|
|
|
2877c9c |
|
|
|
2877c9c |
if (f.isProtected()){
|
|
|
2877c9c |
ObjectType classtype = o.getClassType(cpg);
|
|
|
2877c9c |
- ObjectType curr = new ObjectType(mg.getClassName());
|
|
|
2877c9c |
+ ObjectType curr = ObjectType.getInstance(mg.getClassName());
|
|
|
2877c9c |
|
|
|
2877c9c |
if ( classtype.equals(curr) ||
|
|
|
2877c9c |
curr.subclassOf(classtype) ){
|
|
|
2877c9c |
Index: /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/verifier/structurals/Pass3bVerifier.java
|
|
|
2877c9c |
===================================================================
|
|
|
2877c9c |
--- /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/verifier/structurals/Pass3bVerifier.java (revision 510968)
|
|
|
2877c9c |
+++ /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/verifier/structurals/Pass3bVerifier.java (working copy)
|
|
|
2877c9c |
@@ -301,7 +301,7 @@
|
|
|
2877c9c |
Frame f = new Frame(mg.getMaxLocals(),mg.getMaxStack());
|
|
|
2877c9c |
if ( !mg.isStatic() ){
|
|
|
2877c9c |
if (mg.getName().equals(Constants.CONSTRUCTOR_NAME)){
|
|
|
2877c9c |
- Frame._this = new UninitializedObjectType(new ObjectType(jc.getClassName()));
|
|
|
2877c9c |
+ Frame._this = new UninitializedObjectType(ObjectType.getInstance(jc.getClassName()));
|
|
|
2877c9c |
f.getLocals().set(0, Frame._this);
|
|
|
2877c9c |
}
|
|
|
2877c9c |
else{
|
|
|
2877c9c |
@@ -306,7 +306,7 @@
|
|
|
2877c9c |
}
|
|
|
2877c9c |
else{
|
|
|
2877c9c |
Frame._this = null;
|
|
|
2877c9c |
- f.getLocals().set(0, new ObjectType(jc.getClassName()));
|
|
|
2877c9c |
+ f.getLocals().set(0, ObjectType.getInstance(jc.getClassName()));
|
|
|
2877c9c |
}
|
|
|
2877c9c |
}
|
|
|
2877c9c |
Type[] argtypes = mg.getArgumentTypes();
|