Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.m2m.atl.emftvm/src/org/eclipse/m2m/atl/emftvm/jit/ByteCodeSwitch.java')
-rw-r--r--plugins/org.eclipse.m2m.atl.emftvm/src/org/eclipse/m2m/atl/emftvm/jit/ByteCodeSwitch.java70
1 files changed, 8 insertions, 62 deletions
diff --git a/plugins/org.eclipse.m2m.atl.emftvm/src/org/eclipse/m2m/atl/emftvm/jit/ByteCodeSwitch.java b/plugins/org.eclipse.m2m.atl.emftvm/src/org/eclipse/m2m/atl/emftvm/jit/ByteCodeSwitch.java
index 1ad77166..a8ca44a2 100644
--- a/plugins/org.eclipse.m2m.atl.emftvm/src/org/eclipse/m2m/atl/emftvm/jit/ByteCodeSwitch.java
+++ b/plugins/org.eclipse.m2m.atl.emftvm/src/org/eclipse/m2m/atl/emftvm/jit/ByteCodeSwitch.java
@@ -11,13 +11,11 @@
package org.eclipse.m2m.atl.emftvm.jit;
import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
-import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
@@ -664,7 +662,7 @@ public class ByteCodeSwitch extends EmftvmSwitch<MethodVisitor> implements Opcod
localVariable("body", CodeBlock.class, bodyStart, ifOpNull, bodyIdx);
}
// Generate native method invocation code here
- final Method method = findRootMethod(object.getNativeMethod());
+ final Method method = EMFTVMUtil.findRootMethod(object.getNativeMethod());
if (method != null) { // native method recorded - try first
// Labels
final Label subframeStart = new Label();
@@ -711,7 +709,8 @@ public class ByteCodeSwitch extends EmftvmSwitch<MethodVisitor> implements Opcod
mv.visitMethodInsn(opcode, // self.<method>(): [..., ?]
Type.getInternalName(dc),
method.getName(),
- Type.getMethodDescriptor(method));
+ Type.getMethodDescriptor(method),
+ dc.isInterface());
// Check if method returned anything
final Class<?> rt = method.getReturnType();
// Box primitive return values
@@ -849,7 +848,7 @@ public class ByteCodeSwitch extends EmftvmSwitch<MethodVisitor> implements Opcod
localVariable("body", CodeBlock.class, bodyStart, ifOpNull, bodyIdx);
}
// Generate native method invocation code here
- final Method method = findRootMethod(object.getNativeMethod());
+ final Method method = EMFTVMUtil.findRootMethod(object.getNativeMethod());
if (method != null) { // native method recorded - try first
// Labels
final Label subframeStart = new Label();
@@ -915,7 +914,8 @@ public class ByteCodeSwitch extends EmftvmSwitch<MethodVisitor> implements Opcod
mv.visitMethodInsn(opcode, // self.<method>(arg): [..., ?]
Type.getInternalName(dc),
method.getName(),
- Type.getMethodDescriptor(method));
+ Type.getMethodDescriptor(method),
+ dc.isInterface());
// Check if method returned anything
final Class<?> rt = method.getReturnType();
// Box primitive return values
@@ -1085,61 +1085,6 @@ public class ByteCodeSwitch extends EmftvmSwitch<MethodVisitor> implements Opcod
}
/**
- * Finds the root {@link Class} in which <code>method</code> was declared.
- * @param method the method for which to find the root {@link Class}
- * @return the root {@link Class} in which <code>method</code> was declared
- */
- private Method findRootMethod(Method method) {
- if (method == null) {
- return null;
- }
- final int methodModifiers = getRelevantModifiers(method);
- Class<?> dc = method.getDeclaringClass();
- java.util.Set<Class<?>> dis = new LinkedHashSet<Class<?>>(
- Arrays.asList(dc.getInterfaces()));
- while ((dc = dc.getSuperclass()) != null) {
- try {
- Method superMethod = dc.getDeclaredMethod(method.getName(), method.getParameterTypes());
- if (getRelevantModifiers(superMethod) == methodModifiers) {
- method = superMethod;
- } else {
- break;
- }
- } catch (SecurityException e) {
- } catch (NoSuchMethodException e) {
- }
- dis.addAll(Arrays.asList(dc.getInterfaces()));
- }
- while (!dis.isEmpty()) {
- java.util.Set<Class<?>> newDis = new LinkedHashSet<Class<?>>();
- for (Class<?> di : dis) {
- try {
- // Only replace by method declared in a super-interface
- if (di.isAssignableFrom(method.getDeclaringClass())) {
- method = di.getDeclaredMethod(method.getName(), method.getParameterTypes());
- }
- } catch (SecurityException e) {
- } catch (NoSuchMethodException e) {
- }
- newDis.addAll(Arrays.asList(di.getInterfaces()));
- }
- newDis.removeAll(dis);
- dis = newDis;
- }
- return method;
- }
-
- /**
- * Returns the relevant modifiers (visibility and static) for the given method.
- * @param method the method for which to return the modifiers
- * @return the relevant modifiers (visibility and static) for the given method
- */
- private int getRelevantModifiers(final Method method) {
- final int methodModifiers = method.getModifiers();
- return methodModifiers & (Modifier.PRIVATE + Modifier.PROTECTED + Modifier.PUBLIC + Modifier.STATIC);
- }
-
- /**
* {@inheritDoc}
*/
@Override
@@ -2336,7 +2281,8 @@ public class ByteCodeSwitch extends EmftvmSwitch<MethodVisitor> implements Opcod
name,
Type.getMethodDescriptor(
retType instanceof Type ? (Type)retType : Type.getType((Class<?>)retType),
- ats));
+ ats),
+ owner.isInterface());
}
protected void invokeIface(final Class<?> owner, final String name,

Back to the top