diff options
author | chiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3> | 2005-11-22 16:51:12 +0000 |
---|---|---|
committer | chiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3> | 2005-11-22 16:51:12 +0000 |
commit | ecb71c75155bdd2990141314db777348fdf313ff (patch) | |
tree | d45c70c481bf274e87dd9ecbbc41670e51e080ef /src/main/javassist/bytecode/Bytecode.java | |
parent | a1419a5df6a881f26d3eedacb37d9ea616764cf0 (diff) | |
download | javassist-ecb71c75155bdd2990141314db777348fdf313ff.tar.gz javassist-ecb71c75155bdd2990141314db777348fdf313ff.zip |
added some methods to javassist.Bytecode and Descriptor.
git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@225 30ef5769-5b8d-40dd-aea6-55b5d6557bb3
Diffstat (limited to 'src/main/javassist/bytecode/Bytecode.java')
-rw-r--r-- | src/main/javassist/bytecode/Bytecode.java | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/src/main/javassist/bytecode/Bytecode.java b/src/main/javassist/bytecode/Bytecode.java index 32f9d2b2..9fe0bb84 100644 --- a/src/main/javassist/bytecode/Bytecode.java +++ b/src/main/javassist/bytecode/Bytecode.java @@ -1297,9 +1297,29 @@ public class Bytecode extends ByteVector implements Cloneable, Opcode { * @param desc the descriptor of the field type. */ public void addPutstatic(CtClass c, String name, String desc) { + addPutstatic0(c, null, name, desc); + } + + /** + * Appends PUTSTATIC. + * + * @param classname the fully-qualified name of the target class. + * @param filedName the field name. + * @param desc the descriptor of the field type. + */ + public void addPutstatic(String classname, String fieldName, String desc) { + // if classname is null, the target class is THIS. + addPutstatic0(null, classname, fieldName, desc); + } + + private void addPutstatic0(CtClass target, String classname, + String fieldName, String desc) { add(PUTSTATIC); - int ci = constPool.addClassInfo(c); - addIndex(constPool.addFieldrefInfo(ci, name, desc)); + + // target is null if it represents THIS. + int ci = classname == null ? constPool.addClassInfo(target) + : constPool.addClassInfo(classname); + addIndex(constPool.addFieldrefInfo(ci, fieldName, desc)); growStack(-Descriptor.dataSize(desc)); } |