RFR: 8372258: Improve TypeVariable support

ExE Boss duke at openjdk.org
Sat Nov 22 10:20:11 UTC 2025


On Thu, 20 Nov 2025 13:06:12 GMT, Per Minborg <pminborg at openjdk.org> wrote:

> The `TypeVariableImpl::getGenericDeclaration` method should return copies of generic declarations where appropriate.

src/java.base/share/classes/sun/reflect/generics/reflectiveObjects/TypeVariableImpl.java line 142:

> 140:                 genericDeclaration instanceof Method ||
> 141:                 genericDeclaration instanceof Constructor : "Unexpected kind of GenericDeclaration";
> 142:         // If the `genericDeclaration` instance is mutable, we need to make a copy.

Additionally, the old version would leak the internal root `Method` and `Constructor` objects.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/28429#discussion_r2552861038


More information about the core-libs-dev mailing list