From d727a0f9fdb6bc04a7445ed77a217ce4ced2d199 Mon Sep 17 00:00:00 2001 From: Peter Hofer Date: Thu, 14 Jul 2022 17:50:23 +0200 Subject: [PATCH] Move reflection code to com.oracle.svm.{core,hosted}.reflect. --- substratevm/mx.substratevm/suite.py | 36 ++--------------- .../reflect/proxy/DynamicProxySupport.java | 2 +- .../serialize/SerializationRegistry.java | 2 +- .../serialize/SerializationSupport.java | 2 +- .../EncodedReflectionMetadataSupplier.java} | 21 ++++++++-- .../target}/ExecutableAccessorComputer.java | 4 +- .../reflect/target}/FieldOffsetComputer.java | 23 ++--------- .../reflect/target/ReflectionHelper.java | 2 +- .../target}/ReflectionMetadataComputer.java | 2 +- .../target/ReflectionMetadataDecoderImpl.java | 5 +-- .../target/ReflectionMetadataEncoding.java | 2 +- .../ReflectionSubstitutionSupport.java} | 17 +++++--- ...et_java_lang_reflect_AccessibleObject.java | 6 +-- .../Target_java_lang_reflect_Constructor.java | 9 ++--- .../Target_java_lang_reflect_Executable.java | 6 +-- .../Target_java_lang_reflect_Field.java | 10 +---- .../Target_java_lang_reflect_Method.java | 11 ++--- .../Target_java_lang_reflect_Parameter.java | 2 +- ...arget_java_lang_reflect_ReflectAccess.java | 6 +-- ...t_jdk_internal_misc_Unsafe_Reflection.java | 2 +- ...dk_internal_reflect_AccessorGenerator.java | 4 +- ..._internal_reflect_ConstructorAccessor.java | 2 +- ...et_jdk_internal_reflect_FieldAccessor.java | 2 +- ...t_jdk_internal_reflect_MethodAccessor.java | 2 +- ...nnotation_AnnotationInvocationHandler.java | 2 +- ...n_reflect_annotation_AnnotationParser.java | 9 ++--- .../hotspot/libgraal/LibGraalFeature.java | 2 +- .../oracle/svm/hosted/ProgressReporter.java | 4 +- .../svm/hosted/heap/SVMImageHeapScanner.java | 6 +-- .../svm/hosted/heap/SVMImageHeapVerifier.java | 4 +- .../hosted/image/NativeImageCodeCache.java | 17 ++------ .../hosted/reflect}/AnnotationEncoder.java | 6 +-- .../reflect}/ReflectionDataBuilder.java | 8 ++-- .../ReflectionExpandSignatureMethod.java | 2 +- .../hosted/reflect}/ReflectionFeature.java | 40 +++++++++++++++---- .../hosted/reflect}/ReflectionGraphKit.java | 2 +- .../ReflectionHostedSupport.java} | 6 +-- .../hosted/reflect}/ReflectionMetadata.java | 6 +-- .../ReflectionMetadataEncoderImpl.java | 40 +++++++++---------- .../reflect/proxy}/DynamicProxyFeature.java | 6 +-- .../hosted/reflect/proxy}/ProxyRegistry.java | 2 +- .../serialize}/SerializationFeature.java | 12 +++--- .../com/oracle/svm/junit/JUnitFeature.java | 10 +---- .../Target_java_lang_invoke_MethodHandle.java | 6 +-- ..._java_lang_invoke_MethodHandleNatives.java | 2 +- .../serialize/hosted/package-info.java | 30 -------------- .../truffle/tck/tests/TruffleTCKFeature.java | 11 ----- 47 files changed, 168 insertions(+), 245 deletions(-) rename substratevm/src/{com.oracle.svm.reflect/src/com/oracle/svm => com.oracle.svm.core/src/com/oracle/svm/core}/reflect/proxy/DynamicProxySupport.java (99%) rename substratevm/src/{com.oracle.svm.reflect/src/com/oracle/svm => com.oracle.svm.core/src/com/oracle/svm/core}/reflect/serialize/SerializationRegistry.java (96%) rename substratevm/src/{com.oracle.svm.reflect/src/com/oracle/svm => com.oracle.svm.core/src/com/oracle/svm/core}/reflect/serialize/SerializationSupport.java (99%) rename substratevm/src/{com.oracle.svm.reflect/src/com/oracle/svm/reflect/proxy/hosted/package-info.java => com.oracle.svm.core/src/com/oracle/svm/core/reflect/target/EncodedReflectionMetadataSupplier.java} (68%) rename substratevm/src/{com.oracle.svm.reflect/src/com/oracle/svm/reflect/hosted => com.oracle.svm.core/src/com/oracle/svm/core/reflect/target}/ExecutableAccessorComputer.java (92%) rename substratevm/src/{com.oracle.svm.reflect/src/com/oracle/svm/reflect/hosted => com.oracle.svm.core/src/com/oracle/svm/core/reflect/target}/FieldOffsetComputer.java (66%) rename substratevm/src/{com.oracle.svm.reflect/src/com/oracle/svm => com.oracle.svm.core/src/com/oracle/svm/core}/reflect/target/ReflectionHelper.java (98%) rename substratevm/src/{com.oracle.svm.reflect/src/com/oracle/svm/reflect/hosted => com.oracle.svm.core/src/com/oracle/svm/core/reflect/target}/ReflectionMetadataComputer.java (97%) rename substratevm/src/{com.oracle.svm.reflect/src/com/oracle/svm => com.oracle.svm.core/src/com/oracle/svm/core}/reflect/target/ReflectionMetadataDecoderImpl.java (99%) rename substratevm/src/{com.oracle.svm.reflect/src/com/oracle/svm => com.oracle.svm.core/src/com/oracle/svm/core}/reflect/target/ReflectionMetadataEncoding.java (97%) rename substratevm/src/{com.oracle.svm.reflect/src/com/oracle/svm/reflect/hosted/package-info.java => com.oracle.svm.core/src/com/oracle/svm/core/reflect/target/ReflectionSubstitutionSupport.java} (70%) rename substratevm/src/{com.oracle.svm.reflect/src/com/oracle/svm => com.oracle.svm.core/src/com/oracle/svm/core}/reflect/target/Target_java_lang_reflect_AccessibleObject.java (89%) rename substratevm/src/{com.oracle.svm.reflect/src/com/oracle/svm => com.oracle.svm.core/src/com/oracle/svm/core}/reflect/target/Target_java_lang_reflect_Constructor.java (87%) rename substratevm/src/{com.oracle.svm.reflect/src/com/oracle/svm => com.oracle.svm.core/src/com/oracle/svm/core}/reflect/target/Target_java_lang_reflect_Executable.java (90%) rename substratevm/src/{com.oracle.svm.reflect/src/com/oracle/svm => com.oracle.svm.core/src/com/oracle/svm/core}/reflect/target/Target_java_lang_reflect_Field.java (92%) rename substratevm/src/{com.oracle.svm.reflect/src/com/oracle/svm => com.oracle.svm.core/src/com/oracle/svm/core}/reflect/target/Target_java_lang_reflect_Method.java (85%) rename substratevm/src/{com.oracle.svm.reflect/src/com/oracle/svm => com.oracle.svm.core/src/com/oracle/svm/core}/reflect/target/Target_java_lang_reflect_Parameter.java (97%) rename substratevm/src/{com.oracle.svm.reflect/src/com/oracle/svm => com.oracle.svm.core/src/com/oracle/svm/core}/reflect/target/Target_java_lang_reflect_ReflectAccess.java (94%) rename substratevm/src/{com.oracle.svm.reflect/src/com/oracle/svm => com.oracle.svm.core/src/com/oracle/svm/core}/reflect/target/Target_jdk_internal_misc_Unsafe_Reflection.java (98%) rename substratevm/src/{com.oracle.svm.reflect/src/com/oracle/svm => com.oracle.svm.core/src/com/oracle/svm/core}/reflect/target/Target_jdk_internal_reflect_AccessorGenerator.java (95%) rename substratevm/src/{com.oracle.svm.reflect/src/com/oracle/svm => com.oracle.svm.core/src/com/oracle/svm/core}/reflect/target/Target_jdk_internal_reflect_ConstructorAccessor.java (96%) rename substratevm/src/{com.oracle.svm.reflect/src/com/oracle/svm => com.oracle.svm.core/src/com/oracle/svm/core}/reflect/target/Target_jdk_internal_reflect_FieldAccessor.java (96%) rename substratevm/src/{com.oracle.svm.reflect/src/com/oracle/svm => com.oracle.svm.core/src/com/oracle/svm/core}/reflect/target/Target_jdk_internal_reflect_MethodAccessor.java (96%) rename substratevm/src/{com.oracle.svm.reflect/src/com/oracle/svm => com.oracle.svm.core/src/com/oracle/svm/core}/reflect/target/Target_sun_reflect_annotation_AnnotationInvocationHandler.java (99%) rename substratevm/src/{com.oracle.svm.reflect/src/com/oracle/svm => com.oracle.svm.core/src/com/oracle/svm/core}/reflect/target/Target_sun_reflect_annotation_AnnotationParser.java (97%) rename substratevm/src/{com.oracle.svm.reflect/src/com/oracle/svm/reflect/hosted => com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect}/AnnotationEncoder.java (99%) rename substratevm/src/{com.oracle.svm.reflect/src/com/oracle/svm/reflect/hosted => com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect}/ReflectionDataBuilder.java (99%) rename substratevm/src/{com.oracle.svm.reflect/src/com/oracle/svm/reflect/hosted => com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect}/ReflectionExpandSignatureMethod.java (99%) rename substratevm/src/{com.oracle.svm.reflect/src/com/oracle/svm/reflect/hosted => com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect}/ReflectionFeature.java (91%) rename substratevm/src/{com.oracle.svm.reflect/src/com/oracle/svm/reflect/hosted => com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect}/ReflectionGraphKit.java (99%) rename substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/{meta/InternalRuntimeReflectionSupport.java => reflect/ReflectionHostedSupport.java} (92%) rename substratevm/src/{com.oracle.svm.reflect/src/com/oracle/svm/reflect/hosted => com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect}/ReflectionMetadata.java (98%) rename substratevm/src/{com.oracle.svm.reflect/src/com/oracle/svm/reflect/hosted => com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect}/ReflectionMetadataEncoderImpl.java (96%) rename substratevm/src/{com.oracle.svm.reflect/src/com/oracle/svm/reflect/proxy/hosted => com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/proxy}/DynamicProxyFeature.java (96%) rename substratevm/src/{com.oracle.svm.reflect/src/com/oracle/svm/reflect/proxy/hosted => com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/proxy}/ProxyRegistry.java (98%) rename substratevm/src/{com.oracle.svm.reflect/src/com/oracle/svm/reflect/serialize/hosted => com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/serialize}/SerializationFeature.java (98%) delete mode 100644 substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/serialize/hosted/package-info.java diff --git a/substratevm/mx.substratevm/suite.py b/substratevm/mx.substratevm/suite.py index 8b9382ff3c00..f68faf57ae06 100644 --- a/substratevm/mx.substratevm/suite.py +++ b/substratevm/mx.substratevm/suite.py @@ -677,7 +677,7 @@ "resources", ], "dependencies": [ - "com.oracle.svm.reflect", + "com.oracle.svm.core", "mx:JUNIT_TOOL", ], "checkstyle": "com.oracle.svm.core", @@ -753,38 +753,11 @@ "testProject": True, }, - "com.oracle.svm.reflect": { - "subDir": "src", - "sourceDirs": ["src"], - "dependencies": [ - "com.oracle.svm.hosted", - ], - "requiresConcealed" : { - "java.base" : [ - "sun.invoke.util", - "sun.reflect.annotation", - "sun.reflect.generics.repository", - "jdk.internal.reflect", - "sun.reflect.generics.scope" - ], - "jdk.internal.vm.ci" : [ - "jdk.vm.ci.code", - ], - }, - "checkstyle": "com.oracle.svm.core", - "workingSets": "SVM", - "annotationProcessors": [ - "compiler:GRAAL_PROCESSOR", - ], - "javaCompliance": "11+", - "spotbugs": "false", - }, - "com.oracle.svm.methodhandles": { "subDir": "src", "sourceDirs": ["src"], "dependencies": [ - "com.oracle.svm.reflect", + "com.oracle.svm.hosted", ], "requiresConcealed" : { "java.base" : [ @@ -1014,8 +987,6 @@ "subDir": "src", "sourceDirs": ["src"], "dependencies": [ - "com.oracle.svm.core", - "com.oracle.svm.reflect", "com.oracle.svm.graal", "compiler:GRAAL" ], @@ -1142,7 +1113,6 @@ "com.oracle.svm.core.windows", "com.oracle.svm.core.genscavenge", "com.oracle.svm.core.containers", - "com.oracle.svm.reflect", "com.oracle.svm.methodhandles" ], "manifestEntries" : { @@ -1170,7 +1140,7 @@ "com.oracle.svm.core.graal.nodes to jdk.internal.vm.compiler", "com.oracle.svm.core.graal.snippets to jdk.internal.vm.compiler", "com.oracle.svm.hosted.fieldfolding to jdk.internal.vm.compiler", - "com.oracle.svm.reflect.hosted to jdk.internal.vm.compiler", + "com.oracle.svm.hosted.reflect to jdk.internal.vm.compiler", ], "requires": [ "java.management", diff --git a/substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/proxy/DynamicProxySupport.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/proxy/DynamicProxySupport.java similarity index 99% rename from substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/proxy/DynamicProxySupport.java rename to substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/proxy/DynamicProxySupport.java index dab8810a4e19..38e965b4d49a 100644 --- a/substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/proxy/DynamicProxySupport.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/proxy/DynamicProxySupport.java @@ -22,7 +22,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package com.oracle.svm.reflect.proxy; +package com.oracle.svm.core.reflect.proxy; import java.lang.reflect.InvocationHandler; import java.util.Arrays; diff --git a/substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/serialize/SerializationRegistry.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/serialize/SerializationRegistry.java similarity index 96% rename from substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/serialize/SerializationRegistry.java rename to substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/serialize/SerializationRegistry.java index 946ff9565d43..40134807fc71 100644 --- a/substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/serialize/SerializationRegistry.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/serialize/SerializationRegistry.java @@ -23,7 +23,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package com.oracle.svm.reflect.serialize; +package com.oracle.svm.core.reflect.serialize; public interface SerializationRegistry { diff --git a/substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/serialize/SerializationSupport.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/serialize/SerializationSupport.java similarity index 99% rename from substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/serialize/SerializationSupport.java rename to substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/serialize/SerializationSupport.java index 18984a0fde5b..d83019ae3248 100644 --- a/substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/serialize/SerializationSupport.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/serialize/SerializationSupport.java @@ -23,7 +23,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package com.oracle.svm.reflect.serialize; +package com.oracle.svm.core.reflect.serialize; import java.io.Serializable; import java.lang.invoke.SerializedLambda; diff --git a/substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/proxy/hosted/package-info.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/target/EncodedReflectionMetadataSupplier.java similarity index 68% rename from substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/proxy/hosted/package-info.java rename to substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/target/EncodedReflectionMetadataSupplier.java index 573afbd1aade..c49ca53c217a 100644 --- a/substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/proxy/hosted/package-info.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/target/EncodedReflectionMetadataSupplier.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 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 @@ -22,9 +22,24 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ +package com.oracle.svm.core.reflect.target; -@Platforms(Platform.HOSTED_ONLY.class) -package com.oracle.svm.reflect.proxy.hosted; +import java.lang.reflect.AccessibleObject; +import java.lang.reflect.Executable; +import java.lang.reflect.Method; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; + +@Platforms(Platform.HOSTED_ONLY.class) +public interface EncodedReflectionMetadataSupplier { + byte[] getAnnotationsEncoding(AccessibleObject object); + + byte[] getParameterAnnotationsEncoding(Executable object); + + byte[] getAnnotationDefaultEncoding(Method object); + + byte[] getTypeAnnotationsEncoding(AccessibleObject object); + + byte[] getReflectParametersEncoding(Executable object); +} diff --git a/substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/hosted/ExecutableAccessorComputer.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/target/ExecutableAccessorComputer.java similarity index 92% rename from substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/hosted/ExecutableAccessorComputer.java rename to substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/target/ExecutableAccessorComputer.java index e3681a6b78ea..24840dfe7c28 100644 --- a/substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/hosted/ExecutableAccessorComputer.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/target/ExecutableAccessorComputer.java @@ -22,7 +22,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package com.oracle.svm.reflect.hosted; +package com.oracle.svm.core.reflect.target; import java.lang.reflect.Executable; @@ -47,6 +47,6 @@ public RecomputeFieldValue.ValueAvailability valueAvailability() { @Override public Object compute(MetaAccessProvider metaAccess, ResolvedJavaField original, ResolvedJavaField annotated, Object receiver) { - return ImageSingletons.lookup(ReflectionFeature.class).getOrCreateAccessor((Executable) receiver); + return ImageSingletons.lookup(ReflectionSubstitutionSupport.class).getOrCreateAccessor((Executable) receiver); } } diff --git a/substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/hosted/FieldOffsetComputer.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/target/FieldOffsetComputer.java similarity index 66% rename from substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/hosted/FieldOffsetComputer.java rename to substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/target/FieldOffsetComputer.java index b94e39889b91..be3bb8822e01 100644 --- a/substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/hosted/FieldOffsetComputer.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/target/FieldOffsetComputer.java @@ -22,15 +22,14 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package com.oracle.svm.reflect.hosted; +package com.oracle.svm.core.reflect.target; import java.lang.reflect.Field; +import org.graalvm.nativeimage.ImageSingletons; + import com.oracle.svm.core.annotate.RecomputeFieldValue; import com.oracle.svm.core.annotate.RecomputeFieldValue.CustomFieldValueComputer; -import com.oracle.svm.core.util.VMError; -import com.oracle.svm.hosted.meta.HostedField; -import com.oracle.svm.hosted.meta.HostedMetaAccess; import jdk.vm.ci.meta.MetaAccessProvider; import jdk.vm.ci.meta.ResolvedJavaField; @@ -44,21 +43,7 @@ public RecomputeFieldValue.ValueAvailability valueAvailability() { @Override public Object compute(MetaAccessProvider metaAccess, ResolvedJavaField original, ResolvedJavaField annotated, Object receiver) { - VMError.guarantee(metaAccess instanceof HostedMetaAccess, "Field offset computation must be done during compilation."); - - /* - * We have to use `optionalLookupJavaField` as fields are omitted when there is no - * reflective access in an image. - */ - HostedField hostedField = ((HostedMetaAccess) metaAccess).optionalLookupJavaField((Field) receiver); - if (hostedField != null && hostedField.wrapped.isUnsafeAccessed()) { - int location = hostedField.getLocation(); - VMError.guarantee(location > 0, "Incorrect field location: " + location + " for " + hostedField.format("%H.%n")); - return location; - } else { - /* A value of -1 signals that the field was not marked as unsafe accessed. */ - return -1; - } + return ImageSingletons.lookup(ReflectionSubstitutionSupport.class).getFieldOffset((Field) receiver); } @Override diff --git a/substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/target/ReflectionHelper.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/target/ReflectionHelper.java similarity index 98% rename from substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/target/ReflectionHelper.java rename to substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/target/ReflectionHelper.java index 3fbc27fac9eb..91275b850f64 100644 --- a/substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/target/ReflectionHelper.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/target/ReflectionHelper.java @@ -22,7 +22,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package com.oracle.svm.reflect.target; +package com.oracle.svm.core.reflect.target; import com.oracle.svm.core.SubstrateUtil; import com.oracle.svm.core.util.VMError; diff --git a/substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/hosted/ReflectionMetadataComputer.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/target/ReflectionMetadataComputer.java similarity index 97% rename from substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/hosted/ReflectionMetadataComputer.java rename to substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/target/ReflectionMetadataComputer.java index 17fe4ba0dc8a..3d31c04a9915 100644 --- a/substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/hosted/ReflectionMetadataComputer.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/target/ReflectionMetadataComputer.java @@ -22,7 +22,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package com.oracle.svm.reflect.hosted; +package com.oracle.svm.core.reflect.target; import com.oracle.svm.core.annotate.RecomputeFieldValue; diff --git a/substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/target/ReflectionMetadataDecoderImpl.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/target/ReflectionMetadataDecoderImpl.java similarity index 99% rename from substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/target/ReflectionMetadataDecoderImpl.java rename to substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/target/ReflectionMetadataDecoderImpl.java index fbdef9bc7df3..7a9a908345ae 100644 --- a/substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/target/ReflectionMetadataDecoderImpl.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/target/ReflectionMetadataDecoderImpl.java @@ -22,7 +22,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package com.oracle.svm.reflect.target; +package com.oracle.svm.core.reflect.target; import java.lang.reflect.Array; import java.lang.reflect.Constructor; @@ -47,13 +47,12 @@ import com.oracle.svm.core.reflect.ReflectionMetadataDecoder; import com.oracle.svm.core.reflect.Target_java_lang_reflect_RecordComponent; import com.oracle.svm.core.util.ByteArrayReader; -import com.oracle.svm.reflect.hosted.ReflectionMetadataEncoderImpl; /** * This class performs the parsing of reflection metadata at runtime. The encoding formats are * specified as comments above each parsing method. * - * See {@link ReflectionMetadataEncoderImpl} for details about the emission of the metadata. + * See {@code ReflectionMetadataEncoderImpl} for details about the emission of the metadata. */ public class ReflectionMetadataDecoderImpl implements ReflectionMetadataDecoder { public static final int NO_METHOD_METADATA = -1; diff --git a/substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/target/ReflectionMetadataEncoding.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/target/ReflectionMetadataEncoding.java similarity index 97% rename from substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/target/ReflectionMetadataEncoding.java rename to substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/target/ReflectionMetadataEncoding.java index fc33ab2c2b53..0b0ef630ef38 100644 --- a/substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/target/ReflectionMetadataEncoding.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/target/ReflectionMetadataEncoding.java @@ -22,7 +22,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package com.oracle.svm.reflect.target; +package com.oracle.svm.core.reflect.target; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; diff --git a/substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/hosted/package-info.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/target/ReflectionSubstitutionSupport.java similarity index 70% rename from substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/hosted/package-info.java rename to substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/target/ReflectionSubstitutionSupport.java index abf4166c2d69..0069389c83f4 100644 --- a/substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/hosted/package-info.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/target/ReflectionSubstitutionSupport.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 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 @@ -22,9 +22,16 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ +package com.oracle.svm.core.reflect.target; -@Platforms(Platform.HOSTED_ONLY.class) -package com.oracle.svm.reflect.hosted; +import java.lang.reflect.Executable; +import java.lang.reflect.Field; -import org.graalvm.nativeimage.Platform; -import org.graalvm.nativeimage.Platforms; +import com.oracle.svm.core.reflect.SubstrateAccessor; + +public interface ReflectionSubstitutionSupport { + SubstrateAccessor getOrCreateAccessor(Executable member); + + /** Offset of the field or -1 if the field was not registered for unsafe access. */ + int getFieldOffset(Field field); +} diff --git a/substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/target/Target_java_lang_reflect_AccessibleObject.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/target/Target_java_lang_reflect_AccessibleObject.java similarity index 89% rename from substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/target/Target_java_lang_reflect_AccessibleObject.java rename to substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/target/Target_java_lang_reflect_AccessibleObject.java index 2f6952df26b1..1afc085f39ba 100644 --- a/substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/target/Target_java_lang_reflect_AccessibleObject.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/target/Target_java_lang_reflect_AccessibleObject.java @@ -22,7 +22,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package com.oracle.svm.reflect.target; +package com.oracle.svm.core.reflect.target; import java.lang.reflect.AccessibleObject; @@ -35,8 +35,6 @@ import com.oracle.svm.core.annotate.TargetElement; import com.oracle.svm.core.jdk.JDK11OrEarlier; import com.oracle.svm.core.jdk.JDK17OrLater; -import com.oracle.svm.hosted.image.NativeImageCodeCache; -import com.oracle.svm.reflect.hosted.ReflectionMetadataComputer; import jdk.vm.ci.meta.MetaAccessProvider; import jdk.vm.ci.meta.ResolvedJavaField; @@ -63,7 +61,7 @@ public final class Target_java_lang_reflect_AccessibleObject { static class TypeAnnotationsComputer extends ReflectionMetadataComputer { @Override public Object compute(MetaAccessProvider metaAccess, ResolvedJavaField original, ResolvedJavaField annotated, Object receiver) { - return ImageSingletons.lookup(NativeImageCodeCache.ReflectionMetadataEncoder.class).getTypeAnnotationsEncoding((AccessibleObject) receiver); + return ImageSingletons.lookup(EncodedReflectionMetadataSupplier.class).getTypeAnnotationsEncoding((AccessibleObject) receiver); } } } diff --git a/substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/target/Target_java_lang_reflect_Constructor.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/target/Target_java_lang_reflect_Constructor.java similarity index 87% rename from substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/target/Target_java_lang_reflect_Constructor.java rename to substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/target/Target_java_lang_reflect_Constructor.java index bc696529cdf4..6b67a24d3313 100644 --- a/substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/target/Target_java_lang_reflect_Constructor.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/target/Target_java_lang_reflect_Constructor.java @@ -22,7 +22,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package com.oracle.svm.reflect.target; +package com.oracle.svm.core.reflect.target; import static com.oracle.svm.core.annotate.TargetElement.CONSTRUCTOR_NAME; @@ -39,9 +39,6 @@ import com.oracle.svm.core.annotate.TargetClass; import com.oracle.svm.core.annotate.TargetElement; import com.oracle.svm.core.util.VMError; -import com.oracle.svm.hosted.image.NativeImageCodeCache; -import com.oracle.svm.reflect.hosted.ExecutableAccessorComputer; -import com.oracle.svm.reflect.hosted.ReflectionMetadataComputer; import jdk.vm.ci.meta.MetaAccessProvider; import jdk.vm.ci.meta.ResolvedJavaField; @@ -79,14 +76,14 @@ Target_jdk_internal_reflect_ConstructorAccessor acquireConstructorAccessor() { static class AnnotationsComputer extends ReflectionMetadataComputer { @Override public Object compute(MetaAccessProvider metaAccess, ResolvedJavaField original, ResolvedJavaField annotated, Object receiver) { - return ImageSingletons.lookup(NativeImageCodeCache.ReflectionMetadataEncoder.class).getAnnotationsEncoding((AccessibleObject) receiver); + return ImageSingletons.lookup(EncodedReflectionMetadataSupplier.class).getAnnotationsEncoding((AccessibleObject) receiver); } } static class ParameterAnnotationsComputer extends ReflectionMetadataComputer { @Override public Object compute(MetaAccessProvider metaAccess, ResolvedJavaField original, ResolvedJavaField annotated, Object receiver) { - return ImageSingletons.lookup(NativeImageCodeCache.ReflectionMetadataEncoder.class).getParameterAnnotationsEncoding((Executable) receiver); + return ImageSingletons.lookup(EncodedReflectionMetadataSupplier.class).getParameterAnnotationsEncoding((Executable) receiver); } } } diff --git a/substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/target/Target_java_lang_reflect_Executable.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/target/Target_java_lang_reflect_Executable.java similarity index 90% rename from substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/target/Target_java_lang_reflect_Executable.java rename to substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/target/Target_java_lang_reflect_Executable.java index 152b5186e681..684d005bf83e 100644 --- a/substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/target/Target_java_lang_reflect_Executable.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/target/Target_java_lang_reflect_Executable.java @@ -22,7 +22,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package com.oracle.svm.reflect.target; +package com.oracle.svm.core.reflect.target; import java.lang.annotation.Annotation; import java.lang.reflect.Executable; @@ -39,8 +39,6 @@ import com.oracle.svm.core.annotate.Substitute; import com.oracle.svm.core.annotate.TargetClass; import com.oracle.svm.core.reflect.ReflectionMetadataDecoder; -import com.oracle.svm.hosted.image.NativeImageCodeCache; -import com.oracle.svm.reflect.hosted.ReflectionMetadataComputer; import jdk.vm.ci.meta.MetaAccessProvider; import jdk.vm.ci.meta.ResolvedJavaField; @@ -73,7 +71,7 @@ byte[] getTypeAnnotationBytes0() { static class RawParametersComputer extends ReflectionMetadataComputer { @Override public Object compute(MetaAccessProvider metaAccess, ResolvedJavaField original, ResolvedJavaField annotated, Object receiver) { - return ImageSingletons.lookup(NativeImageCodeCache.ReflectionMetadataEncoder.class).getReflectParametersEncoding((Executable) receiver); + return ImageSingletons.lookup(EncodedReflectionMetadataSupplier.class).getReflectParametersEncoding((Executable) receiver); } } } diff --git a/substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/target/Target_java_lang_reflect_Field.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/target/Target_java_lang_reflect_Field.java similarity index 92% rename from substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/target/Target_java_lang_reflect_Field.java rename to substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/target/Target_java_lang_reflect_Field.java index 83fa05ba740d..c41aa4e80ce4 100644 --- a/substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/target/Target_java_lang_reflect_Field.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/target/Target_java_lang_reflect_Field.java @@ -22,7 +22,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package com.oracle.svm.reflect.target; +package com.oracle.svm.core.reflect.target; import static com.oracle.svm.core.annotate.TargetElement.CONSTRUCTOR_NAME; @@ -48,9 +48,6 @@ import com.oracle.svm.core.jdk.JDK17OrLater; import com.oracle.svm.core.jdk.JDK19OrLater; import com.oracle.svm.core.util.VMError; -import com.oracle.svm.hosted.image.NativeImageCodeCache; -import com.oracle.svm.reflect.hosted.FieldOffsetComputer; -import com.oracle.svm.reflect.hosted.ReflectionMetadataComputer; import com.oracle.svm.util.GuardedAnnotationAccess; import jdk.vm.ci.meta.MetaAccessProvider; @@ -110,7 +107,6 @@ public final class Target_java_lang_reflect_Field { @SuppressWarnings("hiding") native void constructorJDK11OrEarlier(Class declaringClass, String name, Class type, int modifiers, int slot, String signature, byte[] annotations); - /** @see com.oracle.svm.hosted.substitute.AnnotationSubstitutionProcessor#deleteErrorMessage */ @Substitute @TargetElement(onlyWith = JDK17OrEarlier.class) Target_jdk_internal_reflect_FieldAccessor getFieldAccessor(@SuppressWarnings("unused") Object obj) { @@ -127,7 +123,6 @@ Target_jdk_internal_reflect_FieldAccessor getFieldAccessor(@SuppressWarnings("un return acquireFieldAccessor(ov); } - /** @see com.oracle.svm.hosted.substitute.AnnotationSubstitutionProcessor#deleteErrorMessage */ @Substitute @TargetElement(onlyWith = JDK19OrLater.class) Target_jdk_internal_reflect_FieldAccessor getFieldAccessor() { @@ -143,7 +138,6 @@ Target_jdk_internal_reflect_FieldAccessor getFieldAccessor() { return acquireFieldAccessor(); } - /** @see com.oracle.svm.hosted.substitute.AnnotationSubstitutionProcessor#deleteErrorMessage */ @Substitute @TargetElement(onlyWith = JDK19OrLater.class) Target_jdk_internal_reflect_FieldAccessor getOverrideFieldAccessor() { @@ -181,7 +175,7 @@ public Object compute(MetaAccessProvider metaAccess, ResolvedJavaField original, static class AnnotationsComputer extends ReflectionMetadataComputer { @Override public Object compute(MetaAccessProvider metaAccess, ResolvedJavaField original, ResolvedJavaField annotated, Object receiver) { - return ImageSingletons.lookup(NativeImageCodeCache.ReflectionMetadataEncoder.class).getAnnotationsEncoding((AccessibleObject) receiver); + return ImageSingletons.lookup(EncodedReflectionMetadataSupplier.class).getAnnotationsEncoding((AccessibleObject) receiver); } } } diff --git a/substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/target/Target_java_lang_reflect_Method.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/target/Target_java_lang_reflect_Method.java similarity index 85% rename from substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/target/Target_java_lang_reflect_Method.java rename to substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/target/Target_java_lang_reflect_Method.java index d064cb6e496f..73d5c526c2e2 100644 --- a/substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/target/Target_java_lang_reflect_Method.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/target/Target_java_lang_reflect_Method.java @@ -22,7 +22,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package com.oracle.svm.reflect.target; +package com.oracle.svm.core.reflect.target; import static com.oracle.svm.core.annotate.TargetElement.CONSTRUCTOR_NAME; @@ -39,9 +39,6 @@ import com.oracle.svm.core.annotate.TargetClass; import com.oracle.svm.core.annotate.TargetElement; import com.oracle.svm.core.util.VMError; -import com.oracle.svm.hosted.image.NativeImageCodeCache; -import com.oracle.svm.reflect.hosted.ExecutableAccessorComputer; -import com.oracle.svm.reflect.hosted.ReflectionMetadataComputer; import jdk.vm.ci.meta.MetaAccessProvider; import jdk.vm.ci.meta.ResolvedJavaField; @@ -82,21 +79,21 @@ public Target_jdk_internal_reflect_MethodAccessor acquireMethodAccessor() { static class AnnotationsComputer extends ReflectionMetadataComputer { @Override public Object compute(MetaAccessProvider metaAccess, ResolvedJavaField original, ResolvedJavaField annotated, Object receiver) { - return ImageSingletons.lookup(NativeImageCodeCache.ReflectionMetadataEncoder.class).getAnnotationsEncoding((AccessibleObject) receiver); + return ImageSingletons.lookup(EncodedReflectionMetadataSupplier.class).getAnnotationsEncoding((AccessibleObject) receiver); } } static class ParameterAnnotationsComputer extends ReflectionMetadataComputer { @Override public Object compute(MetaAccessProvider metaAccess, ResolvedJavaField original, ResolvedJavaField annotated, Object receiver) { - return ImageSingletons.lookup(NativeImageCodeCache.ReflectionMetadataEncoder.class).getParameterAnnotationsEncoding((Executable) receiver); + return ImageSingletons.lookup(EncodedReflectionMetadataSupplier.class).getParameterAnnotationsEncoding((Executable) receiver); } } static class AnnotationDefaultComputer extends ReflectionMetadataComputer { @Override public Object compute(MetaAccessProvider metaAccess, ResolvedJavaField original, ResolvedJavaField annotated, Object receiver) { - return ImageSingletons.lookup(NativeImageCodeCache.ReflectionMetadataEncoder.class).getAnnotationDefaultEncoding((Method) receiver); + return ImageSingletons.lookup(EncodedReflectionMetadataSupplier.class).getAnnotationDefaultEncoding((Method) receiver); } } } diff --git a/substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/target/Target_java_lang_reflect_Parameter.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/target/Target_java_lang_reflect_Parameter.java similarity index 97% rename from substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/target/Target_java_lang_reflect_Parameter.java rename to substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/target/Target_java_lang_reflect_Parameter.java index 9b9d03d68b31..def7dfb53cde 100644 --- a/substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/target/Target_java_lang_reflect_Parameter.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/target/Target_java_lang_reflect_Parameter.java @@ -22,7 +22,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package com.oracle.svm.reflect.target; +package com.oracle.svm.core.reflect.target; import java.lang.reflect.Executable; import java.lang.reflect.Parameter; diff --git a/substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/target/Target_java_lang_reflect_ReflectAccess.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/target/Target_java_lang_reflect_ReflectAccess.java similarity index 94% rename from substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/target/Target_java_lang_reflect_ReflectAccess.java rename to substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/target/Target_java_lang_reflect_ReflectAccess.java index f46bed4838f1..8696746aa3f1 100644 --- a/substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/target/Target_java_lang_reflect_ReflectAccess.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/target/Target_java_lang_reflect_ReflectAccess.java @@ -22,10 +22,10 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package com.oracle.svm.reflect.target; +package com.oracle.svm.core.reflect.target; -import static com.oracle.svm.reflect.target.Util_java_lang_reflect_ReflectAccess.copyAccessibleObject; -import static com.oracle.svm.reflect.target.Util_java_lang_reflect_ReflectAccess.copyExecutable; +import static com.oracle.svm.core.reflect.target.Util_java_lang_reflect_ReflectAccess.copyAccessibleObject; +import static com.oracle.svm.core.reflect.target.Util_java_lang_reflect_ReflectAccess.copyExecutable; import com.oracle.svm.core.SubstrateUtil; import com.oracle.svm.core.annotate.Substitute; diff --git a/substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/target/Target_jdk_internal_misc_Unsafe_Reflection.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/target/Target_jdk_internal_misc_Unsafe_Reflection.java similarity index 98% rename from substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/target/Target_jdk_internal_misc_Unsafe_Reflection.java rename to substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/target/Target_jdk_internal_misc_Unsafe_Reflection.java index 9b7eb71c316a..1fc5303ac94c 100644 --- a/substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/target/Target_jdk_internal_misc_Unsafe_Reflection.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/target/Target_jdk_internal_misc_Unsafe_Reflection.java @@ -23,7 +23,7 @@ * questions. */ -package com.oracle.svm.reflect.target; +package com.oracle.svm.core.reflect.target; import java.lang.reflect.Field; diff --git a/substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/target/Target_jdk_internal_reflect_AccessorGenerator.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/target/Target_jdk_internal_reflect_AccessorGenerator.java similarity index 95% rename from substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/target/Target_jdk_internal_reflect_AccessorGenerator.java rename to substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/target/Target_jdk_internal_reflect_AccessorGenerator.java index 19c47d81bf29..dbd2dddf7c20 100644 --- a/substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/target/Target_jdk_internal_reflect_AccessorGenerator.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/target/Target_jdk_internal_reflect_AccessorGenerator.java @@ -22,13 +22,13 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package com.oracle.svm.reflect.target; +package com.oracle.svm.core.reflect.target; import org.graalvm.nativeimage.ImageSingletons; import com.oracle.svm.core.annotate.Substitute; import com.oracle.svm.core.annotate.TargetClass; -import com.oracle.svm.reflect.serialize.SerializationRegistry; +import com.oracle.svm.core.reflect.serialize.SerializationRegistry; @TargetClass(className = "jdk.internal.reflect.AccessorGenerator") public final class Target_jdk_internal_reflect_AccessorGenerator { diff --git a/substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/target/Target_jdk_internal_reflect_ConstructorAccessor.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/target/Target_jdk_internal_reflect_ConstructorAccessor.java similarity index 96% rename from substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/target/Target_jdk_internal_reflect_ConstructorAccessor.java rename to substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/target/Target_jdk_internal_reflect_ConstructorAccessor.java index 333280cde456..c85eb65da81f 100644 --- a/substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/target/Target_jdk_internal_reflect_ConstructorAccessor.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/target/Target_jdk_internal_reflect_ConstructorAccessor.java @@ -22,7 +22,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package com.oracle.svm.reflect.target; +package com.oracle.svm.core.reflect.target; import com.oracle.svm.core.annotate.TargetClass; diff --git a/substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/target/Target_jdk_internal_reflect_FieldAccessor.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/target/Target_jdk_internal_reflect_FieldAccessor.java similarity index 96% rename from substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/target/Target_jdk_internal_reflect_FieldAccessor.java rename to substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/target/Target_jdk_internal_reflect_FieldAccessor.java index 868881d2a4cf..840b9f3e5fa3 100644 --- a/substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/target/Target_jdk_internal_reflect_FieldAccessor.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/target/Target_jdk_internal_reflect_FieldAccessor.java @@ -22,7 +22,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package com.oracle.svm.reflect.target; +package com.oracle.svm.core.reflect.target; import com.oracle.svm.core.annotate.TargetClass; diff --git a/substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/target/Target_jdk_internal_reflect_MethodAccessor.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/target/Target_jdk_internal_reflect_MethodAccessor.java similarity index 96% rename from substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/target/Target_jdk_internal_reflect_MethodAccessor.java rename to substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/target/Target_jdk_internal_reflect_MethodAccessor.java index 4b3c8c310edf..300749ec9136 100644 --- a/substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/target/Target_jdk_internal_reflect_MethodAccessor.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/target/Target_jdk_internal_reflect_MethodAccessor.java @@ -22,7 +22,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package com.oracle.svm.reflect.target; +package com.oracle.svm.core.reflect.target; import com.oracle.svm.core.annotate.TargetClass; diff --git a/substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/target/Target_sun_reflect_annotation_AnnotationInvocationHandler.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/target/Target_sun_reflect_annotation_AnnotationInvocationHandler.java similarity index 99% rename from substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/target/Target_sun_reflect_annotation_AnnotationInvocationHandler.java rename to substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/target/Target_sun_reflect_annotation_AnnotationInvocationHandler.java index 25713cd62281..06d72e568291 100644 --- a/substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/target/Target_sun_reflect_annotation_AnnotationInvocationHandler.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/target/Target_sun_reflect_annotation_AnnotationInvocationHandler.java @@ -22,7 +22,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package com.oracle.svm.reflect.target; +package com.oracle.svm.core.reflect.target; import java.util.ArrayList; import java.util.List; diff --git a/substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/target/Target_sun_reflect_annotation_AnnotationParser.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/target/Target_sun_reflect_annotation_AnnotationParser.java similarity index 97% rename from substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/target/Target_sun_reflect_annotation_AnnotationParser.java rename to substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/target/Target_sun_reflect_annotation_AnnotationParser.java index e8a44343fea8..7c520fc8458c 100644 --- a/substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/target/Target_sun_reflect_annotation_AnnotationParser.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/target/Target_sun_reflect_annotation_AnnotationParser.java @@ -22,7 +22,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package com.oracle.svm.reflect.target; +package com.oracle.svm.core.reflect.target; import java.lang.annotation.Annotation; import java.lang.annotation.AnnotationFormatError; @@ -40,8 +40,6 @@ import com.oracle.svm.core.code.CodeInfoTable; import com.oracle.svm.core.reflect.Target_jdk_internal_reflect_ConstantPool; import com.oracle.svm.core.util.VMError; -import com.oracle.svm.hosted.annotation.AnnotationValue; -import com.oracle.svm.reflect.hosted.ReflectionMetadataEncoderImpl; import sun.reflect.annotation.AnnotationParser; import sun.reflect.annotation.AnnotationType; @@ -50,9 +48,8 @@ /** * Substitutions in this class are required to adapt the JDK encoding for annotations to our - * modified version of it. See - * {@link ReflectionMetadataEncoderImpl#encodeAnnotations(AnnotationValue[])} for a description of - * the changes and the rationale behind them. + * modified version of it. See {@code ReflectionMetadataEncoderImpl.encodeAnnotations()} for a + * description of the changes and the rationale behind them. */ @TargetClass(AnnotationParser.class) public final class Target_sun_reflect_annotation_AnnotationParser { diff --git a/substratevm/src/com.oracle.svm.graal.hotspot.libgraal/src/com/oracle/svm/graal/hotspot/libgraal/LibGraalFeature.java b/substratevm/src/com.oracle.svm.graal.hotspot.libgraal/src/com/oracle/svm/graal/hotspot/libgraal/LibGraalFeature.java index 2a19400c6467..b56efb20177c 100644 --- a/substratevm/src/com.oracle.svm.graal.hotspot.libgraal/src/com/oracle/svm/graal/hotspot/libgraal/LibGraalFeature.java +++ b/substratevm/src/com.oracle.svm.graal.hotspot.libgraal/src/com/oracle/svm/graal/hotspot/libgraal/LibGraalFeature.java @@ -139,7 +139,7 @@ import com.oracle.svm.hosted.FeatureImpl.DuringSetupAccessImpl; import com.oracle.svm.hosted.ImageClassLoader; import com.oracle.svm.hosted.jni.JNIFeature; -import com.oracle.svm.reflect.hosted.ReflectionFeature; +import com.oracle.svm.hosted.reflect.ReflectionFeature; import com.oracle.svm.util.ModuleSupport; import com.oracle.svm.util.ReflectionUtil; diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ProgressReporter.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ProgressReporter.java index c99619020c6e..2d8df430dc0d 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ProgressReporter.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ProgressReporter.java @@ -90,7 +90,7 @@ import com.oracle.svm.hosted.code.CompileQueue.CompileTask; import com.oracle.svm.hosted.image.AbstractImage.NativeImageKind; import com.oracle.svm.hosted.image.NativeImageHeap.ObjectInfo; -import com.oracle.svm.hosted.meta.InternalRuntimeReflectionSupport; +import com.oracle.svm.hosted.reflect.ReflectionHostedSupport; import com.oracle.svm.util.ImageBuildStatistics; import com.oracle.svm.util.ReflectionUtil; @@ -353,7 +353,7 @@ private void printAnalysisStatistics(AnalysisUniverse universe, Collection economicMapImpl; private final Field economicMapImplEntriesField; private final Field economicMapImplHashArrayField; - private final InternalRuntimeReflectionSupport reflectionSupport; + private final ReflectionHostedSupport reflectionSupport; public SVMImageHeapScanner(ImageHeap imageHeap, ImageClassLoader loader, AnalysisMetaAccess metaAccess, SnippetReflectionProvider snippetReflection, ConstantReflectionProvider aConstantReflection, ObjectScanningObserver aScanningObserver) { @@ -72,7 +72,7 @@ public SVMImageHeapScanner(ImageHeap imageHeap, ImageClassLoader loader, Analysi economicMapImplEntriesField = ReflectionUtil.lookupField(economicMapImpl, "entries"); economicMapImplHashArrayField = ReflectionUtil.lookupField(economicMapImpl, "hashArray"); ImageSingletons.add(ImageHeapScanner.class, this); - reflectionSupport = ImageSingletons.lookup(InternalRuntimeReflectionSupport.class); + reflectionSupport = ImageSingletons.lookup(ReflectionHostedSupport.class); } public static ImageHeapScanner instance() { diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/heap/SVMImageHeapVerifier.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/heap/SVMImageHeapVerifier.java index 4e40d481aa3e..e049deed020b 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/heap/SVMImageHeapVerifier.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/heap/SVMImageHeapVerifier.java @@ -35,7 +35,7 @@ import com.oracle.graal.pointsto.util.CompletionExecutor; import com.oracle.svm.core.meta.SubstrateObjectConstant; import com.oracle.svm.hosted.SVMHost; -import com.oracle.svm.hosted.meta.InternalRuntimeReflectionSupport; +import com.oracle.svm.hosted.reflect.ReflectionHostedSupport; import jdk.vm.ci.meta.JavaConstant; @@ -62,7 +62,7 @@ public boolean requireAnalysisIteration(CompletionExecutor executor) throws Inte * */ private static boolean imageStateModified() { - return ImageSingletons.lookup(InternalRuntimeReflectionSupport.class).requiresProcessing() || + return ImageSingletons.lookup(ReflectionHostedSupport.class).requiresProcessing() || ImageSingletons.lookup(ImageHeapMapFeature.class).imageHeapMapNeedsUpdate(); } diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/NativeImageCodeCache.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/NativeImageCodeCache.java index bdfd8c0bbeb5..f9f678e9fa9a 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/NativeImageCodeCache.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/NativeImageCodeCache.java @@ -29,7 +29,6 @@ import java.lang.reflect.AccessibleObject; import java.lang.reflect.Executable; import java.lang.reflect.Field; -import java.lang.reflect.Method; import java.nio.ByteBuffer; import java.nio.file.Path; import java.util.ArrayList; @@ -79,6 +78,7 @@ import com.oracle.svm.core.meta.SubstrateObjectConstant; import com.oracle.svm.core.option.HostedOptionKey; import com.oracle.svm.core.option.HostedOptionValues; +import com.oracle.svm.core.reflect.target.EncodedReflectionMetadataSupplier; import com.oracle.svm.core.util.Counter; import com.oracle.svm.core.util.VMError; import com.oracle.svm.hosted.NativeImageOptions; @@ -92,7 +92,7 @@ import com.oracle.svm.hosted.meta.HostedMethod; import com.oracle.svm.hosted.meta.HostedType; import com.oracle.svm.hosted.meta.HostedUniverse; -import com.oracle.svm.hosted.meta.InternalRuntimeReflectionSupport; +import com.oracle.svm.hosted.reflect.ReflectionHostedSupport; import jdk.vm.ci.code.BytecodeFrame; import jdk.vm.ci.code.site.Call; @@ -254,7 +254,7 @@ public void buildRuntimeMetadata(CFunctionPointer firstMethod, UnsignedWord code } ReflectionMetadataEncoder reflectionMetadataEncoder = ImageSingletons.lookup(ReflectionMetadataEncoderFactory.class).create(encoders); - InternalRuntimeReflectionSupport reflectionSupport = ImageSingletons.lookup(InternalRuntimeReflectionSupport.class); + ReflectionHostedSupport reflectionSupport = ImageSingletons.lookup(ReflectionHostedSupport.class); HostedUniverse hUniverse = imageHeap.getUniverse(); HostedMetaAccess hMetaAccess = imageHeap.getMetaAccess(); @@ -650,7 +650,7 @@ protected boolean isDeoptEntry(ResolvedJavaMethod method, Infopoint infopoint) { } } - public interface ReflectionMetadataEncoder { + public interface ReflectionMetadataEncoder extends EncodedReflectionMetadataSupplier { void addClassMetadata(MetaAccessProvider metaAccess, HostedType type, Class[] reflectionClasses); void addReflectionFieldMetadata(MetaAccessProvider metaAccess, HostedField sharedField, Field reflectField); @@ -669,15 +669,6 @@ public interface ReflectionMetadataEncoder { void encodeAllAndInstall(); - byte[] getAnnotationsEncoding(AccessibleObject object); - - byte[] getParameterAnnotationsEncoding(Executable object); - - byte[] getAnnotationDefaultEncoding(Method object); - - byte[] getTypeAnnotationsEncoding(AccessibleObject object); - - byte[] getReflectParametersEncoding(Executable object); } public interface ReflectionMetadataEncoderFactory { diff --git a/substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/hosted/AnnotationEncoder.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/AnnotationEncoder.java similarity index 99% rename from substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/hosted/AnnotationEncoder.java rename to substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/AnnotationEncoder.java index f15336da38f2..5287df3acaff 100644 --- a/substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/hosted/AnnotationEncoder.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/AnnotationEncoder.java @@ -22,7 +22,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package com.oracle.svm.reflect.hosted; +package com.oracle.svm.hosted.reflect; import java.util.function.Consumer; @@ -30,14 +30,14 @@ import org.graalvm.compiler.debug.GraalError; import com.oracle.svm.core.code.CodeInfoEncoder.Encoders; -import com.oracle.svm.hosted.annotation.AnnotationMemberValue; -import com.oracle.svm.hosted.annotation.AnnotationValue; import com.oracle.svm.hosted.annotation.AnnotationArrayValue; import com.oracle.svm.hosted.annotation.AnnotationClassValue; import com.oracle.svm.hosted.annotation.AnnotationEnumValue; import com.oracle.svm.hosted.annotation.AnnotationExceptionProxyValue; +import com.oracle.svm.hosted.annotation.AnnotationMemberValue; import com.oracle.svm.hosted.annotation.AnnotationPrimitiveValue; import com.oracle.svm.hosted.annotation.AnnotationStringValue; +import com.oracle.svm.hosted.annotation.AnnotationValue; import com.oracle.svm.hosted.annotation.TypeAnnotationValue; public class AnnotationEncoder { diff --git a/substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/hosted/ReflectionDataBuilder.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/ReflectionDataBuilder.java similarity index 99% rename from substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/hosted/ReflectionDataBuilder.java rename to substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/ReflectionDataBuilder.java index ca53f7b12a29..9c502edc8b3e 100644 --- a/substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/hosted/ReflectionDataBuilder.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/ReflectionDataBuilder.java @@ -22,7 +22,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package com.oracle.svm.reflect.hosted; +package com.oracle.svm.hosted.reflect; import java.lang.reflect.AccessibleObject; import java.lang.reflect.AnnotatedElement; @@ -53,6 +53,7 @@ import org.graalvm.nativeimage.hosted.Feature.DuringAnalysisAccess; import org.graalvm.nativeimage.hosted.RuntimeReflection; import org.graalvm.nativeimage.impl.ConfigurationCondition; +import org.graalvm.nativeimage.impl.RuntimeReflectionSupport; import com.oracle.graal.pointsto.constraints.UnsupportedFeatureException; import com.oracle.graal.pointsto.meta.AnalysisField; @@ -61,8 +62,8 @@ import com.oracle.svm.core.SubstrateOptions; import com.oracle.svm.core.annotate.InjectAccessors; import com.oracle.svm.core.hub.ClassForNameSupport; -import com.oracle.svm.core.hub.DynamicHub; import com.oracle.svm.core.hub.ClassLoadingExceptionSupport; +import com.oracle.svm.core.hub.DynamicHub; import com.oracle.svm.core.jdk.RecordSupport; import com.oracle.svm.core.jdk.proxy.DynamicProxyRegistry; import com.oracle.svm.core.reflect.SubstrateAccessor; @@ -75,7 +76,6 @@ import com.oracle.svm.hosted.annotation.AnnotationValue; import com.oracle.svm.hosted.annotation.SubstrateAnnotationExtracter; import com.oracle.svm.hosted.annotation.TypeAnnotationValue; -import com.oracle.svm.hosted.meta.InternalRuntimeReflectionSupport; import com.oracle.svm.hosted.substitute.SubstitutionReflectivityFilter; import com.oracle.svm.util.GuardedAnnotationAccess; @@ -85,7 +85,7 @@ import jdk.vm.ci.meta.ResolvedJavaType; import sun.reflect.annotation.ExceptionProxy; -public class ReflectionDataBuilder extends ConditionalConfigurationRegistry implements InternalRuntimeReflectionSupport { +public class ReflectionDataBuilder extends ConditionalConfigurationRegistry implements RuntimeReflectionSupport, ReflectionHostedSupport { private final Set> modifiedClasses = ConcurrentHashMap.newKeySet(); private boolean sealed; diff --git a/substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/hosted/ReflectionExpandSignatureMethod.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/ReflectionExpandSignatureMethod.java similarity index 99% rename from substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/hosted/ReflectionExpandSignatureMethod.java rename to substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/ReflectionExpandSignatureMethod.java index dfdaecf5438b..6cc7a41a9d92 100644 --- a/substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/hosted/ReflectionExpandSignatureMethod.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/ReflectionExpandSignatureMethod.java @@ -22,7 +22,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package com.oracle.svm.reflect.hosted; +package com.oracle.svm.hosted.reflect; import org.graalvm.compiler.core.common.type.StampFactory; import org.graalvm.compiler.core.common.type.StampPair; diff --git a/substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/hosted/ReflectionFeature.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/ReflectionFeature.java similarity index 91% rename from substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/hosted/ReflectionFeature.java rename to substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/ReflectionFeature.java index ac382e3d1586..f80b825660bb 100644 --- a/substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/hosted/ReflectionFeature.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/ReflectionFeature.java @@ -22,11 +22,12 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package com.oracle.svm.reflect.hosted; +package com.oracle.svm.hosted.reflect; import java.lang.invoke.MethodHandle; import java.lang.reflect.Constructor; import java.lang.reflect.Executable; +import java.lang.reflect.Field; import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.util.Arrays; @@ -34,8 +35,6 @@ import java.util.Objects; import java.util.concurrent.ConcurrentHashMap; -import com.oracle.svm.hosted.annotation.SubstrateAnnotationExtracter; -import com.oracle.svm.util.AnnotationExtracter; import org.graalvm.compiler.api.replacements.SnippetReflectionProvider; import org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins; import org.graalvm.compiler.phases.util.Providers; @@ -60,17 +59,22 @@ import com.oracle.svm.core.reflect.SubstrateAccessor; import com.oracle.svm.core.reflect.SubstrateConstructorAccessor; import com.oracle.svm.core.reflect.SubstrateMethodAccessor; +import com.oracle.svm.core.reflect.target.ReflectionSubstitutionSupport; import com.oracle.svm.core.util.VMError; import com.oracle.svm.hosted.FallbackFeature; import com.oracle.svm.hosted.FeatureImpl; +import com.oracle.svm.hosted.FeatureImpl.BeforeCompilationAccessImpl; import com.oracle.svm.hosted.FeatureImpl.DuringSetupAccessImpl; import com.oracle.svm.hosted.ImageClassLoader; import com.oracle.svm.hosted.analysis.Inflation; +import com.oracle.svm.hosted.annotation.SubstrateAnnotationExtracter; import com.oracle.svm.hosted.code.FactoryMethodSupport; import com.oracle.svm.hosted.config.ConfigurationParserUtils; -import com.oracle.svm.hosted.meta.InternalRuntimeReflectionSupport; +import com.oracle.svm.hosted.meta.HostedField; +import com.oracle.svm.hosted.meta.HostedMetaAccess; import com.oracle.svm.hosted.snippets.ReflectionPlugins; import com.oracle.svm.hosted.substitute.AnnotationSubstitutionProcessor; +import com.oracle.svm.util.AnnotationExtracter; import com.oracle.svm.util.ModuleSupport; import com.oracle.svm.util.ReflectionUtil; @@ -78,7 +82,7 @@ import jdk.vm.ci.meta.ResolvedJavaMethod; @AutomaticFeature -public class ReflectionFeature implements InternalFeature { +public class ReflectionFeature implements InternalFeature, ReflectionSubstitutionSupport { private AnnotationSubstitutionProcessor annotationSubstitutions; @@ -86,6 +90,7 @@ public class ReflectionFeature implements InternalFeature { private ImageClassLoader loader; private AnalysisUniverse aUniverse; private int loadedConfigurations; + private HostedMetaAccess hMetaAccess; final Map accessors = new ConcurrentHashMap<>(); private final Map expandSignatureMethods = new ConcurrentHashMap<>(); @@ -99,7 +104,8 @@ public class ReflectionFeature implements InternalFeature { FeatureImpl.BeforeAnalysisAccessImpl analysisAccess; - SubstrateAccessor getOrCreateAccessor(Executable member) { + @Override + public SubstrateAccessor getOrCreateAccessor(Executable member) { SubstrateAccessor existing = accessors.get(member); if (existing != null) { return existing; @@ -204,9 +210,11 @@ private MethodPointer register(ResolvedJavaMethod method) { public void afterRegistration(AfterRegistrationAccess access) { ModuleSupport.accessPackagesToClass(ModuleSupport.Access.OPEN, null, false, "java.base", "jdk.internal.reflect"); + ImageSingletons.add(ReflectionSubstitutionSupport.class, this); + reflectionData = new ReflectionDataBuilder((SubstrateAnnotationExtracter) ImageSingletons.lookup(AnnotationExtracter.class)); ImageSingletons.add(RuntimeReflectionSupport.class, reflectionData); - ImageSingletons.add(InternalRuntimeReflectionSupport.class, reflectionData); + ImageSingletons.add(ReflectionHostedSupport.class, reflectionData); } @Override @@ -253,6 +261,24 @@ public void beforeCompilation(BeforeCompilationAccess access) { if (reflectionFallback != null && loadedConfigurations == 0) { throw reflectionFallback; } + hMetaAccess = ((BeforeCompilationAccessImpl) access).getMetaAccess(); + } + + @Override + public int getFieldOffset(Field field) { + VMError.guarantee(hMetaAccess != null, "Field offsets are available only for compilation and afterwards."); + + /* + * We have to use `optionalLookupJavaField` as fields are omitted when there is no + * reflective access in an image. + */ + HostedField hostedField = hMetaAccess.optionalLookupJavaField(field); + if (hostedField == null || !hostedField.wrapped.isUnsafeAccessed()) { + return -1; + } + int location = hostedField.getLocation(); + VMError.guarantee(location > 0, "Incorrect field location: " + location + " for " + hostedField.format("%H.%n")); + return location; } @Override diff --git a/substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/hosted/ReflectionGraphKit.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/ReflectionGraphKit.java similarity index 99% rename from substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/hosted/ReflectionGraphKit.java rename to substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/ReflectionGraphKit.java index 2dc7e51ba6dd..d9511cdba79a 100644 --- a/substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/hosted/ReflectionGraphKit.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/ReflectionGraphKit.java @@ -22,7 +22,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package com.oracle.svm.reflect.hosted; +package com.oracle.svm.hosted.reflect; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/meta/InternalRuntimeReflectionSupport.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/ReflectionHostedSupport.java similarity index 92% rename from substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/meta/InternalRuntimeReflectionSupport.java rename to substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/ReflectionHostedSupport.java index 8aaaf8722e6d..a2f476e77d6e 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/meta/InternalRuntimeReflectionSupport.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/ReflectionHostedSupport.java @@ -22,7 +22,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package com.oracle.svm.hosted.meta; +package com.oracle.svm.hosted.reflect; import java.lang.reflect.AccessibleObject; import java.lang.reflect.Executable; @@ -30,9 +30,7 @@ import java.util.Map; import java.util.Set; -import org.graalvm.nativeimage.impl.RuntimeReflectionSupport; - -public interface InternalRuntimeReflectionSupport extends RuntimeReflectionSupport { +public interface ReflectionHostedSupport { Map, Set>> getReflectionInnerClasses(); Set getReflectionFields(); diff --git a/substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/hosted/ReflectionMetadata.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/ReflectionMetadata.java similarity index 98% rename from substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/hosted/ReflectionMetadata.java rename to substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/ReflectionMetadata.java index 112c9a4c841f..18a2410efd79 100644 --- a/substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/hosted/ReflectionMetadata.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/ReflectionMetadata.java @@ -22,7 +22,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package com.oracle.svm.reflect.hosted; +package com.oracle.svm.hosted.reflect; import static com.oracle.svm.core.meta.SharedField.LOC_UNINITIALIZED; @@ -31,13 +31,13 @@ import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.reflect.ReflectionMetadataDecoder; +import com.oracle.svm.core.reflect.target.ReflectionMetadataDecoderImpl; +import com.oracle.svm.core.reflect.target.ReflectionMetadataEncoding; import com.oracle.svm.hosted.annotation.AnnotationMemberValue; import com.oracle.svm.hosted.annotation.AnnotationValue; import com.oracle.svm.hosted.annotation.TypeAnnotationValue; import com.oracle.svm.hosted.image.NativeImageCodeCache.ReflectionMetadataEncoderFactory; import com.oracle.svm.hosted.meta.HostedType; -import com.oracle.svm.reflect.target.ReflectionMetadataDecoderImpl; -import com.oracle.svm.reflect.target.ReflectionMetadataEncoding; import jdk.vm.ci.meta.JavaConstant; diff --git a/substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/hosted/ReflectionMetadataEncoderImpl.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/ReflectionMetadataEncoderImpl.java similarity index 96% rename from substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/hosted/ReflectionMetadataEncoderImpl.java rename to substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/ReflectionMetadataEncoderImpl.java index a08d51f4f8a9..7536191ee546 100644 --- a/substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/hosted/ReflectionMetadataEncoderImpl.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/ReflectionMetadataEncoderImpl.java @@ -22,14 +22,22 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package com.oracle.svm.reflect.hosted; +package com.oracle.svm.hosted.reflect; import static com.oracle.svm.core.reflect.ReflectionMetadataDecoder.NO_DATA; -import static com.oracle.svm.reflect.target.ReflectionMetadataDecoderImpl.ALL_FLAGS_MASK; -import static com.oracle.svm.reflect.target.ReflectionMetadataDecoderImpl.COMPLETE_FLAG_MASK; -import static com.oracle.svm.reflect.target.ReflectionMetadataDecoderImpl.HIDING_FLAG_MASK; -import static com.oracle.svm.reflect.target.ReflectionMetadataDecoderImpl.IN_HEAP_FLAG_MASK; -import static com.oracle.svm.reflect.target.ReflectionMetadataDecoderImpl.NULL_OBJECT; +import static com.oracle.svm.core.reflect.target.ReflectionMetadataDecoderImpl.ALL_FLAGS_MASK; +import static com.oracle.svm.core.reflect.target.ReflectionMetadataDecoderImpl.COMPLETE_FLAG_MASK; +import static com.oracle.svm.core.reflect.target.ReflectionMetadataDecoderImpl.HIDING_FLAG_MASK; +import static com.oracle.svm.core.reflect.target.ReflectionMetadataDecoderImpl.IN_HEAP_FLAG_MASK; +import static com.oracle.svm.core.reflect.target.ReflectionMetadataDecoderImpl.NULL_OBJECT; +import static com.oracle.svm.hosted.reflect.ReflectionMetadata.AccessibleObjectMetadata; +import static com.oracle.svm.hosted.reflect.ReflectionMetadata.ClassMetadata; +import static com.oracle.svm.hosted.reflect.ReflectionMetadata.ConstructorMetadata; +import static com.oracle.svm.hosted.reflect.ReflectionMetadata.ExecutableMetadata; +import static com.oracle.svm.hosted.reflect.ReflectionMetadata.FieldMetadata; +import static com.oracle.svm.hosted.reflect.ReflectionMetadata.MethodMetadata; +import static com.oracle.svm.hosted.reflect.ReflectionMetadata.RecordComponentMetadata; +import static com.oracle.svm.hosted.reflect.ReflectionMetadata.ReflectParameterMetadata; import java.lang.reflect.AccessibleObject; import java.lang.reflect.AnnotatedElement; @@ -68,6 +76,10 @@ import com.oracle.svm.core.meta.SharedField; import com.oracle.svm.core.meta.SubstrateObjectConstant; import com.oracle.svm.core.reflect.Target_jdk_internal_reflect_ConstantPool; +import com.oracle.svm.core.reflect.target.EncodedReflectionMetadataSupplier; +import com.oracle.svm.core.reflect.target.ReflectionMetadataDecoderImpl; +import com.oracle.svm.core.reflect.target.ReflectionMetadataEncoding; +import com.oracle.svm.core.reflect.target.Target_sun_reflect_annotation_AnnotationParser; import com.oracle.svm.core.util.ByteArrayReader; import com.oracle.svm.core.util.VMError; import com.oracle.svm.hosted.annotation.AnnotationMemberValue; @@ -79,19 +91,7 @@ import com.oracle.svm.hosted.meta.HostedMetaAccess; import com.oracle.svm.hosted.meta.HostedMethod; import com.oracle.svm.hosted.meta.HostedType; -import com.oracle.svm.hosted.meta.InternalRuntimeReflectionSupport; import com.oracle.svm.hosted.substitute.DeletedElementException; -import com.oracle.svm.reflect.hosted.ReflectionMetadata.AccessibleObjectMetadata; -import com.oracle.svm.reflect.hosted.ReflectionMetadata.ClassMetadata; -import com.oracle.svm.reflect.hosted.ReflectionMetadata.ConstructorMetadata; -import com.oracle.svm.reflect.hosted.ReflectionMetadata.ExecutableMetadata; -import com.oracle.svm.reflect.hosted.ReflectionMetadata.FieldMetadata; -import com.oracle.svm.reflect.hosted.ReflectionMetadata.MethodMetadata; -import com.oracle.svm.reflect.hosted.ReflectionMetadata.RecordComponentMetadata; -import com.oracle.svm.reflect.hosted.ReflectionMetadata.ReflectParameterMetadata; -import com.oracle.svm.reflect.target.ReflectionMetadataDecoderImpl; -import com.oracle.svm.reflect.target.ReflectionMetadataEncoding; -import com.oracle.svm.reflect.target.Target_sun_reflect_annotation_AnnotationParser; import com.oracle.svm.util.GuardedAnnotationAccess; import com.oracle.svm.util.ReflectionUtil; @@ -588,7 +588,7 @@ private static ReflectParameterMetadata[] getReflectParameters(Executable reflec } private RecordComponentMetadata[] getRecordComponents(MetaAccessProvider metaAccess, HostedType declaringType, Class clazz) { - Object[] recordComponents = ImageSingletons.lookup(InternalRuntimeReflectionSupport.class).getRecordComponents(clazz); + Object[] recordComponents = ImageSingletons.lookup(ReflectionHostedSupport.class).getRecordComponents(clazz); if (recordComponents == null) { return null; } @@ -711,7 +711,7 @@ public void encodeAllAndInstall() { } install(buf); /* Enable field recomputers in reflection objects to see the computed values */ - ImageSingletons.add(ReflectionMetadataEncoder.class, this); + ImageSingletons.add(EncodedReflectionMetadataSupplier.class, this); } private static int encodeAndAddCollection(UnsafeArrayTypeWriter buf, T[] data, BiConsumer encodeCallback, boolean canBeNull) { diff --git a/substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/proxy/hosted/DynamicProxyFeature.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/proxy/DynamicProxyFeature.java similarity index 96% rename from substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/proxy/hosted/DynamicProxyFeature.java rename to substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/proxy/DynamicProxyFeature.java index c265f3d901c4..e4a34ed10eee 100644 --- a/substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/proxy/hosted/DynamicProxyFeature.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/proxy/DynamicProxyFeature.java @@ -22,7 +22,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package com.oracle.svm.reflect.proxy.hosted; +package com.oracle.svm.hosted.reflect.proxy; import java.lang.reflect.Field; import java.util.Collections; @@ -36,14 +36,14 @@ import com.oracle.svm.core.configure.ConfigurationFiles; import com.oracle.svm.core.configure.ProxyConfigurationParser; import com.oracle.svm.core.jdk.proxy.DynamicProxyRegistry; +import com.oracle.svm.core.reflect.proxy.DynamicProxySupport; import com.oracle.svm.hosted.ConfigurationTypeResolver; import com.oracle.svm.hosted.FallbackFeature; import com.oracle.svm.hosted.FeatureImpl.DuringAnalysisAccessImpl; import com.oracle.svm.hosted.FeatureImpl.DuringSetupAccessImpl; import com.oracle.svm.hosted.ImageClassLoader; import com.oracle.svm.hosted.config.ConfigurationParserUtils; -import com.oracle.svm.reflect.hosted.ReflectionFeature; -import com.oracle.svm.reflect.proxy.DynamicProxySupport; +import com.oracle.svm.hosted.reflect.ReflectionFeature; @AutomaticFeature public final class DynamicProxyFeature implements Feature { diff --git a/substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/proxy/hosted/ProxyRegistry.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/proxy/ProxyRegistry.java similarity index 98% rename from substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/proxy/hosted/ProxyRegistry.java rename to substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/proxy/ProxyRegistry.java index 824b1a0213fc..7b583240aa39 100644 --- a/substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/proxy/hosted/ProxyRegistry.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/proxy/ProxyRegistry.java @@ -22,7 +22,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package com.oracle.svm.reflect.proxy.hosted; +package com.oracle.svm.hosted.reflect.proxy; import java.util.List; import java.util.function.Consumer; diff --git a/substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/serialize/hosted/SerializationFeature.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/serialize/SerializationFeature.java similarity index 98% rename from substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/serialize/hosted/SerializationFeature.java rename to substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/serialize/SerializationFeature.java index 23f78995c760..6df9fa40e004 100644 --- a/substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/serialize/hosted/SerializationFeature.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/serialize/SerializationFeature.java @@ -23,10 +23,10 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package com.oracle.svm.reflect.serialize.hosted; +package com.oracle.svm.hosted.reflect.serialize; -import static com.oracle.svm.reflect.serialize.hosted.SerializationFeature.capturingClasses; -import static com.oracle.svm.reflect.serialize.hosted.SerializationFeature.warn; +import static com.oracle.svm.hosted.reflect.serialize.SerializationFeature.capturingClasses; +import static com.oracle.svm.hosted.reflect.serialize.SerializationFeature.warn; import java.io.Externalizable; import java.io.ObjectOutputStream; @@ -72,6 +72,8 @@ import com.oracle.svm.core.configure.ConfigurationFiles; import com.oracle.svm.core.configure.SerializationConfigurationParser; import com.oracle.svm.core.jdk.RecordSupport; +import com.oracle.svm.core.reflect.serialize.SerializationRegistry; +import com.oracle.svm.core.reflect.serialize.SerializationSupport; import com.oracle.svm.core.util.UserError; import com.oracle.svm.core.util.VMError; import com.oracle.svm.hosted.ConditionalConfigurationRegistry; @@ -81,9 +83,7 @@ import com.oracle.svm.hosted.FeatureImpl.BeforeAnalysisAccessImpl; import com.oracle.svm.hosted.ImageClassLoader; import com.oracle.svm.hosted.config.ConfigurationParserUtils; -import com.oracle.svm.reflect.hosted.ReflectionFeature; -import com.oracle.svm.reflect.serialize.SerializationRegistry; -import com.oracle.svm.reflect.serialize.SerializationSupport; +import com.oracle.svm.hosted.reflect.ReflectionFeature; import com.oracle.svm.util.ReflectionUtil; import jdk.internal.reflect.ReflectionFactory; diff --git a/substratevm/src/com.oracle.svm.junit/src/com/oracle/svm/junit/JUnitFeature.java b/substratevm/src/com.oracle.svm.junit/src/com/oracle/svm/junit/JUnitFeature.java index b4406081a8a4..e2ec68be2803 100644 --- a/substratevm/src/com.oracle.svm.junit/src/com/oracle/svm/junit/JUnitFeature.java +++ b/substratevm/src/com.oracle.svm.junit/src/com/oracle/svm/junit/JUnitFeature.java @@ -24,18 +24,15 @@ */ package com.oracle.svm.junit; -import java.util.Collections; -import java.util.List; import java.util.function.BooleanSupplier; -import com.oracle.svm.util.ModuleSupport; import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.nativeimage.hosted.RuntimeClassInitialization; import org.junit.runner.Description; import org.junit.runner.Request; -import com.oracle.svm.reflect.hosted.ReflectionFeature; +import com.oracle.svm.util.ModuleSupport; public final class JUnitFeature implements Feature { @@ -68,11 +65,6 @@ private static boolean includesClass(Description dn, Class clazz) { return clazz.equals(dn.getTestClass()) || dn.getChildren().stream().anyMatch(child -> includesClass(child, clazz)); } - @Override - public List> getRequiredFeatures() { - return Collections.singletonList(ReflectionFeature.class); - } - @Override public void afterRegistration(AfterRegistrationAccess access) { /* Open up builder to allow whitebox testing */ diff --git a/substratevm/src/com.oracle.svm.methodhandles/src/com/oracle/svm/methodhandles/Target_java_lang_invoke_MethodHandle.java b/substratevm/src/com.oracle.svm.methodhandles/src/com/oracle/svm/methodhandles/Target_java_lang_invoke_MethodHandle.java index dc1ad012857a..86285a6de399 100644 --- a/substratevm/src/com.oracle.svm.methodhandles/src/com/oracle/svm/methodhandles/Target_java_lang_invoke_MethodHandle.java +++ b/substratevm/src/com.oracle.svm.methodhandles/src/com/oracle/svm/methodhandles/Target_java_lang_invoke_MethodHandle.java @@ -41,10 +41,10 @@ import com.oracle.svm.core.invoke.MethodHandleUtils; import com.oracle.svm.core.invoke.Target_java_lang_invoke_MemberName; import com.oracle.svm.core.reflect.SubstrateMethodAccessor; +import com.oracle.svm.core.reflect.target.Target_java_lang_reflect_AccessibleObject; +import com.oracle.svm.core.reflect.target.Target_java_lang_reflect_Method; +import com.oracle.svm.core.reflect.target.Target_jdk_internal_reflect_MethodAccessor; import com.oracle.svm.core.util.VMError; -import com.oracle.svm.reflect.target.Target_java_lang_reflect_AccessibleObject; -import com.oracle.svm.reflect.target.Target_java_lang_reflect_Method; -import com.oracle.svm.reflect.target.Target_jdk_internal_reflect_MethodAccessor; import sun.invoke.util.ValueConversions; import sun.invoke.util.Wrapper; diff --git a/substratevm/src/com.oracle.svm.methodhandles/src/com/oracle/svm/methodhandles/Target_java_lang_invoke_MethodHandleNatives.java b/substratevm/src/com.oracle.svm.methodhandles/src/com/oracle/svm/methodhandles/Target_java_lang_invoke_MethodHandleNatives.java index e4b2205c9e85..de1a08760273 100644 --- a/substratevm/src/com.oracle.svm.methodhandles/src/com/oracle/svm/methodhandles/Target_java_lang_invoke_MethodHandleNatives.java +++ b/substratevm/src/com.oracle.svm.methodhandles/src/com/oracle/svm/methodhandles/Target_java_lang_invoke_MethodHandleNatives.java @@ -53,8 +53,8 @@ import com.oracle.svm.core.invoke.Target_java_lang_invoke_MemberName; import com.oracle.svm.core.jdk.JDK11OrEarlier; import com.oracle.svm.core.jdk.JDK17OrLater; +import com.oracle.svm.core.reflect.target.Target_java_lang_reflect_Field; import com.oracle.svm.core.util.VMError; -import com.oracle.svm.reflect.target.Target_java_lang_reflect_Field; import com.oracle.svm.util.ReflectionUtil; import sun.invoke.util.VerifyAccess; diff --git a/substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/serialize/hosted/package-info.java b/substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/serialize/hosted/package-info.java deleted file mode 100644 index 4ed038fb6147..000000000000 --- a/substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/serialize/hosted/package-info.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2021, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -@Platforms(Platform.HOSTED_ONLY.class) -package com.oracle.svm.reflect.serialize.hosted; - -import org.graalvm.nativeimage.Platform; -import org.graalvm.nativeimage.Platforms; diff --git a/truffle/src/com.oracle.truffle.tck.tests/src/com/oracle/truffle/tck/tests/TruffleTCKFeature.java b/truffle/src/com.oracle.truffle.tck.tests/src/com/oracle/truffle/tck/tests/TruffleTCKFeature.java index 72843289aa15..60d8782a854d 100644 --- a/truffle/src/com.oracle.truffle.tck.tests/src/com/oracle/truffle/tck/tests/TruffleTCKFeature.java +++ b/truffle/src/com.oracle.truffle.tck.tests/src/com/oracle/truffle/tck/tests/TruffleTCKFeature.java @@ -50,8 +50,6 @@ import java.nio.file.Files; import java.nio.file.Path; import java.util.Collection; -import java.util.Collections; -import java.util.List; import java.util.Map; import java.util.function.Function; import java.util.function.Supplier; @@ -70,15 +68,6 @@ public class TruffleTCKFeature implements Feature { - @Override - public List> getRequiredFeatures() { - try { - return Collections.singletonList(Class.forName("com.oracle.svm.reflect.hosted.ReflectionFeature").asSubclass(Feature.class)); - } catch (ClassNotFoundException cnf) { - throw new RuntimeException(cnf); - } - } - @Override public void beforeAnalysis(BeforeAnalysisAccess access) { try {