Java: Invoke a specific method through reflections on a generic type?

Well all method invocation based on reflection is at its most simple about shoving Objects into the method, praying it'll work. So cast & keep your fingers crossed.

Inside of a generic type there is no way to get the name of the type parameter at runtime if nobody did tell it to you. On runtime, a BurningSun and BurningSun are completely equivalent, and you can even cast one into the other (this is not type safe, though). So, usually if you really need the class object of the type parameter inside your generic object, you let someone give it to you in the constructor.

Class BurningSun { private Class paramClass; public BurningSun(Class pClass) { this. ParamClass = pClass; } public void kitchenSink() { T t = paramClass.newInstance(); } } (You would need to catch or declare some exceptions here. ).

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions