101 throw new RuntimeException("Test Failed, an IAE should be thrown since p2/c2's method2 is private"); |
101 throw new RuntimeException("Test Failed, an IAE should be thrown since p2/c2's method2 is private"); |
102 } catch (IllegalAccessError e) { |
102 } catch (IllegalAccessError e) { |
103 String message = e.getMessage(); |
103 String message = e.getMessage(); |
104 System.out.println(e.toString()); |
104 System.out.println(e.toString()); |
105 // java.lang.IllegalAccessError: |
105 // java.lang.IllegalAccessError: |
106 // tried to access method p2.c2.method2()V from class p1.c1 (p2.c2 is in module m2x of loader |
106 // tried to access private method p2.c2.method2()V from class p1.c1 (p2.c2 is in module m2x of loader |
107 // myloaders.MySameClassLoader @<id>; p1.c1 is in module m1x of loader myloaders.MySameClassLoader @<id>) |
107 // myloaders.MySameClassLoader @<id>; p1.c1 is in module m1x of loader myloaders.MySameClassLoader @<id>) |
108 if (!message.contains("class p1.c1 tried to access method p2.c2.method2()V (p1.c1 is in module m1x of loader myloaders.MySameClassLoader @") || |
108 if (!message.contains("class p1.c1 tried to access private method p2.c2.method2()V " + |
|
109 "(p1.c1 is in module m1x of loader myloaders.MySameClassLoader @") || |
109 !message.contains("; p2.c2 is in module m2x of loader myloaders.MySameClassLoader @")) { |
110 !message.contains("; p2.c2 is in module m2x of loader myloaders.MySameClassLoader @")) { |
110 throw new RuntimeException("Test Failed, an IAE was thrown with the wrong message: " + e.toString()); |
111 throw new RuntimeException("Test Failed, an IAE was thrown with the wrong message: " + e.toString()); |
111 } |
112 } |
112 } catch (Throwable e) { |
113 } catch (Throwable e) { |
113 throw new RuntimeException("Test Failed, an IAE should be thrown since p2/c2's method2 is private"); |
114 throw new RuntimeException("Test Failed, an IAE should be thrown since p2/c2's method2 is private"); |