aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/javassist/bytecode
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/javassist/bytecode')
-rw-r--r--src/main/javassist/bytecode/AttributeInfo.java2
-rw-r--r--src/main/javassist/bytecode/Bytecode.java3
-rw-r--r--src/main/javassist/bytecode/CodeAttribute.java1
-rw-r--r--src/main/javassist/bytecode/ExceptionsAttribute.java2
-rw-r--r--src/main/javassist/bytecode/FieldInfo.java1
-rw-r--r--src/main/javassist/bytecode/InnerClassesAttribute.java2
-rw-r--r--src/main/javassist/bytecode/LineNumberAttribute.java2
-rw-r--r--src/main/javassist/bytecode/LocalVariableAttribute.java159
-rw-r--r--src/main/javassist/bytecode/MethodInfo.java1
9 files changed, 164 insertions, 9 deletions
diff --git a/src/main/javassist/bytecode/AttributeInfo.java b/src/main/javassist/bytecode/AttributeInfo.java
index 8070500c..bd8f29de 100644
--- a/src/main/javassist/bytecode/AttributeInfo.java
+++ b/src/main/javassist/bytecode/AttributeInfo.java
@@ -81,6 +81,8 @@ public class AttributeInfo {
return new SourceFileAttribute(cp, name, in);
else if (nameStr.equals(LineNumberAttribute.tag))
return new LineNumberAttribute(cp, name, in);
+ else if (nameStr.equals(LocalVariableAttribute.tag))
+ return new LocalVariableAttribute(cp, name, in);
else if (nameStr.equals(SyntheticAttribute.tag))
return new SyntheticAttribute(cp, name, in);
else if (nameStr.equals(DeprecatedAttribute.tag))
diff --git a/src/main/javassist/bytecode/Bytecode.java b/src/main/javassist/bytecode/Bytecode.java
index 9c742396..087c9393 100644
--- a/src/main/javassist/bytecode/Bytecode.java
+++ b/src/main/javassist/bytecode/Bytecode.java
@@ -15,9 +15,6 @@
package javassist.bytecode;
-import java.io.DataOutputStream;
-import java.io.IOException;
-import javassist.CannotCompileException;
import javassist.CtClass;
import javassist.CtPrimitiveType;
diff --git a/src/main/javassist/bytecode/CodeAttribute.java b/src/main/javassist/bytecode/CodeAttribute.java
index d96add16..b146440a 100644
--- a/src/main/javassist/bytecode/CodeAttribute.java
+++ b/src/main/javassist/bytecode/CodeAttribute.java
@@ -21,7 +21,6 @@ import java.io.IOException;
import java.util.List;
import java.util.LinkedList;
import java.util.Map;
-import javassist.CtClass;
/**
* <code>Code_attribute</code>.
diff --git a/src/main/javassist/bytecode/ExceptionsAttribute.java b/src/main/javassist/bytecode/ExceptionsAttribute.java
index ac25dea3..614a0682 100644
--- a/src/main/javassist/bytecode/ExceptionsAttribute.java
+++ b/src/main/javassist/bytecode/ExceptionsAttribute.java
@@ -161,7 +161,7 @@ public class ExceptionsAttribute extends AttributeInfo {
/**
* Returns <code>number_of_exceptions</code>.
*/
- public int length() { return info.length / 2 - 1; }
+ public int tableLength() { return info.length / 2 - 1; }
/**
* Returns the value of <code>exception_index_table[nth]</code>.
diff --git a/src/main/javassist/bytecode/FieldInfo.java b/src/main/javassist/bytecode/FieldInfo.java
index 495ff224..bc1e456b 100644
--- a/src/main/javassist/bytecode/FieldInfo.java
+++ b/src/main/javassist/bytecode/FieldInfo.java
@@ -18,7 +18,6 @@ package javassist.bytecode;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
-import java.util.Hashtable;
import java.util.List;
import java.util.LinkedList;
diff --git a/src/main/javassist/bytecode/InnerClassesAttribute.java b/src/main/javassist/bytecode/InnerClassesAttribute.java
index e6a3ec7f..98edcb8a 100644
--- a/src/main/javassist/bytecode/InnerClassesAttribute.java
+++ b/src/main/javassist/bytecode/InnerClassesAttribute.java
@@ -41,7 +41,7 @@ public class InnerClassesAttribute extends AttributeInfo {
/**
* Returns <code>number_of_classes</code>.
*/
- public int length() { return ByteArray.readU16bit(get(), 0); }
+ public int tableLength() { return ByteArray.readU16bit(get(), 0); }
/**
* Returns <code>classes[nth].inner_class_info_index</code>.
diff --git a/src/main/javassist/bytecode/LineNumberAttribute.java b/src/main/javassist/bytecode/LineNumberAttribute.java
index 4e888bc1..0a6df55a 100644
--- a/src/main/javassist/bytecode/LineNumberAttribute.java
+++ b/src/main/javassist/bytecode/LineNumberAttribute.java
@@ -20,7 +20,7 @@ import java.io.IOException;
import java.util.Map;
/**
- * <code>LineNumberTablec_attribute</code>.
+ * <code>LineNumberTable_attribute</code>.
*/
public class LineNumberAttribute extends AttributeInfo {
/**
diff --git a/src/main/javassist/bytecode/LocalVariableAttribute.java b/src/main/javassist/bytecode/LocalVariableAttribute.java
new file mode 100644
index 00000000..74262b67
--- /dev/null
+++ b/src/main/javassist/bytecode/LocalVariableAttribute.java
@@ -0,0 +1,159 @@
+/*
+ * Javassist, a Java-bytecode translator toolkit.
+ * Copyright (C) 1999-2003 Shigeru Chiba. All Rights Reserved.
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. Alternatively, the contents of this file may be used under
+ * the terms of the GNU Lesser General Public License Version 2.1 or later.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ */
+
+package javassist.bytecode;
+
+import java.io.DataInputStream;
+import java.io.IOException;
+import java.util.Map;
+
+/**
+ * <code>LocalVariableTable_attribute</code>.
+ */
+public class LocalVariableAttribute extends AttributeInfo {
+ /**
+ * The name of this attribute <code>"LocalVariableTable"</code>.
+ */
+ public static final String tag = "LocalVariableTable";
+
+ LocalVariableAttribute(ConstPool cp, int n, DataInputStream in)
+ throws IOException
+ {
+ super(cp, n, in);
+ }
+
+ private LocalVariableAttribute(ConstPool cp, byte[] i) {
+ super(cp, tag, i);
+ }
+
+ /**
+ * Returns <code>local_variable_table_length</code>.
+ * This represents the number of entries in the table.
+ */
+ public int tableLength() {
+ return ByteArray.readU16bit(info, 0);
+ }
+
+ /**
+ * Returns <code>local_variable_table[i].start_pc</code>.
+ * This represents the index into the code array from which the local
+ * variable is effective.
+ *
+ * @param i the i-th entry.
+ */
+ public int startPc(int i) {
+ return ByteArray.readU16bit(info, i * 10 + 2);
+ }
+
+ /**
+ * Returns <code>local_variable_table[i].length</code>.
+ * This represents the length of the code region in which the local
+ * variable is effective.
+ *
+ * @param i the i-th entry.
+ */
+ public int codeLength(int i) {
+ return ByteArray.readU16bit(info, i * 10 + 4);
+ }
+
+ /**
+ * Returns <code>local_variable_table[i].name_index</code>.
+ * This represents the name of the local variable.
+ *
+ * @param i the i-th entry.
+ */
+ public int nameIndex(int i) {
+ return ByteArray.readU16bit(info, i * 10 + 6);
+ }
+
+ /**
+ * Returns the name of the local variable
+ * specified by <code>local_variable_table[i].name_index</code>.
+ *
+ * @param i the i-th entry.
+ */
+ public String variableName(int i) {
+ return getConstPool().getUtf8Info(nameIndex(i));
+ }
+
+ /**
+ * Returns <code>local_variable_table[i].descriptor_index</code>.
+ * This represents the type descriptor of the local variable.
+ *
+ * @param i the i-th entry.
+ */
+ public int descriptorIndex(int i) {
+ return ByteArray.readU16bit(info, i * 10 + 8);
+ }
+
+ /**
+ * Returns the type descriptor of the local variable
+ * specified by <code>local_variable_table[i].descriptor_index</code>.
+ *
+ * @param i the i-th entry.
+ */
+ public String descriptor(int i) {
+ return getConstPool().getUtf8Info(descriptorIndex(i));
+ }
+
+ /**
+ * Returns <code>local_variable_table[i].index</code>.
+ * This represents the index of the local variable.
+ *
+ * @param i the i-th entry.
+ */
+ public int index(int i) {
+ return ByteArray.readU16bit(info, i * 10 + 10);
+ }
+
+ /**
+ * Makes a copy.
+ *
+ * @param newCp the constant pool table used by the new copy.
+ * @param classnames should be null.
+ */
+ public AttributeInfo copy(ConstPool newCp, Map classnames) {
+ byte[] src = get();
+ byte[] dest = new byte[src.length];
+ ConstPool cp = getConstPool();
+ LocalVariableAttribute attr = new LocalVariableAttribute(newCp, dest);
+ int n = ByteArray.readU16bit(src, 0);
+ ByteArray.write16bit(n, dest, 0);
+ int j = 2;
+ for (int i = 0; i < n; ++i) {
+ int start = ByteArray.readU16bit(src, j);
+ int len = ByteArray.readU16bit(src, j + 2);
+ int name = ByteArray.readU16bit(src, j + 4);
+ int type = ByteArray.readU16bit(src, j + 6);
+ int index = ByteArray.readU16bit(src, j + 8);
+
+ ByteArray.write16bit(start, dest, j);
+ ByteArray.write16bit(len, dest, j + 2);
+ if (name != 0)
+ name = cp.copy(name, newCp, null);
+
+ ByteArray.write16bit(name, dest, j + 4);
+
+ if (type != 0)
+ type = cp.copy(type, newCp, null);
+
+ ByteArray.write16bit(type, dest, j + 6);
+ ByteArray.write16bit(index, dest, j + 8);
+ j += 10;
+ }
+
+ return attr;
+ }
+}
diff --git a/src/main/javassist/bytecode/MethodInfo.java b/src/main/javassist/bytecode/MethodInfo.java
index 272b2603..1dbbd864 100644
--- a/src/main/javassist/bytecode/MethodInfo.java
+++ b/src/main/javassist/bytecode/MethodInfo.java
@@ -21,7 +21,6 @@ import java.io.IOException;
import java.util.Map;
import java.util.List;
import java.util.LinkedList;
-import javassist.CannotCompileException;
/**
* <code>method_info</code> structure.