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 ;
@@ -767,7 +771,7 @@ public boolean test(ResolvedJavaType type) {
767771 }
768772
769773 /**
770- * Get the {@link Class} corresponding to {@code type}.
774+ * Gets the {@link Class} corresponding to {@code type}.
771775 *
772776 * @param type the type for which a {@link Class} is requested
773777 * @return the original Java class corresponding to {@code type} or {@code null} if this runtime
@@ -781,6 +785,36 @@ public Class<?> getMirror(ResolvedJavaType type) {
781785 return null ;
782786 }
783787
788+ /**
789+ * Gets the {@link Executable} corresponding to {@code method}.
790+ *
791+ * @param method the method for which an {@link Executable} is requested
792+ * @return the original Java method or constructor corresponding to {@code method} or
793+ * {@code null} if this runtime does not support mapping {@link ResolvedJavaMethod}
794+ * instances to {@link Executable} instances
795+ */
796+ public Executable getMirror (ResolvedJavaMethod method ) {
797+ if (method instanceof HotSpotResolvedJavaMethodImpl && reflection instanceof HotSpotJDKReflection ) {
798+ return HotSpotJDKReflection .getMethod ((HotSpotResolvedJavaMethodImpl ) method );
799+ }
800+ return null ;
801+ }
802+
803+ /**
804+ * Gets the {@link Field} corresponding to {@code field}.
805+ *
806+ * @param field the field for which a {@link Field} is requested
807+ * @return the original Java field corresponding to {@code field} or {@code null} if this
808+ * runtime does not support mapping {@link ResolvedJavaField} instances to {@link Field}
809+ * instances
810+ */
811+ public Field getMirror (ResolvedJavaField field ) {
812+ if (field instanceof HotSpotResolvedJavaFieldImpl && reflection instanceof HotSpotJDKReflection ) {
813+ return HotSpotJDKReflection .getField ((HotSpotResolvedJavaFieldImpl ) field );
814+ }
815+ return null ;
816+ }
817+
784818 static class ErrorCreatingCompiler implements JVMCICompiler {
785819 private final RuntimeException t ;
786820
0 commit comments