java - accessing private inner class field using reflection -
I'm wondering how I can use a private internal classroom private sector through reflections for my JUnit tests Can i
Here's an example of what I want:
Public category A {Private map & lt; Integer, innerclas & gt; ObjectMap = New TreeMap & lt; Integer, InnerClass & gt; .descendingMap (); Private class Innerclass {Private full field is a private area area} 2}} In this example, I want to use values of field-on-field and fieldTo which is in the example of A.
I have tried the following:
An example A = new A (); Field Private ObjectMafield = Eccleslate.GetDeclairField ("ObjectMap"); PrivateObjectMapField.setAccessible (true); Naviglalm & lt; Integer, class & lt ;? & Gt; & Gt; FieldValue = (NavigableMap & lt; integer, class? Lt;? & Gt; & gt;) Private ObjectMailedGet (example A); // 5 is a major in the map so it declared class to the inner class class In this case these accidents: class with error: java.lang.ClassCastException: com.test.A $ inner class can not be entered in Java. Lang.class Does anyone know what's wrong here?
I hope this example is clear.
Thanks
should be
Naviglalm & lt; Integer, InnerClass & gt; FieldValue = (NavigableMap & lt; Integer, Innerclass & gt;) Private ObjectMfieldGet (example A);
Comments
Post a Comment