Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ JavaConstant boxPrimitive(JavaConstant source) {
* Gets a {@link Method} object corresponding to {@code method}. This method guarantees the same
* {@link Method} object is returned if called twice on the same {@code method} value.
*/
private static Executable getMethod(HotSpotResolvedJavaMethodImpl method) {
static Executable getMethod(HotSpotResolvedJavaMethodImpl method) {
assert !method.isClassInitializer() : method;
if (method.toJavaCache == null) {
synchronized (method) {
Expand All @@ -303,7 +303,7 @@ private static Executable getMethod(HotSpotResolvedJavaMethodImpl method) {
* {@code f} and annotation class {@code a}, the same object is returned for each call to
* {@code f.getAnnotation(a)}).
*/
private static Field getField(HotSpotResolvedJavaFieldImpl field) {
static Field getField(HotSpotResolvedJavaFieldImpl field) {
HotSpotResolvedObjectTypeImpl declaringClass = field.getDeclaringClass();
synchronized (declaringClass) {
HashMap<HotSpotResolvedJavaFieldImpl, Field> cache = declaringClass.reflectionFieldCache;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
import java.lang.invoke.ConstantCallSite;
import java.lang.invoke.MethodHandle;
import java.lang.ref.WeakReference;
import java.lang.reflect.Executable;
import java.lang.reflect.Field;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.ArrayList;
Expand All @@ -60,6 +62,8 @@
import jdk.vm.ci.common.NativeImageReinitialize;
import jdk.vm.ci.meta.JavaKind;
import jdk.vm.ci.meta.JavaType;
import jdk.vm.ci.meta.ResolvedJavaField;
import jdk.vm.ci.meta.ResolvedJavaMethod;
import jdk.vm.ci.meta.ResolvedJavaType;
import jdk.vm.ci.meta.UnresolvedJavaType;
import jdk.vm.ci.runtime.JVMCI;
Expand Down Expand Up @@ -767,7 +771,7 @@ public boolean test(ResolvedJavaType type) {
}

/**
* Get the {@link Class} corresponding to {@code type}.
* Gets the {@link Class} corresponding to {@code type}.
*
* @param type the type for which a {@link Class} is requested
* @return the original Java class corresponding to {@code type} or {@code null} if this runtime
Expand All @@ -781,6 +785,36 @@ public Class<?> getMirror(ResolvedJavaType type) {
return null;
}

/**
* Gets the {@link Executable} corresponding to {@code method}.
*
* @param method the method for which an {@link Executable} is requested
* @return the original Java method or constructor corresponding to {@code method} or
* {@code null} if this runtime does not support mapping {@link ResolvedJavaMethod}
* instances to {@link Executable} instances
*/
public Executable getMirror(ResolvedJavaMethod method) {
if (method instanceof HotSpotResolvedJavaMethodImpl && reflection instanceof HotSpotJDKReflection) {
return HotSpotJDKReflection.getMethod((HotSpotResolvedJavaMethodImpl) method);
}
return null;
}

/**
* Gets the {@link Field} corresponding to {@code field}.
*
* @param field the field for which a {@link Field} is requested
* @return the original Java field corresponding to {@code field} or {@code null} if this
* runtime does not support mapping {@link ResolvedJavaField} instances to {@link Field}
* instances
*/
public Field getMirror(ResolvedJavaField field) {
if (field instanceof HotSpotResolvedJavaFieldImpl && reflection instanceof HotSpotJDKReflection) {
return HotSpotJDKReflection.getField((HotSpotResolvedJavaFieldImpl) field);
}
return null;
}

static class ErrorCreatingCompiler implements JVMCICompiler {
private final RuntimeException t;

Expand Down