What i am trying to do: get the value of the a reflected field named "f3" with the type "K". I would like to be able to use the value of f3 to reflect fields from within it.
All methods of getting the value that i try give the error: can not set K field f3 to java.lang.Class.
Question: How can i get the value of "f3" which has the type "K"?
Code that throws IllegalArgumentException:
Field fieldf3 = instance.getDeclaredField("f3"); fieldf3.setAccessible(true); Object value = fieldf3.get(instance); //exception on this line.
exception: java.lang.IllegalArgumentException: Can not set K field b.f3 to java.lang.Class at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:167) at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:171) at sun.reflect.UnsafeFieldAccessorImpl.ensureObj(UnsafeFieldAccessorImpl.java:58) at sun.reflect.UnsafeObjectFieldAccessorImpl.get(UnsafeObjectFieldAccessorImpl.java:36) at java.lang.reflect.Field.get(Field.java:387)
sorry for poor english
Aucun commentaire:
Enregistrer un commentaire