diff options
author | chibash <chiba@javassist.org> | 2016-07-31 12:20:22 +0900 |
---|---|---|
committer | chibash <chiba@javassist.org> | 2016-07-31 12:20:22 +0900 |
commit | c0b62eeabad1f96da80f26339f6cd1986330174f (patch) | |
tree | 6a798bbe32a3793a36a06c9cda051b028e7009b6 /src/main/javassist | |
parent | 384e014fc88037130e346dbe3c95af477bfbbbd4 (diff) | |
download | javassist-c0b62eeabad1f96da80f26339f6cd1986330174f.tar.gz javassist-c0b62eeabad1f96da80f26339f6cd1986330174f.zip |
modifies addInvokestatic() in Bytecode to support a static method declared in an interface type.
Diffstat (limited to 'src/main/javassist')
-rw-r--r-- | src/main/javassist/bytecode/Bytecode.java | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/src/main/javassist/bytecode/Bytecode.java b/src/main/javassist/bytecode/Bytecode.java index 4de69dab..34068f8d 100644 --- a/src/main/javassist/bytecode/Bytecode.java +++ b/src/main/javassist/bytecode/Bytecode.java @@ -1025,13 +1025,20 @@ public class Bytecode extends ByteVector implements Cloneable, Opcode { * @see Descriptor#ofMethod(CtClass,CtClass[]) */ public void addInvokestatic(CtClass clazz, String name, String desc) { - addInvokestatic(constPool.addClassInfo(clazz), name, desc); + boolean isInterface; + if (clazz == THIS) + isInterface = false; + else + isInterface = clazz.isInterface(); + + addInvokestatic(constPool.addClassInfo(clazz), name, desc, isInterface); } /** * Appends INVOKESTATIC. * * @param classname the fully-qualified class name. + * It must not be an interface-type name. * @param name the method name * @param desc the descriptor of the method signature. * @@ -1045,15 +1052,26 @@ public class Bytecode extends ByteVector implements Cloneable, Opcode { * Appends INVOKESTATIC. * * @param clazz the index of <code>CONSTANT_Class_info</code> - * structure. + * structure. It must not be an interface type. * @param name the method name * @param desc the descriptor of the method signature. * * @see Descriptor#ofMethod(CtClass,CtClass[]) */ public void addInvokestatic(int clazz, String name, String desc) { + addInvokestatic(clazz, name, desc, false); + } + + private void addInvokestatic(int clazz, String name, String desc, + boolean isInterface) { add(INVOKESTATIC); - addIndex(constPool.addMethodrefInfo(clazz, name, desc)); + int index; + if (isInterface) + index = constPool.addInterfaceMethodrefInfo(clazz, name, desc); + else + index = constPool.addMethodrefInfo(clazz, name, desc); + + addIndex(index); growStack(Descriptor.dataSize(desc)); } |