added LocalVariableAttribute. git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@46 30ef5769-5b8d-40dd-aea6-55b5d6557bb3tags/rel_3_17_1_ga
@@ -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. |
@@ -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; |
@@ -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)) |
@@ -15,9 +15,6 @@ | |||
package javassist.bytecode; | |||
import java.io.DataOutputStream; | |||
import java.io.IOException; | |||
import javassist.CannotCompileException; | |||
import javassist.CtClass; | |||
import javassist.CtPrimitiveType; | |||
@@ -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>. |
@@ -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>. |
@@ -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; | |||
@@ -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>. |
@@ -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 { | |||
/** |
@@ -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; | |||
} | |||
} |
@@ -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. |
@@ -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)); |
@@ -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; | |||
} | |||
@@ -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, |
@@ -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; |
@@ -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; |
@@ -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; |
@@ -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; | |||
@@ -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, |
@@ -18,7 +18,6 @@ package javassist.expr; | |||
import javassist.*; | |||
import javassist.bytecode.*; | |||
import javassist.compiler.*; | |||
import javassist.compiler.ast.ASTList; | |||
/** | |||
* Catch clause. |
@@ -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; | |||
/** |
@@ -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. |
@@ -16,7 +16,6 @@ | |||
package javassist.reflect; | |||
import javassist.*; | |||
import java.io.IOException; | |||
import javassist.CtMethod.ConstParameter; | |||
/** |
@@ -17,7 +17,6 @@ package javassist.rmi; | |||
import java.io.*; | |||
import java.net.*; | |||
import java.awt.*; | |||
import java.applet.Applet; | |||
import java.lang.reflect.*; | |||
@@ -15,7 +15,6 @@ | |||
package javassist.rmi; | |||
import java.io.*; | |||
import javassist.*; | |||
import java.lang.reflect.Method; | |||
import java.util.Hashtable; |
@@ -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. |