ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dominique Devienne <DDevie...@lgc.com>
Subject RE: Unresolved compilation problem - why?
Date Fri, 02 Jul 2004 09:45:48 GMT
Hmmm, I don't know. Not very helpful, uh ;-)

But really, is using reflection mandatory here? Why can't your custom task
can compile directly against the Schema class? You'd probably get much more
explicit errors than the ones the VM gives you at runtime.

I've very rarelly needed to do reflection in custom task, so before going
any further, please confirm it's absolutely necessary, even the why if it's
not asking too much. Thanks, --DD

-----Original Message-----
From: Jochen Wiedmann
To: user@ant.apache.org
Sent: 7/2/2004 4:25 AM
Subject: Unresolved compilation problem - why?


Hi,

I have a custom Ant task, that works with reflection. The Ant task is
loaded 
over a ClassLoader created with the "path" type. Now, my code looks like
this:

     // The ClassLoader is the AntClassLoader used to load the custom
Ant
     // task. It is also used to instantiate the class pClass.
     ClassLoader cl = pClass.getClassLoader();
     try {
         cl.loadClass("com.sag.justus.vo.Schema");
         System.err.println("Successful load of Schema class");
     } catch (Throwable t) {
         t.printStackTrace();
     }
     try {
         pClass.newInstance();
         System.err.println("Successful instantiation");
     } catch (Throwable t) {
         t.printStackTrace();
     }

The output looks as follows. Note, that the output claims, that the
class 
com.sag.justus.vo.Schema cannot be imported into the constructor of
pClass, 
although that classes ClassLoader can very well load that class.

Any ideas, what might be wrong? Or what I can do for further debugging
the 
problem?


Jochen


     [jaxme] Successful load of Schema class
     [jaxme] java.lang.Error: Unresolved compilation problems:
     [jaxme]     The import com.sag.justus.vo.Schema cannot be resolved
     [jaxme]     Schema cannot be resolved
     [jaxme]     Schema cannot be resolved
     [jaxme]     Schema cannot be resolved
     [jaxme]     Schema cannot be resolved

     [jaxme]     at 
com.sag.justus.server.query.view.QueryOffeneStatistikFG.<init>(QueryOffe
neStatistikFG.java:6)
     [jaxme]     at 
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
     [jaxme]     at 
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorA
ccessorImpl.java:39)
     [jaxme]     at 
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingCons
tructorAccessorImpl.java:27)
     [jaxme]     at 
java.lang.reflect.Constructor.newInstance(Constructor.java:274)
     [jaxme]     at java.lang.Class.newInstance0(Class.java:308)
     [jaxme]     at java.lang.Class.newInstance(Class.java:261)
     [jaxme]     at 
com.sag.justus.generator.QuerySchemaReader.getElement(QuerySchemaReader.
java:68)

Die unterste Zeile ist der obige Quelltext. Mit anderen Worten: Ich kann

über den ClassLoader die Klasse Schema laden. Ich kann aber nicht beim 
Instanziieren der Klasse über den selben ClassLoader dieselbe Klasse 
importieren?


Gruß,

Jochen


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message