Retrieving the inherited attribute names/values using Java Reflection -


I have a Java object 'ChildObj' which has grown from 'parent oz' Now, if all the properties of hair oboes It is possible to retrieve names and values, where the inherited characteristics are also used, using the Java Reflection Mechanism?

I give an array of public attributes, and gives me the array of all fields, but none of those fields are included in the inventory.

Is there any way to recover inherited attributes?

No, you have to write it yourself, this is a normal recurring method that:

  public static list & lt; Field & gt; GetAllFields (List & lt; Field & gt; Field, Class & lt;? & Gt; Types) {fields.addAll (Arrays.asList (type.getDeclaredFields ())); If (type.getSuperclass ()! = Null) {getAllFields (field, type.getSuperclass ()); } Return field; } @Test Public Zero getLinkedListFields () {System.out.println (getAllFields (new linked list & lt; field & gt; (), LinkedList.class); }  

Comments

Popular posts from this blog

c++ - Linux and clipboard -

Visual Studio 2005: How to speed up builds when a VSMDI is open? -

booting ubuntu from usb using virtualbox -