use of java.lang.invoke.MethodHandles.Lookup in project openj9 by eclipse.
the class Find_InvokeTracker method test_GetterSetter_Private_CrossPackage_SuperclassLookup.
/**
* Negative test : findSetter, findGetter tests using a superclass as lookup class and private fields
* belonging to a sub-class under a different package than the lookup ( super ) class.
* @throws Throwable
*/
@Test(groups = { "level.extended" })
public void test_GetterSetter_Private_CrossPackage_SuperclassLookup() throws Throwable {
boolean illegalAccessExceptionThrown = false;
Lookup superclassLookup = PackageExamples.getLookup();
try {
superclassLookup.findSetter(CrossPackageExampleSubclass.class, "nonStaticPrivateField_Child", int.class);
} catch (IllegalAccessException e) {
illegalAccessExceptionThrown = true;
}
AssertJUnit.assertTrue(illegalAccessExceptionThrown);
illegalAccessExceptionThrown = false;
try {
superclassLookup.findGetter(CrossPackageExampleSubclass.class, "nonStaticPrivateField_Child", int.class);
} catch (IllegalAccessException e) {
illegalAccessExceptionThrown = true;
}
AssertJUnit.assertTrue(illegalAccessExceptionThrown);
}
use of java.lang.invoke.MethodHandles.Lookup in project openj9 by eclipse.
the class LookupInTests method testLookup_PublicNestedInnerClassLookup_Level1.
/**
*************************************************
* Tests involving nested public inner classes
* ***********************************************
*/
/**
* Validates access restrictions stored in a new Lookup object created from an old Lookup object
* where the new lookup class is a second level inner class under the old lookup class which is a first level inner class.
* Basically we validate that a nested class C.D can access private members within another nested class C.D.E.
* @throws Throwable
*/
@Test(groups = { "level.sanity" })
public void testLookup_PublicNestedInnerClassLookup_Level1() throws Throwable {
Lookup inObj = samePackageInnerClassLookup.in(SamePackageInnerClass_Nested_Level2.class);
assertClassAndMode(inObj, SamePackageInnerClass_Nested_Level2.class, FULL_ACCESS_MODE);
}
use of java.lang.invoke.MethodHandles.Lookup in project openj9 by eclipse.
the class LookupInTests method testLookup_PublicInnerClassLookup.
/**
*************************************************
* Tests involving public inner classes
* ***********************************************
*/
/**
* Validates access restrictions stored in a new Lookup object created from an old Lookup object
* where the new lookup class is a public inner class under the old lookup class.
* @throws Throwable
*/
@Test(groups = { "level.sanity" })
public void testLookup_PublicInnerClassLookup() throws Throwable {
Lookup inObj = samePackageExampleLookup.in(SamePackageInnerClass.class);
assertClassAndMode(inObj, SamePackageInnerClass.class, FULL_ACCESS_MODE);
}
use of java.lang.invoke.MethodHandles.Lookup in project openj9 by eclipse.
the class LookupInTests method testLookup_CrossPackageLookup_Superclass.
/**
* Validates access restrictions stored in a new Lookup object created from an old Lookup object
* where the new lookup class is the superclass of the old lookup class but is residing in a
* different package than the old lookup class.
* @throws Throwable
*/
@Test(groups = { "level.sanity" })
public void testLookup_CrossPackageLookup_Superclass() throws Throwable {
Lookup lookup = CrossPackageExampleSubclass.getLookup();
Lookup inObject = lookup.in(PackageExamples.class);
assertClassAndMode(inObject, PackageExamples.class, MODULE_PUBLIC_MODE);
}
use of java.lang.invoke.MethodHandles.Lookup in project openj9 by eclipse.
the class LookupInTests method testLookup_StaticInnerClassLookup.
/**
*************************************************
* Tests involving static inner classes
* ***********************************************
*/
/**
* Validates access restrictions stored in a new Lookup object created from an old Lookup object
* where the new lookup class is a static inner class under the old lookup class.
* @throws Throwable
*/
@Test(groups = { "level.sanity" })
public void testLookup_StaticInnerClassLookup() throws Throwable {
Lookup inObj = samePackageExampleLookup.in(SamePackageInnerClass_Static.class);
assertClassAndMode(inObj, SamePackageInnerClass_Static.class, FULL_ACCESS_MODE);
}
Aggregations