From ba8842922d16f7e9e6166006c1886d53dd7f6f71 Mon Sep 17 00:00:00 2001 From: Theresa Mammarella Date: Wed, 15 Nov 2023 13:46:12 -0500 Subject: [PATCH] Append cp to annotation data to fix redefinition inconsistencies Port to Java 21 from ibmruntimes/openj9-openjdk-jdk8#705 Signed-off-by: Theresa Mammarella --- .../share/classes/java/lang/reflect/Executable.java | 12 ++++++++---- .../share/classes/java/lang/reflect/Field.java | 9 +++++++-- .../share/classes/java/lang/reflect/Method.java | 9 +++++++-- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/java.base/share/classes/java/lang/reflect/Executable.java b/src/java.base/share/classes/java/lang/reflect/Executable.java index dcf4bfafe25..1e5441b77f2 100644 --- a/src/java.base/share/classes/java/lang/reflect/Executable.java +++ b/src/java.base/share/classes/java/lang/reflect/Executable.java @@ -23,6 +23,12 @@ * questions. */ + /* + * =========================================================================== + * (c) Copyright IBM Corp. 2023, 2023 All Rights Reserved + * =========================================================================== + */ + package java.lang.reflect; import java.lang.annotation.Annotation; @@ -83,8 +89,7 @@ boolean equalParamTypes(Class[] params1, Class[] params2) { Annotation[][] parseParameterAnnotations(byte[] parameterAnnotations) { return AnnotationParser.parseParameterAnnotations( parameterAnnotations, - SharedSecrets.getJavaLangAccess(). - getConstantPool(getDeclaringClass()), + com.ibm.oti.vm.VM.getConstantPoolFromAnnotationBytes(getDeclaringClass(), parameterAnnotations), getDeclaringClass()); } @@ -633,8 +638,7 @@ private Map, Annotation> declaredAnnotations() { } else { declAnnos = AnnotationParser.parseAnnotations( getAnnotationBytes(), - SharedSecrets.getJavaLangAccess(). - getConstantPool(getDeclaringClass()), + com.ibm.oti.vm.VM.getConstantPoolFromAnnotationBytes(getDeclaringClass(), getAnnotationBytes()), getDeclaringClass() ); } diff --git a/src/java.base/share/classes/java/lang/reflect/Field.java b/src/java.base/share/classes/java/lang/reflect/Field.java index 3e9d02d5509..6096395b0c7 100644 --- a/src/java.base/share/classes/java/lang/reflect/Field.java +++ b/src/java.base/share/classes/java/lang/reflect/Field.java @@ -23,6 +23,12 @@ * questions. */ + /* + * =========================================================================== + * (c) Copyright IBM Corp. 2023, 2023 All Rights Reserved + * =========================================================================== + */ + package java.lang.reflect; import jdk.internal.access.SharedSecrets; @@ -1280,8 +1286,7 @@ private Map, Annotation> declaredAnnotations() { } else { declAnnos = AnnotationParser.parseAnnotations( annotations, - SharedSecrets.getJavaLangAccess() - .getConstantPool(getDeclaringClass()), + com.ibm.oti.vm.VM.getConstantPoolFromAnnotationBytes(getDeclaringClass(), annotations), getDeclaringClass()); } declaredAnnotations = declAnnos; diff --git a/src/java.base/share/classes/java/lang/reflect/Method.java b/src/java.base/share/classes/java/lang/reflect/Method.java index 028577c229c..734113976d4 100644 --- a/src/java.base/share/classes/java/lang/reflect/Method.java +++ b/src/java.base/share/classes/java/lang/reflect/Method.java @@ -23,6 +23,12 @@ * questions. */ + /* + * =========================================================================== + * (c) Copyright IBM Corp. 2023, 2023 All Rights Reserved + * =========================================================================== + */ + package java.lang.reflect; import jdk.internal.access.SharedSecrets; @@ -771,8 +777,7 @@ public Object getDefaultValue() { getReturnType()); Object result = AnnotationParser.parseMemberValue( memberType, ByteBuffer.wrap(annotationDefault), - SharedSecrets.getJavaLangAccess(). - getConstantPool(getDeclaringClass()), + com.ibm.oti.vm.VM.getConstantPoolFromAnnotationBytes(getDeclaringClass(), annotationDefault), getDeclaringClass()); if (result instanceof ExceptionProxy) { if (result instanceof TypeNotPresentExceptionProxy proxy) {