Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapt cross package interface test to correctly handle Java 8 #18398

Merged
merged 1 commit into from
Nov 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
*******************************************************************************/
package com.ibm.j9.jsr292;

import org.openj9.test.util.VersionCheck;
import org.testng.annotations.Test;
import org.testng.Assert;
import org.testng.AssertJUnit;
Expand Down Expand Up @@ -2106,7 +2107,17 @@ public void test_FindSpecial_Public_CrossPackage_InnerClass() throws Throwable {
*/
@Test(groups = { "level.extended" })
public void test_FindSpecial_Default_CrossPackage_Interface() throws Throwable {
MethodHandle example = MethodHandles.lookup().findSpecial(CrossPackageDefaultMethodInterface.class, "addDefault", MethodType.methodType(int.class, int.class, int.class), CrossPackageDefaultMethodInterface.class);
try {
Class<?> cls = CrossPackageDefaultMethodInterface.class;
MethodType mt = MethodType.methodType(int.class, int.class, int.class);
MethodHandles.lookup().findSpecial(cls, "addDefault", mt, cls);
ThanHenderson marked this conversation as resolved.
Show resolved Hide resolved
} catch (IllegalAccessException e) {
// JEP 274 is implemented from Java 9 onwards; Java 8 with OpenJDK MethodHandles
// expects an IllegalAccessException.
if (VersionCheck.major() > 8) {
Assert.fail("[Java 9+] Since JEP 274, an IllegalAccessException should not be thrown ", e);
}
}
}

/**
Expand Down