(String[] args)
| 9 | |
| 10 | public class HiddenImplementation { |
| 11 | public static void |
| 12 | main(String[] args) throws Exception { |
| 13 | A a = HiddenC.makeA(); |
| 14 | a.f(); |
| 15 | System.out.println(a.getClass().getName()); |
| 16 | // Compile error: cannot find symbol 'C': |
| 17 | /* if(a instanceof C) { |
| 18 | C c = (C)a; |
| 19 | c.g(); |
| 20 | } */ |
| 21 | // Oops! Reflection still allows us to call g(): |
| 22 | callHiddenMethod(a, "g"); |
| 23 | // And even less accessible methods! |
| 24 | callHiddenMethod(a, "u"); |
| 25 | callHiddenMethod(a, "v"); |
| 26 | callHiddenMethod(a, "w"); |
| 27 | } |
| 28 | static void |
| 29 | callHiddenMethod(Object a, String methodName) |
| 30 | throws Exception { |
nothing calls this directly
no test coverage detected