use of java.lang.invoke.MethodHandles.lookup in project openj9 by eclipse.
the class Test_ReflectionAndMethodHandles method test_find_special_child_public_static.
/**
* This method is a negative test to verify that the methodHandle for the public static
* method from the child interface cannot be successfully looked up using findSpecial.
* An IllegalAccessException is expected to be thrown
* @throws IllegalAccessException
*/
@Test
public static void test_find_special_child_public_static() throws Exception {
Class<?> c = Class.forName("ITestChild", true, loadClass);
Lookup lookup = getLookupObject(c);
try {
MethodHandle mh = lookup.findSpecial(c, "child_public_static_method", type, Test_ReflectionAndMethodHandles.class);
Assert.fail("Should have thrown an IllegalAccessException");
} catch (IllegalAccessException e) {
/* Pass */
}
}
use of java.lang.invoke.MethodHandles.lookup in project openj9 by eclipse.
the class Test_ReflectionAndMethodHandles method test_find_special_ancestor_private_static.
/**
* This method is a negative test to verify that the methodHandle for the private static
* method from the parent interface cannot be successfully looked up using findSpecial.
* An IllegalAccessException is expected to be thrown
* @throws IllegalAccessException
*/
@Test
public static void test_find_special_ancestor_private_static() throws Exception {
Class<?> c = Class.forName("ITestChild", true, loadClass);
Lookup lookup = getLookupObject(c);
try {
MethodHandle mh = lookup.findSpecial(c, "private_static_method", type, Test_ReflectionAndMethodHandles.class);
Assert.fail("Should have thrown an IllegalAccessException");
} catch (Exception e) {
AssertJUnit.assertTrue("Failing test as expected IllegalAccessException to get thrown, instead of " + e, e instanceof IllegalAccessException);
}
}
use of java.lang.invoke.MethodHandles.lookup in project openj9 by eclipse.
the class Test_ReflectionAndMethodHandles method test_find_special_ancestor_private_non_static.
/**
* This method is a negative test to verify that the methodHandle for the private non static
* method from the parent interface cannot be successfully looked up using findSpecial.
* An IllegalAccessException is expected to be thrown
* @throws IllegalAccessException
*/
@Test
public static void test_find_special_ancestor_private_non_static() throws Exception {
Class<?> c = Class.forName("ITestChild", true, loadClass);
Lookup lookup = getLookupObject(c);
try {
MethodHandle mh = lookup.findSpecial(c, "private_non_static_method", type, Test_ReflectionAndMethodHandles.class);
Assert.fail("Should have thrown an IllegalAccessException");
} catch (IllegalAccessException e) {
/* Pass */
}
}
use of java.lang.invoke.MethodHandles.lookup in project openj9 by eclipse.
the class Test_ReflectionAndMethodHandles method test_find_static_ancestor_private_static.
/**
* This method is a negative test to verify that the methodHandle for the private static
* method from the parent interface ITest cannot be successfully looked up using findStatic.
* A NoSuchMethodException is expected to be thrown
* @throws NoSuchMethodException
*/
@Test
public static void test_find_static_ancestor_private_static() throws Exception {
Class<?> c = Class.forName("ITestChild", true, loadClass);
Lookup lookup = getLookupObject(c);
try {
MethodHandle mh = lookup.findStatic(c, "private_static_method", type);
Assert.fail("Should have thrown a NoSuchMethodException");
} catch (NoSuchMethodException e) {
/* Pass */
}
}
use of java.lang.invoke.MethodHandles.lookup in project openj9 by eclipse.
the class Test_ReflectionAndMethodHandles method test_find_special_ancestor_public_static.
/**
* This method is a negative test to verify that the methodHandle for the public static
* method from the parent interface cannot be successfully looked up using findSpecial.
* An IllegalAccessException is expected to be thrown
* @throws IllegalAccessException
*/
@Test
public static void test_find_special_ancestor_public_static() throws Exception {
Class<?> c = Class.forName("ITestChild", true, loadClass);
Lookup lookup = getLookupObject(c);
try {
MethodHandle mh = lookup.findSpecial(c, "RunTest_private_static_method_with_InvokeStatic", type, Test_ReflectionAndMethodHandles.class);
Assert.fail("Should have thrown an IllegalAccessException");
} catch (IllegalAccessException e) {
/* Pass */
}
}
Aggregations