mercredi 6 mai 2015

Javassist - CannotCompileException: constructor/method declaration not found

I've got the following class which i want to use in my generated code with Javassist.

public class SomeClass {
    private String someString;
    private Object someValue;

    public SomeClass() {}

    public SomeClass(String someString, Object someValue) {
        this.someString = someString;
        this.someValue = someValue;
    }

    public void setSomeValue(Object someValue) {
        this.someValue = someValue;
    }

In Javassist i analyse some classes and their fields and then try to instatiate my SomeClass-class. But i get the following error for each field which has another type then java.lang.Object.

javassist.CannotCompileException: [source error] setSomeValue(int) not found in com.test.SomeClass

and

javassist.CannotCompileException: [source error] setSomeValue(double) not found in com.test.SomeClass

and so on. The same happens when i try to use the constructor.

Why this doesn't work?

By the way, Javassist is used in conjunction with Android.

Aucun commentaire:

Enregistrer un commentaire