private static boolean isDirectAccessAllowed( FieldNode a, ClassNode receiver, boolean isSamePackage) { ClassNode declaringClass = a.getDeclaringClass().redirect(); ClassNode receiverType = receiver.redirect(); // first, direct access from within the class or inner class nodes if (declaringClass.equals(receiverType)) return true; if (receiverType instanceof InnerClassNode) { while (receiverType != null && receiverType instanceof InnerClassNode) { if (declaringClass.equals(receiverType)) return true; receiverType = receiverType.getOuterClass(); } } // no getter return a.isPublic() || (a.isProtected() && isSamePackage); }