aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/javassist/bytecode
diff options
context:
space:
mode:
authorchibash <chiba@javassist.org>2014-11-23 01:08:22 +0900
committerchibash <chiba@javassist.org>2014-11-23 01:08:22 +0900
commitf2093c28be24336593e1ebd9c2c633ee0f8c5b5c (patch)
treea143744ccbf9c43fa70e88940f36f96136870e79 /src/main/javassist/bytecode
parente000e8f682a284b7b5d0c03ca32866e745045fa0 (diff)
downloadjavassist-f2093c28be24336593e1ebd9c2c633ee0f8c5b5c.tar.gz
javassist-f2093c28be24336593e1ebd9c2c633ee0f8c5b5c.zip
fiexed JASSIST-238
Diffstat (limited to 'src/main/javassist/bytecode')
-rw-r--r--src/main/javassist/bytecode/Bytecode.java37
1 files changed, 32 insertions, 5 deletions
diff --git a/src/main/javassist/bytecode/Bytecode.java b/src/main/javassist/bytecode/Bytecode.java
index fb4d3ec9..051619d1 100644
--- a/src/main/javassist/bytecode/Bytecode.java
+++ b/src/main/javassist/bytecode/Bytecode.java
@@ -924,11 +924,14 @@ public class Bytecode extends ByteVector implements Cloneable, Opcode {
* @see Descriptor#ofConstructor(CtClass[])
*/
public void addInvokespecial(CtClass clazz, String name, String desc) {
- addInvokespecial(constPool.addClassInfo(clazz), name, desc);
+ boolean isInterface = clazz == null ? false : clazz.isInterface();
+ addInvokespecial(isInterface,
+ constPool.addClassInfo(clazz), name, desc);
}
/**
- * Appends INVOKESPECIAL.
+ * Appends INVOKESPECIAL. The invoked method must not be a default
+ * method declared in an interface.
*
* @param clazz the fully-qualified class name.
* @param name the method name
@@ -938,11 +941,12 @@ public class Bytecode extends ByteVector implements Cloneable, Opcode {
* @see Descriptor#ofConstructor(CtClass[])
*/
public void addInvokespecial(String clazz, String name, String desc) {
- addInvokespecial(constPool.addClassInfo(clazz), name, desc);
+ addInvokespecial(false, constPool.addClassInfo(clazz), name, desc);
}
/**
- * Appends INVOKESPECIAL.
+ * Appends INVOKESPECIAL. The invoked method must not be a default
+ * method declared in an interface.
*
* @param clazz the index of <code>CONSTANT_Class_info</code>
* structure.
@@ -953,8 +957,31 @@ public class Bytecode extends ByteVector implements Cloneable, Opcode {
* @see Descriptor#ofConstructor(CtClass[])
*/
public void addInvokespecial(int clazz, String name, String desc) {
+ addInvokespecial(false, clazz, name, desc);
+ }
+
+ /**
+ * Appends INVOKESPECIAL.
+ *
+ * @param isInterface true if the invoked method is a default method
+ * declared in an interface.
+ * @param clazz the index of <code>CONSTANT_Class_info</code>
+ * structure.
+ * @param name the method name
+ * @param desc the descriptor of the method signature.
+ *
+ * @see Descriptor#ofMethod(CtClass,CtClass[])
+ * @see Descriptor#ofConstructor(CtClass[])
+ */
+ public void addInvokespecial(boolean isInterface, int clazz, String name, String desc) {
add(INVOKESPECIAL);
- 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) - 1);
}