How is Groovy able to access private methods of a Java class?
问题 Groovy can access private methods and variables of a Java class. How does Groovy do this behind the scene? Is it because of the use of invokedynamic bytecode instruction which is used by MethodHandle class? I think Java uses invokespecial instruction for calling private methods and invokevirtual for public right which respects access modifiers? 回答1: Groovy is written in Java, so it hopefully doesn't rely on the byte code directly, it doesn't it using the Reflection API. For more details check