The following test code demonstrates the issue when changing the modifier of Class1.method1():
public class Class1 {
// private static int method1() {
public static int method1() {
return 10;
}
}
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
public class Test {
public static void main(String[] args) throws Exception {
while (true) {
Method m = Class1.class.getDeclaredMethod("method1", new Class[] {});
System.out.println(Modifier.toString(m.getModifiers()));
Thread.sleep(500);
}
}
}