[jboss-jira] [JBoss JIRA] Created: (JASSIST-39) failure to compile an instance method which invokes a static method in a different class and both methods have the same return type, name and argument types

twieger (JIRA) jira-events at lists.jboss.org
Thu Dec 27 18:29:43 EST 2007


failure to compile an instance method which invokes a static method in a different class and both methods have the same return type, name and argument types
------------------------------------------------------------------------------------------------------------------------------------------------------------

                 Key: JASSIST-39
                 URL: http://jira.jboss.com/jira/browse/JASSIST-39
             Project: Javassist
          Issue Type: Bug
            Reporter: twieger
         Assigned To: Shigeru Chiba


The testcase below demonstrates the problem. 
The first invocation of CtNewMethod#make works, the second one fails.
It looks like the problem is related with MemberResolver#lookupMethod.
The check to enable the creation of a recursively called method is not precise enough. It actually succeeds, although the current method is an instance method, and the method which shall be invoked is a static method.

==========================================
package experimental;

import javassist.CannotCompileException;
import javassist.ClassPool;
import javassist.CtClass;
import javassist.CtNewMethod;

import org.testng.annotations.Test;


public class TestJavaAssist {
    @Test
    public void testJavaAssist() throws CannotCompileException {
        ClassPool   classPool   = new ClassPool();
        classPool.appendSystemPath();
        
        CtClass     ctClass     = classPool.makeClass("Test");
        CtNewMethod.make("public String foox(){return experimental.TestJavaAssist.foo();}", ctClass);
        CtNewMethod.make("public String foo(){return experimental.TestJavaAssist.foo();}", ctClass);
    }


    public static final String foo() {        
        return "foo";
    }
}


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the jboss-jira mailing list