Skip to content

Commit

Permalink
Merge pull request #4171 from pdbain-ibm/exception
Browse files Browse the repository at this point in the history
Verify type of MethodHandle.catchException()'s exType argument
  • Loading branch information
DanHeidinga authored Jan 7, 2019
2 parents 86d4e6a + c729c11 commit 93c622c
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*[INCLUDE-IF Sidecar17]*/
/*******************************************************************************
* Copyright (c) 2009, 2018 IBM Corp. and others
* Copyright (c) 2009, 2019 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 @@ -2136,7 +2136,7 @@ public static MethodHandle guardWithTest(MethodHandle guard, MethodHandle trueTa
/**
* Produce a MethodHandle that implements a try-catch block.
*
* This adapter acts as though the <i>tryHandle</i> where run inside a try block. If <i>tryHandle</i>
* This adapter acts as though the <i>tryHandle</i> were run inside a try block. If <i>tryHandle</i>
* throws an exception of type <i>throwableClass</i>, the <i>catchHandle</i> is invoked with the
* exception instance and the original arguments.
* <p>
Expand All @@ -2159,6 +2159,9 @@ public static MethodHandle catchException(MethodHandle tryHandle, Class<? extend
if ((tryHandle == null) || (throwableClass == null) || (catchHandle == null)) {
throw new NullPointerException();
}
if (!Throwable.class.isAssignableFrom(throwableClass)) {
throw new ClassCastException(throwableClass.getName());
}
MethodType tryType = tryHandle.type;
MethodType catchType = catchHandle.type;
if (tryType.returnType != catchType.returnType) {
Expand Down

0 comments on commit 93c622c

Please sign in to comment.