aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Readme.html1
-rw-r--r--src/main/javassist/CtClassType.java1
-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
-rw-r--r--src/main/javassist/compiler/Javac.java5
-rw-r--r--src/main/javassist/compiler/ast/Declarator.java2
-rw-r--r--src/main/javassist/convert/TransformAfter.java2
-rw-r--r--src/main/javassist/convert/TransformBefore.java1
-rw-r--r--src/main/javassist/convert/TransformCall.java1
-rw-r--r--src/main/javassist/convert/TransformFieldAccess.java1
-rw-r--r--src/main/javassist/convert/TransformReadField.java1
-rw-r--r--src/main/javassist/convert/TransformWriteField.java1
-rw-r--r--src/main/javassist/expr/Handler.java1
-rw-r--r--src/main/javassist/expr/NewExpr.java1
-rw-r--r--src/main/javassist/reflect/ClassMetaobject.java1
-rw-r--r--src/main/javassist/reflect/Reflection.java1
-rw-r--r--src/main/javassist/rmi/ObjectImporter.java1
-rw-r--r--src/main/javassist/rmi/StubGenerator.java1
-rw-r--r--src/main/javassist/web/Webserver.java2
26 files changed, 168 insertions, 29 deletions
diff --git a/Readme.html b/Readme.html
index 6dd0f2c6..f0e39df7 100644
--- a/Readme.html
+++ b/Readme.html
@@ -250,6 +250,7 @@ see javassist.Dump.
<ul>
<li>ClassPool.SimpleLoader has been public.
<li>javassist.bytecode.DeprecatedAttribute has been added.
+ <li>javassist.bytecode.LocalVariableAttribute has been added.
</ul>
<p>- version 2.6 in August, 2003.
diff --git a/src/main/javassist/CtClassType.java b/src/main/javassist/CtClassType.java
index 1e73f5d0..33d286c0 100644
--- a/src/main/javassist/CtClassType.java
+++ b/src/main/javassist/CtClassType.java
@@ -20,7 +20,6 @@ import javassist.compiler.Javac;
import javassist.compiler.CompileError;
import javassist.expr.ExprEditor;
import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
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.
diff --git a/src/main/javassist/compiler/Javac.java b/src/main/javassist/compiler/Javac.java
index 45d370bb..12d4b208 100644
--- a/src/main/javassist/compiler/Javac.java
+++ b/src/main/javassist/compiler/Javac.java
@@ -23,7 +23,6 @@ import javassist.CtBehavior;
import javassist.CtMethod;
import javassist.CtConstructor;
import javassist.CannotCompileException;
-import javassist.ClassPool;
import javassist.Modifier;
import javassist.bytecode.Bytecode;
import javassist.bytecode.Opcode;
@@ -120,7 +119,7 @@ public class Javac {
Declarator d = fd.getDeclarator();
f = new CtFieldWithInit(gen.lookupClass(d), d.getVariable().get(),
gen.getThisClass());
- f.setModifiers(gen.getModifiers(fd.getModifiers()));
+ f.setModifiers(MemberCodeGen.getModifiers(fd.getModifiers()));
if (fd.getInit() != null)
f.setInit(fd.getInit());
@@ -130,7 +129,7 @@ public class Javac {
private CtMember compileMethod(Parser p, MethodDecl md)
throws CompileError
{
- int mod = gen.getModifiers(md.getModifiers());
+ int mod = MemberCodeGen.getModifiers(md.getModifiers());
CtClass[] plist = gen.makeParamList(md);
CtClass[] tlist = gen.makeThrowsList(md);
recordParams(plist, Modifier.isStatic(mod));
diff --git a/src/main/javassist/compiler/ast/Declarator.java b/src/main/javassist/compiler/ast/Declarator.java
index 55e4a42d..a23705e7 100644
--- a/src/main/javassist/compiler/ast/Declarator.java
+++ b/src/main/javassist/compiler/ast/Declarator.java
@@ -60,7 +60,7 @@ public class Declarator extends ASTList implements TokenId {
Declarator d = new Declarator(this.varType, this.arrayDim + dim);
d.qualifiedClass = this.qualifiedClass;
d.setLeft(sym);
- d.append(d, init);
+ append(d, init);
return d;
}
diff --git a/src/main/javassist/convert/TransformAfter.java b/src/main/javassist/convert/TransformAfter.java
index 92c36ebd..6430fe6b 100644
--- a/src/main/javassist/convert/TransformAfter.java
+++ b/src/main/javassist/convert/TransformAfter.java
@@ -15,11 +15,9 @@
package javassist.convert;
-import javassist.CtClass;
import javassist.CtMethod;
import javassist.NotFoundException;
import javassist.bytecode.*;
-import javassist.CannotCompileException;
public class TransformAfter extends TransformBefore {
public TransformAfter(Transformer next,
diff --git a/src/main/javassist/convert/TransformBefore.java b/src/main/javassist/convert/TransformBefore.java
index cd4e5ec3..b1d40afc 100644
--- a/src/main/javassist/convert/TransformBefore.java
+++ b/src/main/javassist/convert/TransformBefore.java
@@ -19,7 +19,6 @@ import javassist.CtClass;
import javassist.CtMethod;
import javassist.NotFoundException;
import javassist.bytecode.*;
-import javassist.CannotCompileException;
public class TransformBefore extends TransformCall {
protected CtClass[] parameterTypes;
diff --git a/src/main/javassist/convert/TransformCall.java b/src/main/javassist/convert/TransformCall.java
index 8ec77241..d76e483d 100644
--- a/src/main/javassist/convert/TransformCall.java
+++ b/src/main/javassist/convert/TransformCall.java
@@ -18,7 +18,6 @@ package javassist.convert;
import javassist.CtClass;
import javassist.CtMethod;
import javassist.bytecode.*;
-import javassist.CannotCompileException;
public class TransformCall extends Transformer {
protected String classname, methodname, methodDescriptor;
diff --git a/src/main/javassist/convert/TransformFieldAccess.java b/src/main/javassist/convert/TransformFieldAccess.java
index 9579c867..684fafe3 100644
--- a/src/main/javassist/convert/TransformFieldAccess.java
+++ b/src/main/javassist/convert/TransformFieldAccess.java
@@ -19,7 +19,6 @@ import javassist.bytecode.*;
import javassist.CtClass;
import javassist.CtField;
import javassist.Modifier;
-import javassist.CannotCompileException;
final public class TransformFieldAccess extends Transformer {
private String newClassname, newFieldname;
diff --git a/src/main/javassist/convert/TransformReadField.java b/src/main/javassist/convert/TransformReadField.java
index e7b1f14b..9771e28d 100644
--- a/src/main/javassist/convert/TransformReadField.java
+++ b/src/main/javassist/convert/TransformReadField.java
@@ -19,7 +19,6 @@ import javassist.bytecode.*;
import javassist.ClassPool;
import javassist.CtClass;
import javassist.CtField;
-import javassist.CannotCompileException;
import javassist.NotFoundException;
import javassist.Modifier;
diff --git a/src/main/javassist/convert/TransformWriteField.java b/src/main/javassist/convert/TransformWriteField.java
index 59fbee6d..51859661 100644
--- a/src/main/javassist/convert/TransformWriteField.java
+++ b/src/main/javassist/convert/TransformWriteField.java
@@ -18,7 +18,6 @@ package javassist.convert;
import javassist.CtClass;
import javassist.CtField;
import javassist.bytecode.*;
-import javassist.CannotCompileException;
final public class TransformWriteField extends TransformReadField {
public TransformWriteField(Transformer next, CtField field,
diff --git a/src/main/javassist/expr/Handler.java b/src/main/javassist/expr/Handler.java
index 27618b27..205322fa 100644
--- a/src/main/javassist/expr/Handler.java
+++ b/src/main/javassist/expr/Handler.java
@@ -18,7 +18,6 @@ package javassist.expr;
import javassist.*;
import javassist.bytecode.*;
import javassist.compiler.*;
-import javassist.compiler.ast.ASTList;
/**
* Catch clause.
diff --git a/src/main/javassist/expr/NewExpr.java b/src/main/javassist/expr/NewExpr.java
index c6ee1f4b..2452b95c 100644
--- a/src/main/javassist/expr/NewExpr.java
+++ b/src/main/javassist/expr/NewExpr.java
@@ -18,7 +18,6 @@ package javassist.expr;
import javassist.*;
import javassist.bytecode.*;
import javassist.compiler.*;
-import javassist.compiler.ast.ASTree;
import javassist.compiler.ast.ASTList;
/**
diff --git a/src/main/javassist/reflect/ClassMetaobject.java b/src/main/javassist/reflect/ClassMetaobject.java
index fbcae1c8..dfcc2480 100644
--- a/src/main/javassist/reflect/ClassMetaobject.java
+++ b/src/main/javassist/reflect/ClassMetaobject.java
@@ -20,7 +20,6 @@ import java.io.Serializable;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
-import javassist.CtClass;
/**
* A runtime class metaobject.
diff --git a/src/main/javassist/reflect/Reflection.java b/src/main/javassist/reflect/Reflection.java
index 589b3d3b..30fea847 100644
--- a/src/main/javassist/reflect/Reflection.java
+++ b/src/main/javassist/reflect/Reflection.java
@@ -16,7 +16,6 @@
package javassist.reflect;
import javassist.*;
-import java.io.IOException;
import javassist.CtMethod.ConstParameter;
/**
diff --git a/src/main/javassist/rmi/ObjectImporter.java b/src/main/javassist/rmi/ObjectImporter.java
index b9affb89..c89b6eeb 100644
--- a/src/main/javassist/rmi/ObjectImporter.java
+++ b/src/main/javassist/rmi/ObjectImporter.java
@@ -17,7 +17,6 @@ package javassist.rmi;
import java.io.*;
import java.net.*;
-import java.awt.*;
import java.applet.Applet;
import java.lang.reflect.*;
diff --git a/src/main/javassist/rmi/StubGenerator.java b/src/main/javassist/rmi/StubGenerator.java
index e604d392..308c36e9 100644
--- a/src/main/javassist/rmi/StubGenerator.java
+++ b/src/main/javassist/rmi/StubGenerator.java
@@ -15,7 +15,6 @@
package javassist.rmi;
-import java.io.*;
import javassist.*;
import java.lang.reflect.Method;
import java.util.Hashtable;
diff --git a/src/main/javassist/web/Webserver.java b/src/main/javassist/web/Webserver.java
index d7a988ea..f1d362f5 100644
--- a/src/main/javassist/web/Webserver.java
+++ b/src/main/javassist/web/Webserver.java
@@ -17,10 +17,8 @@ package javassist.web;
import java.net.*;
import java.io.*;
-import java.util.Hashtable;
import java.util.Date;
import javassist.ClassPool;
-import javassist.Translator;
/**
* A web server for Javassist.