1 package examples.workshop;
2
3
4 public class HowToAccess {
5 public static void main(String[] args) throws Exception {
6 String myText = "How to access this?";
7 int i = 6;
8
9 final SomePrintingClass printer = new SomePrintingClass();
10
11 Runnable r = () -> { printer.print(myText, i); };
12
13 Runnable myr = MyRunnable.wrap(r);
14
15 inspect(myr);
16 }
17
18
19 private static void inspect(Runnable runnable) throws IllegalAccessException {
20 // I have reference only to printer... can I access some
21 runnable.run();
22 }
23
24
25 }