Presume we have two different packages... one package can't be accessed but we like to know the value of a complex field called b.
public class A {
    private String  whatever;
    private B       b;
    private static class B {
         final ArrayList<Z> c   = new ArrayList<Z>();
         private void addItem(Z z) {
                this.c.add(z);
         }
         private Z getItem(int nr) {
                return this.c.get(nr);
          }
     }
}
public class Reflect extends A {
      public static void main(String[] args) throws NoSuchFieldException, SecurityException {
            Reflect ref = new Reflect();
            Class getA = ref.getClass().getSuperclass();
            Field getB = getDeclaredField("b");
            getB.setAccessible(true);
            Class bInst = getB.getClass();
            Method bMeth = bInst.getMethod("getItem", Integer.TYPE);
            Object zInst = bMeth.invoke(new Integer(123));
      }
}
How can I get the value if I don't get the complex type B from the package ? Still get java.lang.NoSuchMethodException: stackOver.A.getItem(int) even I set the field gstB accessible ....
 
     
     
    