77 try {
78 // non-null object parameter
79 m.canAccess(INSTANCE);
80 assertTrue(false);
81 } catch (IllegalArgumentException expected) { }
82 }
83
84 /**
85 * Test protected static
86 */
87 public void testProtectedStatic() throws Exception {
88 Method m = TestLoader.testProtectedStatic();
89 assertFalse(m.canAccess(null));
90 }
91
92 /**
93 * the specified object must be an instance of the declaring class
94 * for instance members
95 */
96 public void testInstanceMethod() throws Exception {
97 Method m = Unsafe.class.getDeclaredMethod("addressSize0");
98 assertFalse(m.canAccess(INSTANCE));
99
100 try {
101 m.canAccess(null);
102 assertTrue(false);
103 } catch (IllegalArgumentException expected) { }
104 }
105
106 /**
107 * the specified object must be an instance of the declaring class
108 * for instance members
109 */
110 public void testInvalidInstanceObject() throws Exception {
111 Class<?> clazz = Class.forName("sun.security.x509.X500Name");
112 Method m = clazz.getDeclaredMethod("size");
113
114 try {
115 m.canAccess(INSTANCE);
116 assertTrue(false);
117 } catch (IllegalArgumentException expected) { }
|
77 try {
78 // non-null object parameter
79 m.canAccess(INSTANCE);
80 assertTrue(false);
81 } catch (IllegalArgumentException expected) { }
82 }
83
84 /**
85 * Test protected static
86 */
87 public void testProtectedStatic() throws Exception {
88 Method m = TestLoader.testProtectedStatic();
89 assertFalse(m.canAccess(null));
90 }
91
92 /**
93 * the specified object must be an instance of the declaring class
94 * for instance members
95 */
96 public void testInstanceMethod() throws Exception {
97 Method m = Unsafe.class.getDeclaredMethod("allocateMemory0", long.class);
98 assertFalse(m.canAccess(INSTANCE));
99
100 try {
101 m.canAccess(null);
102 assertTrue(false);
103 } catch (IllegalArgumentException expected) { }
104 }
105
106 /**
107 * the specified object must be an instance of the declaring class
108 * for instance members
109 */
110 public void testInvalidInstanceObject() throws Exception {
111 Class<?> clazz = Class.forName("sun.security.x509.X500Name");
112 Method m = clazz.getDeclaredMethod("size");
113
114 try {
115 m.canAccess(INSTANCE);
116 assertTrue(false);
117 } catch (IllegalArgumentException expected) { }
|