8287908: Use non-cloning reflection methods where acceptable

Reviewed-by: rriggs
This commit is contained in:
Sergey Tsypanov 2022-09-12 13:31:53 +00:00 committed by Roger Riggs
parent 0c61bf109f
commit 9ef6c0925a
4 changed files with 9 additions and 9 deletions
src/java.base/share/classes/java/lang/reflect

@ -330,7 +330,7 @@ public abstract sealed class Executable extends AccessibleObject
} else {
final boolean realParamData = hasRealParameterData();
final Type[] genericParamTypes = getGenericParameterTypes();
final Type[] nonGenericParamTypes = getParameterTypes();
final Type[] nonGenericParamTypes = getSharedParameterTypes();
// If we have real parameter data, then we use the
// synthetic and mandate flags to our advantage.
if (realParamData) {
@ -357,7 +357,7 @@ public abstract sealed class Executable extends AccessibleObject
// synthetic/mandated, thus, no way to match up the
// indexes.
return genericParamTypes.length == nonGenericParamTypes.length ?
genericParamTypes : nonGenericParamTypes;
genericParamTypes : getParameterTypes();
}
}
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2022, 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
@ -234,7 +234,7 @@ public final class Parameter implements AnnotatedElement {
public Class<?> getType() {
Class<?> tmp = parameterClassCache;
if (null == tmp) {
tmp = executable.getParameterTypes()[index];
tmp = executable.getSharedParameterTypes()[index];
parameterClassCache = tmp;
}
return tmp;

@ -1256,7 +1256,7 @@ public class Proxy implements java.io.Serializable {
// check if this method is the resolved method if referenced from
// this proxy interface (i.e. this method is not implemented
// by any other superinterface)
Method m = proxyIntf.getMethod(method.getName(), method.getParameterTypes());
Method m = proxyIntf.getMethod(method.getName(), method.getSharedParameterTypes());
if (m.getDeclaringClass() == declaringClass) {
return proxyIntf;
}

@ -522,7 +522,7 @@ final class ProxyGenerator extends ClassWriter {
*/
private void addProxyMethod(Method m, Class<?> fromClass) {
Class<?> returnType = m.getReturnType();
Class<?>[] exceptionTypes = m.getExceptionTypes();
Class<?>[] exceptionTypes = m.getSharedExceptionTypes();
String sig = m.toShortSignature();
List<ProxyMethod> sigmethods = proxyMethods.computeIfAbsent(sig,
@ -544,7 +544,7 @@ final class ProxyGenerator extends ClassWriter {
return;
}
}
sigmethods.add(new ProxyMethod(m, sig, m.getParameterTypes(), returnType,
sigmethods.add(new ProxyMethod(m, sig, m.getSharedParameterTypes(), returnType,
exceptionTypes, fromClass,
"m" + proxyMethodCount++));
}
@ -717,8 +717,8 @@ final class ProxyGenerator extends ClassWriter {
*/
private ProxyMethod(Method method, String methodFieldName) {
this(method, method.toShortSignature(),
method.getParameterTypes(), method.getReturnType(),
method.getExceptionTypes(), method.getDeclaringClass(), methodFieldName);
method.getSharedParameterTypes(), method.getReturnType(),
method.getSharedExceptionTypes(), method.getDeclaringClass(), methodFieldName);
}
/**