MCPcopy Index your code
hub / github.com/BruceEckel/OnJava8-Examples / main

Method main

reflection/HiddenImplementation.java:11–27  ·  view source on GitHub ↗
(String[] args)

Source from the content-addressed store, hash-verified

9
10public 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 {

Callers

nothing calls this directly

Calls 3

makeAMethod · 0.95
fMethod · 0.95
callHiddenMethodMethod · 0.95

Tested by

no test coverage detected