From 187d40440b79a4bcec9c5216c4d866dfc2cf61f4 Mon Sep 17 00:00:00 2001 From: Michael Pfaff Date: Mon, 7 Oct 2024 22:34:58 -0400 Subject: [PATCH] Fix optimization in MethodType and MethodTypeDesc --- src/java.base/share/classes/java/lang/invoke/MethodType.java | 2 +- .../share/classes/jdk/internal/constant/MethodTypeDescImpl.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/java.base/share/classes/java/lang/invoke/MethodType.java b/src/java.base/share/classes/java/lang/invoke/MethodType.java index 5f44dae2e01eb..4c48fcce243e7 100644 --- a/src/java.base/share/classes/java/lang/invoke/MethodType.java +++ b/src/java.base/share/classes/java/lang/invoke/MethodType.java @@ -853,7 +853,7 @@ public Class returnType() { * @return the parameter types (as an immutable list) */ public List> parameterList() { - return SharedSecrets.getJavaUtilCollectionAccess().listFromTrustedArray(ptypes); + return SharedSecrets.getJavaUtilCollectionAccess().listFromTrustedArray(Arrays.copyOf(ptypes, ptypes.length, Object.class)); } /** diff --git a/src/java.base/share/classes/jdk/internal/constant/MethodTypeDescImpl.java b/src/java.base/share/classes/jdk/internal/constant/MethodTypeDescImpl.java index fda9062a4006c..4f1456777fa74 100644 --- a/src/java.base/share/classes/jdk/internal/constant/MethodTypeDescImpl.java +++ b/src/java.base/share/classes/jdk/internal/constant/MethodTypeDescImpl.java @@ -225,7 +225,7 @@ public ClassDesc parameterType(int index) { @Override public List parameterList() { - return SharedSecrets.getJavaUtilCollectionAccess().listFromTrustedArray(argTypes); + return SharedSecrets.getJavaUtilCollectionAccess().listFromTrustedArray(Arrays.copyOf(argTypes, argTypes.length, Object.class)); } @Override