JBoss Community

getDeclaringClass throws error

created by Ragnar Rova in Javassist - View the full discussion

Hi

 

Why does the following testcase fail with IncompatibleClassChangeError ?

 

package foo;
 
import javassist.*;
 
import org.junit.*;
 
public class GetDeclaringClassTest {
 
    static class Foo {
        String bar;
    }
 
    @Test
    public void get_declaring_class_should_not_throw_error()
            throws NotFoundException, CannotCompileException {
        ClassPool pool = ClassPool.getDefault();
        CtClass cc = pool.get(Foo.class.getName());
        cc.setName(Foo.class.getName() + "$BackRef");
        Class<?> klass = cc.toClass();
        klass.getDeclaringClass();
 
    }
}
 
 
 

Reply to this message by going to Community

Start a new discussion in Javassist at Community