Is there a way to create new instance of generic type using java , i have used type resolver to get the parametrized and i was able to get it. type but whenever i call this.myclass.newInstance() an instantiation exception is raised. i know the same question is asked but no answer has solved my problem. Pre Thanks.
Asked
Active
Viewed 105 times
1
-
How about MyClass.newInstance()? – shaunw Jun 06 '13 at 20:54
-
2What *exact* exception was raised? Type erasure actually makes constructing an instance of a generic type with reflection relatively straightforward - you don't need to specify the type arguments because the object isn't aware of them. – Jon Skeet Jun 06 '13 at 20:54
-
http://docs.oracle.com/javase/tutorial/reflect/member/ctorInstance.html – shaunw Jun 06 '13 at 20:55
-
1dup http://stackoverflow.com/questions/1090458/instantiating-a-generic-class-in-java – Amir Afghani Jun 06 '13 at 20:55
-
7Your question is missing two important things: Post your **Code** and the **full stack trace** – BackSlash Jun 06 '13 at 20:55