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) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 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
@ -685,8 +685,8 @@ public class AccessibleObject implements AnnotatedElement {
*/
private boolean isAccessChecked(Class<?> caller, Class<?> targetClass) {
Object cache = accessCheckCache; // read volatile
if (cache instanceof Cache) {
return ((Cache) cache).isCacheFor(caller, targetClass);
if (cache instanceof Cache c) {
return c.isCacheFor(caller, targetClass);
}
return false;
}

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 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
@ -366,9 +366,9 @@ public interface AnnotatedElement {
T[] result = getDeclaredAnnotationsByType(annotationClass);
if (result.length == 0 && // Neither directly nor indirectly present
this instanceof Class && // the element is a class
this instanceof Class<?> cls && // the element is a class
AnnotationType.getInstance(annotationClass).isInherited()) { // Inheritable
Class<?> superClass = ((Class<?>) this).getSuperclass();
Class<?> superClass = cls.getSuperclass();
if (superClass != null) {
// Determine if the annotation is associated with the
// superclass

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 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
@ -1052,8 +1052,8 @@ public class Proxy implements java.io.Serializable {
throw new InternalError(e.toString(), e);
} catch (InvocationTargetException e) {
Throwable t = e.getCause();
if (t instanceof RuntimeException) {
throw (RuntimeException) t;
if (t instanceof RuntimeException re) {
throw re;
} else {
throw new InternalError(t.toString(), t);
}