0

I am loading a class from a jarfile at runtime (because the script won't always use that exact jar), so I have a Class object of it. I am also doing that from javax.script.ScriptEngine (javascript). That class has the method public static <T> User get(T base). I need to call it. What is the best way to do it?

It seems to me that there isn't much documentation on scripting for java...

I just need to find a method called "get" in a class with an argument of type T using Class's getMethod(String name, Class[] argumentTypes)...

Eric
  • 87,154
  • 48
  • 211
  • 332
nickguletskii
  • 292
  • 4
  • 9
  • Scripting on java works and isn't that difficult, but your question is very unclear. I sense some sort of a design problem here, not related to scripting at all. What **exactly** are you trying to do? – genobis Apr 12 '11 at 13:51
  • I just need to find a method called "get" in a class with an argument of type T using Class's getMethod(String name, Class[] argumentTypes)... – nickguletskii Apr 12 '11 at 14:30
  • That is something you can't do. Because of **[type erasure](http://download.oracle.com/javase/tutorial/java/generics/erasure.html)**. In short, information about generic types disappears after compilation. – genobis Apr 12 '11 at 14:36
  • Thanks... I solved the problem in a rather ugly way, going through all functions and ignoring their parameters... – nickguletskii Apr 12 '11 at 15:22
  • @nickguletskii: can you please answer the question yourself and then accept that answer? Also, you need to accept answers to previous questions if they fix your problem. – Zecas May 17 '12 at 09:24

0 Answers0