8310849: Pattern matching for instanceof and arrayType cleanup in j.l.invoke and j.l.reflect

Reviewed-by: mchung, darcy
This commit is contained in:
Chen Liang 2023-06-27 16:10:50 +00:00 committed by Mandy Chung
parent 7ce967a10c
commit 2bd4136bdb
34 changed files with 211 additions and 292 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -350,10 +350,10 @@ class MethodHandleNatives {
}
private static String staticArglistForTrace(Object staticArguments) {
if (staticArguments instanceof Object[])
return "BSA="+java.util.Arrays.asList((Object[]) staticArguments);
if (staticArguments instanceof int[])
return "BSA@"+java.util.Arrays.toString((int[]) staticArguments);
if (staticArguments instanceof Object[] array)
return "BSA="+java.util.Arrays.asList(array);
if (staticArguments instanceof int[] array)
return "BSA@"+java.util.Arrays.toString(array);
if (staticArguments == null)
return "BSA0=null";
return "BSA1="+staticArguments;
@ -509,8 +509,8 @@ class MethodHandleNatives {
throw new LinkageError("no such method "+defc.getName()+"."+name+type);
}
private static MethodType fixMethodType(Class<?> callerClass, Object type) {
if (type instanceof MethodType)
return (MethodType) type;
if (type instanceof MethodType mt)
return mt;
else
return MethodType.fromDescriptor((String)type, callerClass.getClassLoader());
}
@ -637,8 +637,8 @@ class MethodHandleNatives {
LinkageError err;
if (ex instanceof IllegalAccessException) {
Throwable cause = ex.getCause();
if (cause instanceof AbstractMethodError) {
return (AbstractMethodError) cause;
if (cause instanceof AbstractMethodError ame) {
return ame;
} else {
err = new IllegalAccessError(ex.getMessage());
}