Mercurial > hg > truffle
changeset 13777:b6cecbcfa503
fixed HotSpotResolvedJavaMethod.isSynthetic so that it doesn't do any class loading (JBS:GRAAL-5)
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Tue, 28 Jan 2014 12:27:39 +0100 |
parents | 8305aec3a1ae |
children | 0be9a42f28e7 |
files | graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethod.java |
diffstat | 1 files changed, 19 insertions(+), 33 deletions(-) [+] |
line wrap: on
line diff
--- 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());