aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/javassist/bytecode/EnclosingMethodAttribute.java
diff options
context:
space:
mode:
authorchibash <chiba@javassist.org>2014-11-18 15:43:31 +0900
committerchibash <chiba@javassist.org>2014-11-18 15:43:31 +0900
commita0f4d935a20ffeefcfe4c66730ec702b7fff0928 (patch)
tree397f4fda3ebba38bc3c83bb29f087a8caf5b4ab2 /src/main/javassist/bytecode/EnclosingMethodAttribute.java
parentc988383c3921bfd26139c54d6ad4e8f95c48fa0f (diff)
downloadjavassist-a0f4d935a20ffeefcfe4c66730ec702b7fff0928.tar.gz
javassist-a0f4d935a20ffeefcfe4c66730ec702b7fff0928.zip
fixed JASSIST-235. Now CtClass.getEnclosingMethod() is deprecated due to its potential bug.
Diffstat (limited to 'src/main/javassist/bytecode/EnclosingMethodAttribute.java')
-rw-r--r--src/main/javassist/bytecode/EnclosingMethodAttribute.java12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/main/javassist/bytecode/EnclosingMethodAttribute.java b/src/main/javassist/bytecode/EnclosingMethodAttribute.java
index d59955dd..4f422fd7 100644
--- a/src/main/javassist/bytecode/EnclosingMethodAttribute.java
+++ b/src/main/javassist/bytecode/EnclosingMethodAttribute.java
@@ -20,6 +20,8 @@ import java.io.DataInputStream;
import java.io.IOException;
import java.util.Map;
+import javassist.CtConstructor;
+
/**
* <code>EnclosingMethod_attribute</code>.
*/
@@ -98,12 +100,18 @@ public class EnclosingMethodAttribute extends AttributeInfo {
/**
* Returns the method name specified by <code>method_index</code>.
+ * If the method is a class initializer (static constructor),
+ * {@link MethodInfo#nameClinit} is returned.
*/
public String methodName() {
ConstPool cp = getConstPool();
int mi = methodIndex();
- int ni = cp.getNameAndTypeName(mi);
- return cp.getUtf8Info(ni);
+ if (mi == 0)
+ return MethodInfo.nameClinit;
+ else {
+ int ni = cp.getNameAndTypeName(mi);
+ return cp.getUtf8Info(ni);
+ }
}
/**