From 26b574007c7d436a98b21179f532b59b42122964 Mon Sep 17 00:00:00 2001 From: Theresa Mammarella Date: Wed, 15 Nov 2023 13:28:01 -0500 Subject: [PATCH] Append cp to annotation data to fix redefinition inconsistencies Port to Java 17 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 d86a454c751..a6228eb2cc4 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.*; @@ -82,8 +88,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()); } @@ -624,8 +629,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 9cbca96942f..bf7d94d23ff 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; @@ -1210,8 +1216,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 dedf2d5dd91..f70464f1ac1 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; @@ -716,8 +722,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) {