Jérémie Salvucci [http://community.jboss.org/people/vanished_man] created the 
discussion

"Using personnal type : no such class"

To view the discussion, visit: http://community.jboss.org/message/569925#569925

--------------------------------------------------------------
Hello all,

I'm trying to use javassist to create a new class at the execution.

I have a class named TranslatorConstructor and this one should create a class 
Translator. This class is composed of a field. This field is of 
IBinaryOutputFile type (personnal one). So when I get ClassPool thanks to 
ClassPool.getDefault, I do pool.importPackage with my own package 
"tools.IBinaryOutputFile". The problem is that doesn't work... Even if I use a 
class BinaryOutputFile and not an interface...

I'm using eclipse and I configure my project with javassist as an external jar. 
I'm  wondering if it was a good idea because I don't know how javassist does to 
find my class...

public TranslatorConstructor (String className) {
        ClassPool pool = ClassPool.getDefault();
        pool.importPackage("tools.interfaces.IBinaryOutputFile");
        pool.importPackage("tools.BinaryOutputFile");
        clazz = pool.makeClass(className);
    }



public void init () throws CannotCompileException {
        String fieldName = "private IBinaryOuputFile binaryFile;";
        CtField field = CtField.make(fieldName, clazz);
        clazz.addField(field);


When I create the field, an exception occured...

clazz is a class field a TranslatorConstructor affected in the constructor with 
makeClass.

If anyone has an idea about why it doesn't work, it would be great.

Thank you !

--
VanishedMan
--------------------------------------------------------------

Reply to this message by going to Community
[http://community.jboss.org/message/569925#569925]

Start a new discussion in Javassist at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2062]

_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to