use of java.lang.invoke.MethodHandles.Lookup in project openj9 by eclipse.
the class MethodHandleAPI_privateLookupIn method test_privateLookupIn_TargetClass_callerLookup_DiffferentPackage_SameModule.
/**
* privateLookupIn test for a target class and a caller lookup from different packages within the same module
*/
@Test(groups = { "level.sanity" })
public static void test_privateLookupIn_TargetClass_callerLookup_DiffferentPackage_SameModule() throws Throwable {
Lookup mhprivateLookupIn = privateLookupIn(SameModuleExample.class, callerLookup);
Assert.assertEquals(mhprivateLookupIn.lookupClass(), SameModuleExample.class);
Assert.assertEquals(mhprivateLookupIn.lookupModes() & Lookup.PRIVATE, Lookup.PRIVATE);
}
use of java.lang.invoke.MethodHandles.Lookup in project openj9 by eclipse.
the class MethodHandleAPI_privateLookupIn method test_privateLookupIn_NullcallerLookup.
/**
* privateLookupIn test for a null caller lookup.
*/
@Test(expectedExceptions = NullPointerException.class, groups = { "level.sanity" })
public static void test_privateLookupIn_NullcallerLookup() throws Throwable {
Lookup mhprivateLookupIn = privateLookupIn(Object.class, null);
Assert.fail("The test case failed to detect a null caller lookup");
}
use of java.lang.invoke.MethodHandles.Lookup in project openj9 by eclipse.
the class MethodHandleAPI_privateLookupIn method test_privateLookupIn_TargetClass_PrimitiveType.
/**
* privateLookupIn test for a target class with a primitive type.
*/
@Test(expectedExceptions = IllegalArgumentException.class, groups = { "level.sanity" })
public static void test_privateLookupIn_TargetClass_PrimitiveType() throws Throwable {
Lookup mhprivateLookupIn = privateLookupIn(int.class, callerLookup);
Assert.fail("The test case failed to detect a target class with a primitive type");
}
use of java.lang.invoke.MethodHandles.Lookup in project openj9 by eclipse.
the class LookupInTests method testLookup_in_Assert.
/**
* Validates access restrictions stored in a new Lookup object created from the Lookup object of this class (LookupInTests)
* where the new lookup class is org.testng.Assert.
* @throws Throwable
*/
@Test(groups = { "level.sanity" })
public void testLookup_in_Assert() throws Throwable {
Lookup newLookup = localLookup.in(Assert.class);
assertClassAndMode(newLookup, Assert.class, MODULE_PUBLIC_MODE);
}
use of java.lang.invoke.MethodHandles.Lookup in project openj9 by eclipse.
the class Find_InvokeTracker method test_FindSpecial_Public_SamePackage_Overridden_InnerClass_Nested_Level2.
/**
* findSpecial test using a public overridden method belonging to a second level inner class
* which is a child of a first level inner class (the lookup class) under the same outer class.
* The resultant method handle is bound to LookupAPITests_Find (this class).
* @throws Throwable
*/
@Test(groups = { "level.extended" })
public void test_FindSpecial_Public_SamePackage_Overridden_InnerClass_Nested_Level2() throws Throwable {
SamePackageExample spe = new SamePackageExample();
SamePackageInnerClass spe_inner1 = spe.new SamePackageInnerClass();
Lookup publicLookup = spe_inner1.getLookup();
boolean iaeThrown = false;
try {
publicLookup.findSpecial(SamePackageExample.SamePackageInnerClass2.SamePackageInnerClass2_Nested_Level2_SubOf_Inner1.class, "addPublicInner", MethodType.methodType(int.class, int.class, int.class), LookupAPITests_Find.class);
} catch (IllegalAccessException e) {
iaeThrown = true;
}
assert (iaeThrown);
}
Aggregations