Skip to content

Commit

Permalink
Merge pull request #11737 from JasonFengJ9/nperegx
Browse files Browse the repository at this point in the history
Accommodate NPE messages computed by OpenJ9 with OpenJDK MethodHandles
  • Loading branch information
llxia committed Jan 22, 2021
2 parents a1cfdc2 + 2e1d289 commit 678d8eb
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.openj9.test.jep358;

/*******************************************************************************
* Copyright (c) 2020, 2020 IBM Corp. and others
* Copyright (c) 2020, 2021 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -346,14 +346,14 @@ public void test_putfield() {
nullField.nullField = new NPEMessageTests();
}

@Test(expectedExceptions = NullPointerException.class, expectedExceptionsMessageRegExp = "Cannot invoke \"java.lang.invoke.MethodHandle.invokeExact\\(java.lang.String\\)\"")
@Test(expectedExceptions = NullPointerException.class, expectedExceptionsMessageRegExp = "Cannot invoke \"java.lang.invoke.MethodHandle.(invokeExact\\(java.lang.String\\)\"|linkToVirtual\\(java.lang.Object, java.lang.invoke.MemberName\\)\" because \"<parameter1>\" is null)")
public void test_invokehandle() throws WrongMethodTypeException, Throwable {
String msg = null;
MethodHandle mh = MethodHandles.lookup().findVirtual(String.class, "length", MethodType.methodType(int.class));
int len = (int) mh.invokeExact(msg);
}

@Test(expectedExceptions = NullPointerException.class, expectedExceptionsMessageRegExp = "Cannot invoke \"java.lang.invoke.MethodHandle.invoke\\(java.lang.String\\)\"")
@Test(expectedExceptions = NullPointerException.class, expectedExceptionsMessageRegExp = "Cannot invoke \"java.lang.invoke.MethodHandle.(invoke\\(java.lang.String\\)\"|linkToVirtual\\(java.lang.Object, java.lang.invoke.MemberName\\)\" because \"<parameter1>\" is null)")
public void test_invokehandlegeneric() throws WrongMethodTypeException, ClassCastException, Throwable {
String msg = null;
MethodHandle mh = MethodHandles.lookup().findVirtual(String.class, "length", MethodType.methodType(int.class));
Expand Down Expand Up @@ -1520,14 +1520,14 @@ public void test_npeInsideException() {
}
}

@Test(expectedExceptions = NullPointerException.class, expectedExceptionsMessageRegExp = "Cannot invoke \"java.lang.invoke.MethodHandle.invoke\\(java.lang.String\\)\"")
@Test(expectedExceptions = NullPointerException.class, expectedExceptionsMessageRegExp = "Cannot invoke \"java.lang.invoke.MethodHandle.(invoke\\(java.lang.String\\)\"|linkToVirtual\\(java.lang.Object, java.lang.invoke.MemberName\\)\" because \"<parameter1>\" is null)")
public void test_MHinvoke() throws Throwable {
String msg = null;
MethodHandle mh = MethodHandles.lookup().findVirtual(String.class, "length", MethodType.methodType(int.class));
mh.invoke(msg);
}

@Test(expectedExceptions = NullPointerException.class, expectedExceptionsMessageRegExp = "Cannot invoke \"java.lang.invoke.MethodHandle.invokeExact\\(java.lang.String\\)\"")
@Test(expectedExceptions = NullPointerException.class, expectedExceptionsMessageRegExp = "Cannot invoke \"java.lang.invoke.MethodHandle.(invokeExact\\(java.lang.String\\)\"|linkToVirtual\\(java.lang.Object, java.lang.invoke.MemberName\\)\" because \"<parameter1>\" is null)")
public void test_MHinvokeExact() throws Throwable {
String msg = null;
MethodHandle mh = MethodHandles.lookup().findVirtual(String.class, "length", MethodType.methodType(int.class));
Expand Down

0 comments on commit 678d8eb

Please sign in to comment.