3535import java .lang .invoke .ConstantCallSite ;
3636import java .lang .invoke .MethodHandle ;
3737import java .lang .ref .WeakReference ;
38+ import java .lang .reflect .Executable ;
39+ import java .lang .reflect .Field ;
3840import java .nio .ByteBuffer ;
3941import java .nio .ByteOrder ;
4042import java .util .ArrayList ;
6062import jdk .vm .ci .common .NativeImageReinitialize ;
6163import jdk .vm .ci .meta .JavaKind ;
6264import jdk .vm .ci .meta .JavaType ;
65+ import jdk .vm .ci .meta .ResolvedJavaField ;
66+ import jdk .vm .ci .meta .ResolvedJavaMethod ;
6367import jdk .vm .ci .meta .ResolvedJavaType ;
6468import jdk .vm .ci .meta .UnresolvedJavaType ;
6569import jdk .vm .ci .runtime .JVMCI ;
@@ -769,7 +773,7 @@ public boolean test(ResolvedJavaType type) {
769773 }
770774
771775 /**
772- * Get the {@link Class} corresponding to {@code type}.
776+ * Gets the {@link Class} corresponding to {@code type}.
773777 *
774778 * @param type the type for which a {@link Class} is requested
775779 * @return the original Java class corresponding to {@code type} or {@code null} if this runtime
@@ -783,6 +787,36 @@ public Class<?> getMirror(ResolvedJavaType type) {
783787 return null ;
784788 }
785789
790+ /**
791+ * Gets the {@link Executable} corresponding to {@code method}.
792+ *
793+ * @param method the method for which an {@link Executable} is requested
794+ * @return the original Java method or constructor corresponding to {@code method} or
795+ * {@code null} if this runtime does not support mapping {@link ResolvedJavaMethod}
796+ * instances to {@link Executable} instances
797+ */
798+ public Executable getMirror (ResolvedJavaMethod method ) {
799+ if (method instanceof HotSpotResolvedJavaMethodImpl && reflection instanceof HotSpotJDKReflection ) {
800+ return HotSpotJDKReflection .getMethod ((HotSpotResolvedJavaMethodImpl ) method );
801+ }
802+ return null ;
803+ }
804+
805+ /**
806+ * Gets the {@link Field} corresponding to {@code field}.
807+ *
808+ * @param field the field for which a {@link Field} is requested
809+ * @return the original Java field corresponding to {@code field} or {@code null} if this
810+ * runtime does not support mapping {@link ResolvedJavaField} instances to {@link Field}
811+ * instances
812+ */
813+ public Field getMirror (ResolvedJavaField field ) {
814+ if (field instanceof HotSpotResolvedJavaFieldImpl && reflection instanceof HotSpotJDKReflection ) {
815+ return HotSpotJDKReflection .getField ((HotSpotResolvedJavaFieldImpl ) field );
816+ }
817+ return null ;
818+ }
819+
786820 static class ErrorCreatingCompiler implements JVMCICompiler {
787821 private final RuntimeException t ;
788822
0 commit comments