Skip to content

Commit

Permalink
8287908: Use non-cloning reflection methods where acceptable
Browse files Browse the repository at this point in the history
Reviewed-by: rriggs
  • Loading branch information
stsypanov authored and Roger Riggs committed Sep 12, 2022
1 parent 0c61bf1 commit 9ef6c09
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/java.base/share/classes/java/lang/reflect/Executable.java
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ Type[] getAllGenericParameterTypes() {
} 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) {
Expand All @@ -357,7 +357,7 @@ Type[] getAllGenericParameterTypes() {
// synthetic/mandated, thus, no way to match up the
// indexes.
return genericParamTypes.length == nonGenericParamTypes.length ?
genericParamTypes : nonGenericParamTypes;
genericParamTypes : getParameterTypes();
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/java.base/share/classes/java/lang/reflect/Parameter.java
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -234,7 +234,7 @@ public Type getParameterizedType() {
public Class<?> getType() {
Class<?> tmp = parameterClassCache;
if (null == tmp) {
tmp = executable.getParameterTypes()[index];
tmp = executable.getSharedParameterTypes()[index];
parameterClassCache = tmp;
}
return tmp;
Expand Down
2 changes: 1 addition & 1 deletion src/java.base/share/classes/java/lang/reflect/Proxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -1256,7 +1256,7 @@ private static Class<?> findProxyInterfaceOrElseThrow(Class<?> proxyClass, Metho
// 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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ private byte[] generateClassFile() {
*/
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,
Expand All @@ -544,7 +544,7 @@ private void addProxyMethod(Method m, Class<?> fromClass) {
return;
}
}
sigmethods.add(new ProxyMethod(m, sig, m.getParameterTypes(), returnType,
sigmethods.add(new ProxyMethod(m, sig, m.getSharedParameterTypes(), returnType,
exceptionTypes, fromClass,
"m" + proxyMethodCount++));
}
Expand Down Expand Up @@ -717,8 +717,8 @@ private ProxyMethod(Method method, String sig, Class<?>[] parameterTypes,
*/
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);
}

/**
Expand Down

1 comment on commit 9ef6c09

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.