Help Java 9 with some tricky generics type inference

The existing code worked fine under Java 8, but Java 9 fails to
resolve type constraints unless it has more explicit information about
at least one of the arguments to anyOf.  Weird.
This commit is contained in:
Ben Liblit 2018-05-25 11:13:31 -05:00
parent d2852beebf
commit 989ef3ec43
1 changed files with 3 additions and 2 deletions

View File

@ -206,8 +206,9 @@ public class PruneArrayOutOfBoundExceptionEdge {
SSAInstruction lastInstruction = block.getLastInstruction();
lastInstruction.getExceptionTypes();
Matcher<Iterable<? super TypeReference>> matcher1 = anyOf(hasItem(equalTo(TypeReference.JavaLangNullPointerException)),
hasItem(equalTo(TypeReference.JavaLangArrayIndexOutOfBoundsException)));
final Matcher<Iterable<? super TypeReference>> isJLNPE = hasItem(equalTo(TypeReference.JavaLangNullPointerException));
final Matcher<Iterable<? super TypeReference>> isJLAIOOBE = hasItem(equalTo(TypeReference.JavaLangArrayIndexOutOfBoundsException));
final Matcher<Iterable<? super TypeReference>> matcher1 = anyOf(isJLNPE, isJLAIOOBE);
collector.checkThat("Edge deleted but cause instruction can't throw NullPointerException"
+ "nor ArrayIndexOutOfBoundsException: " + identifyer + ":" + method.getLineNumber(lastInstruction.iindex),