Skip to content

Instantly share code, notes, and snippets.

@hamishdickson
Last active September 21, 2015 14:46
Show Gist options
  • Save hamishdickson/79bebbb4027dc7a09ea6 to your computer and use it in GitHub Desktop.
Save hamishdickson/79bebbb4027dc7a09ea6 to your computer and use it in GitHub Desktop.
Calling a private method
public Test {
public void testMyThing() {
MyClass myClass = new MyClass();
Method method = myClass.getClass().getDeclaredMethod("setId", ArgTypeIfAny.class);
privateStringMethod.setAccessible(true);
method.invoke(myClass, args);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment