Skip to content

Commit

Permalink
Merge pull request #18574 from ThanHenderson/rid-missed-case
Browse files Browse the repository at this point in the history
Handle missed BME case in resolveInvokeDynamic for OJDK MHs
  • Loading branch information
babsingh authored Dec 8, 2023
2 parents 6105644 + 2552a5a commit f899fab
Showing 1 changed file with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ private static final Object resolveInvokeDynamic(long j9class, String name, Stri
int bsmArgCount = UNSAFE.getShort(bsmData + BSM_ARGUMENT_COUNT_OFFSET);
long bsmArgs = bsmData + BSM_ARGUMENTS_OFFSET;
MethodHandle bsm = getCPMethodHandleAt(internalConstantPool, bsmIndex);
if (null == bsm) {
if (bsm == null) {
/*[MSG "K05cd", "unable to resolve 'bootstrap_method_ref' in '{0}' at index {1}"]*/
throw new NullPointerException(Msg.getString("K05cd", classObject.toString(), bsmIndex)); //$NON-NLS-1$
}
Expand Down Expand Up @@ -297,9 +297,13 @@ private static final Object resolveInvokeDynamic(long j9class, String name, Stri
throw e;
}
/*[ENDIF] JAVA_SPEC_VERSION < 11*/

if (type == null) {
throw new BootstrapMethodError(e);
}

/* Any throwables are wrapped in an invoke-time BootstrapMethodError exception throw. */
try {
MethodHandle resultHandle;
MethodHandle thrower = MethodHandles.throwException(type.returnType(), BootstrapMethodError.class);
MethodHandle constructor = IMPL_LOOKUP.findConstructor(BootstrapMethodError.class, MethodType.methodType(void.class, Throwable.class));

Expand All @@ -314,13 +318,13 @@ private static final Object resolveInvokeDynamic(long j9class, String name, Stri
} else {
combiner = constructor.bindTo(e);
}
resultHandle = MethodHandles.foldArguments(thrower, combiner);

MethodHandle resultHandle = MethodHandles.foldArguments(thrower, combiner);
/*[IF JAVA_SPEC_VERSION >= 11]*/
MemberName memberName = resultHandle.internalForm().vmentry;
result[0] = resultHandle.internalForm().vmentry;
/*[ELSE] JAVA_SPEC_VERSION >= 11*/
MemberName memberName = resultHandle.internalForm().compileToBytecode();
result[0] = resultHandle.internalForm().compileToBytecode();
/*[ENDIF] JAVA_SPEC_VERSION >= 11*/
result[0] = memberName;
result[1] = resultHandle;
} catch (IllegalAccessException iae) {
throw new Error(iae);
Expand Down

0 comments on commit f899fab

Please sign in to comment.