aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/javassist/CtClass.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/javassist/CtClass.java')
-rw-r--r--src/main/javassist/CtClass.java23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/main/javassist/CtClass.java b/src/main/javassist/CtClass.java
index f34a565a..9e4ca20c 100644
--- a/src/main/javassist/CtClass.java
+++ b/src/main/javassist/CtClass.java
@@ -762,8 +762,29 @@ public abstract class CtClass {
*
* @return null if this class is not a local class or an anonymous
* class.
+ * @deprecated The enclosing method might be a constructor.
+ * Use {@link #getEnclosingBehavior()}.
+ * @see #getEnclosingBehavior()
*/
- public CtMethod getEnclosingMethod() throws NotFoundException {
+ public final CtMethod getEnclosingMethod() throws NotFoundException {
+ CtBehavior b = getEnclosingBehavior();
+ if (b == null)
+ return null;
+ else if (b instanceof CtMethod)
+ return (CtMethod)b;
+ else
+ throw new NotFoundException(b.getLongName() + " is enclosing " + getName());
+ }
+
+ /**
+ * Returns the immediately enclosing method of this class.
+ * It might be not a method but a constructor.
+ * This method works only with JDK 1.5 or later.
+ *
+ * @return null if this class is not a local class or an anonymous
+ * class.
+ */
+ public CtBehavior getEnclosingBehavior() throws NotFoundException {
return null;
}