jeudi 13 avril 2017

java.lang.AbstractMethodError with javassist and abstract generic classes

i want to execute a method within a generated class that extends an abstract generic one but it throws java.lang.AbstractMethodError.

PS: the generic class is not generated

Example:

public abstract class AbstractSpecification<T> implements Specification<T>{
    public abstract boolean isSatisfiedBy(T t); 
    public Specification<T> and(final Specification<T> specification) {
        return new AndSpecification<T>(this, specification);
    }
}

The generated class is

ClassPool pool = new ClassPool(true);
pool.insertClassPath(new ClassClassPath(AbstractSpecification.class));
CtClass abstractClazz = pool.get("com.mycompany.AbstractSpecification");
CtClass myclass = pool.makeClass("ValidAge");
myclass.setSuperclass(abstractClazz);
.
.
.

Invoking isSatisfiedBy works but and throws java.lang.AbstractMethodError





Aucun commentaire:

Enregistrer un commentaire