# HG changeset patch # User Doug Simon # Date 1390908459 -3600 # Node ID b6cecbcfa5030edd2e2abd9d19be0321262c14b8 # Parent 8305aec3a1aef2f3cc4c4a5e018c46024bd1bfa8 fixed HotSpotResolvedJavaMethod.isSynthetic so that it doesn't do any class loading (JBS:GRAAL-5) diff -r 8305aec3a1ae -r b6cecbcfa503 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethod.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethod.java Tue Jan 28 12:19:30 2014 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethod.java Tue Jan 28 12:27:39 2014 +0100 @@ -157,10 +157,14 @@ return getMetaspaceMethodConstant(); } + public int getRawModifiers() { + HotSpotVMConfig config = runtime().getConfig(); + return unsafe.getInt(metaspaceMethod + config.methodAccessFlagsOffset); + } + @Override public int getModifiers() { - HotSpotVMConfig config = runtime().getConfig(); - return unsafe.getInt(metaspaceMethod + config.methodAccessFlagsOffset) & Modifier.methodModifiers(); + return getRawModifiers() & Modifier.methodModifiers(); } @Override @@ -424,27 +428,21 @@ return javaMethod == null ? null : javaMethod.getAnnotation(annotationClass); } + private static final int SYNTHETIC; + static { + try { + Field field = Modifier.class.getDeclaredField("SYNTHETIC"); + field.setAccessible(true); + SYNTHETIC = field.getInt(null); + } catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException | SecurityException e) { + throw GraalInternalError.shouldNotReachHere(e.toString()); + } + } + @Override public boolean isSynthetic() { - if (isConstructor()) { - Constructor javaConstructor = toJavaConstructor(); - return javaConstructor == null ? false : javaConstructor.isSynthetic(); - } - - // Cannot use toJava() as it ignores the return type - HotSpotSignature sig = getSignature(); - JavaType[] sigTypes = MetaUtil.signatureToTypes(sig, null); - MetaAccessProvider metaAccess = runtime().getHostProviders().getMetaAccess(); - for (Method method : holder.mirror().getDeclaredMethods()) { - if (method.getName().equals(name)) { - if (metaAccess.lookupJavaType(method.getReturnType()).equals(sig.getReturnType(holder))) { - if (matches(metaAccess, sigTypes, method.getParameterTypes())) { - return method.isSynthetic(); - } - } - } - } - return false; + int modifiers = getRawModifiers(); + return (SYNTHETIC & modifiers) != 0; } public boolean isDefault() { @@ -476,18 +474,6 @@ return result; } - private static boolean matches(MetaAccessProvider metaAccess, JavaType[] sigTypes, Class[] parameterTypes) { - if (parameterTypes.length == sigTypes.length) { - for (int i = 0; i < parameterTypes.length; i++) { - if (!metaAccess.lookupJavaType(parameterTypes[i]).equals(sigTypes[i])) { - return false; - } - } - return true; - } - return false; - } - private Method toJava() { try { return holder.mirror().getDeclaredMethod(name, signatureToTypes());