[jboss-jira] [JBoss JIRA] (JASSIST-235) CtClassType.getEnclosingBehavior()

Shigeru Chiba (JIRA) issues at jboss.org
Tue Nov 18 01:49:39 EST 2014


     [ https://issues.jboss.org/browse/JASSIST-235?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Shigeru Chiba closed JASSIST-235.
---------------------------------


> CtClassType.getEnclosingBehavior()
> ----------------------------------
>
>                 Key: JASSIST-235
>                 URL: https://issues.jboss.org/browse/JASSIST-235
>             Project: Javassist
>          Issue Type: Enhancement
>    Affects Versions: 3.19.0-GA
>            Reporter: Maximilian Scherr
>            Assignee: Shigeru Chiba
>            Priority: Minor
>              Labels: CtBehavior, class, enclosing, inner, method
>             Fix For: 3.19.0-GA
>
>   Original Estimate: 2 days
>  Remaining Estimate: 2 days
>
> The method {{getEnclosingMethod()}} in {{CtClassType}} (or {{CtClass}}) only works with non-constructor methods ({{CtMethod}}).
> However, the JVM's {{Enclosing Method Attribute}} is not restricted to non-constructor methods ({{CtMethod}}).
> Method-local inner classes can be declared within constructors.
> I suggest the addition of a {{getEnclosingBehavior()}} method as follows:
> {code:title=getEnclosingBehavior|borderStyle=solid}
> public CtBehavior getEnclosingBehavior() throws NotFoundException {
>     ClassFile cf = getClassFile2();
>     EnclosingMethodAttribute ema
>             = (EnclosingMethodAttribute)cf.getAttribute(
>                                             EnclosingMethodAttribute.tag);
>     if (ema != null) {
>         CtClass enc = classPool.get(ema.className());
>         String name = ema.methodName();
>         switch (name) {
>             case MethodInfo.nameInit:
>                 return enc.getConstructor(ema.methodDescriptor());
>             case MethodInfo.nameClinit:
>                 return enc.getClassInitializer();
>             default:
>                 return enc.getMethod(name, ema.methodDescriptor());
>         }
>     }
>     return null;        
> }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.8#6338)


More information about the jboss-jira mailing list