Mercurial > hg > graal-jvmci-8
diff graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethod.java @ 9984:f3330a4487eb
added ResolvedJava[Field|Method].isSynthetic()
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Tue, 11 Jun 2013 01:17:10 +0200 |
parents | a9311ec68721 |
children | d9c14b1828fc |
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethod.java Tue Jun 11 00:00:40 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethod.java Tue Jun 11 01:17:10 2013 +0200 @@ -332,6 +332,29 @@ } @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); + HotSpotRuntime runtime = graalRuntime().getRuntime(); + for (Method method : holder.mirror().getDeclaredMethods()) { + if (method.getName().equals(name)) { + if (runtime.lookupJavaType(method.getReturnType()).equals(sig.getReturnType(holder))) { + if (matches(runtime, sigTypes, method.getParameterTypes())) { + return method.isSynthetic(); + } + } + } + } + return false; + } + + @Override public Type[] getGenericParameterTypes() { if (isConstructor()) { Constructor javaConstructor = toJavaConstructor(); @@ -351,6 +374,18 @@ return result; } + private static boolean matches(HotSpotRuntime runtime, JavaType[] sigTypes, Class<?>[] parameterTypes) { + if (parameterTypes.length == sigTypes.length) { + for (int i = 0; i < parameterTypes.length; i++) { + if (!runtime.lookupJavaType(parameterTypes[i]).equals(sigTypes[i])) { + return false; + } + } + return true; + } + return false; + } + private Method toJava() { try { return holder.mirror().getDeclaredMethod(name, signatureToTypes());