diff --git a/.idea/runConfigurations/build_teavm_fast.xml b/.idea/runConfigurations/build_teavm_fast.xml new file mode 100644 index 000000000..ecfe3b594 --- /dev/null +++ b/.idea/runConfigurations/build_teavm_fast.xml @@ -0,0 +1,28 @@ + + + + + + + + \ No newline at end of file diff --git a/metaprogramming/api/src/main/java/org/teavm/metaprogramming/ReflectClass.java b/metaprogramming/api/src/main/java/org/teavm/metaprogramming/ReflectClass.java index 8b624190c..c7bdaae97 100644 --- a/metaprogramming/api/src/main/java/org/teavm/metaprogramming/ReflectClass.java +++ b/metaprogramming/api/src/main/java/org/teavm/metaprogramming/ReflectClass.java @@ -15,7 +15,6 @@ */ package org.teavm.metaprogramming; -import java.util.Arrays; import org.teavm.metaprogramming.reflect.ReflectAnnotatedElement; import org.teavm.metaprogramming.reflect.ReflectField; import org.teavm.metaprogramming.reflect.ReflectMethod; @@ -49,15 +48,9 @@ public interface ReflectClass extends ReflectAnnotatedElement { ReflectClass asSubclass(Class cls); - default boolean isAssignableFrom(ReflectClass cls) { - return cls == this - || cls.getSuperclass() != null && this.isAssignableFrom(cls.getSuperclass()) - || Arrays.stream(cls.getInterfaces()).anyMatch(this::isAssignableFrom); - } + boolean isAssignableFrom(ReflectClass cls); - default boolean isAssignableFrom(Class cls) { - return isAssignableFrom(Metaprogramming.findClass(cls)); - } + boolean isAssignableFrom(Class cls); ReflectMethod[] getDeclaredMethods(); @@ -65,21 +58,11 @@ public interface ReflectClass extends ReflectAnnotatedElement { ReflectMethod getDeclaredMethod(String name, ReflectClass... parameterTypes); - default ReflectMethod getDeclaredJMethod(String name, Class... parameterTypes) { - ReflectClass[] mappedParamTypes = Arrays.stream(parameterTypes) - .map(Metaprogramming::findClass) - .toArray(ReflectClass[]::new); - return getDeclaredMethod(name, mappedParamTypes); - } + ReflectMethod getDeclaredJMethod(String name, Class... parameterTypes); ReflectMethod getMethod(String name, ReflectClass... parameterTypes); - default ReflectMethod getJMethod(String name, Class... parameterTypes) { - ReflectClass[] mappedParamTypes = Arrays.stream(parameterTypes) - .map(Metaprogramming::findClass) - .toArray(ReflectClass[]::new); - return getMethod(name, mappedParamTypes); - } + ReflectMethod getJMethod(String name, Class... parameterTypes); ReflectField[] getDeclaredFields(); diff --git a/metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/reflect/ReflectClassImpl.java b/metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/reflect/ReflectClassImpl.java index dc95e5a65..af79d9e17 100644 --- a/metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/reflect/ReflectClassImpl.java +++ b/metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/reflect/ReflectClassImpl.java @@ -25,6 +25,7 @@ import java.util.Map; import java.util.Objects; import java.util.Set; import org.teavm.metaprogramming.ReflectClass; +import org.teavm.metaprogramming.impl.MetaprogrammingImpl; import org.teavm.metaprogramming.reflect.ReflectField; import org.teavm.metaprogramming.reflect.ReflectMethod; import org.teavm.model.AccessLevel; @@ -197,6 +198,18 @@ public class ReflectClassImpl implements ReflectClass { return (ReflectClass) this; } + @Override + public boolean isAssignableFrom(ReflectClass cls) { + return cls == this + || cls.getSuperclass() != null && this.isAssignableFrom(cls.getSuperclass()) + || Arrays.stream(cls.getInterfaces()).anyMatch(this::isAssignableFrom); + } + + @Override + public boolean isAssignableFrom(Class cls) { + return isAssignableFrom(MetaprogrammingImpl.findClass(cls)); + } + @Override public ReflectMethod[] getDeclaredMethods() { resolve(); @@ -273,6 +286,22 @@ public class ReflectClassImpl implements ReflectClass { }); } + @Override + public ReflectMethod getDeclaredJMethod(String name, Class... parameterTypes) { + ReflectClass[] mappedParamTypes = Arrays.stream(parameterTypes) + .map(MetaprogrammingImpl::findClass) + .toArray(ReflectClass[]::new); + return getDeclaredMethod(name, mappedParamTypes); + } + + @Override + public ReflectMethod getJMethod(String name, Class... parameterTypes) { + ReflectClass[] mappedParamTypes = Arrays.stream(parameterTypes) + .map(MetaprogrammingImpl::findClass) + .toArray(ReflectClass[]::new); + return getMethod(name, mappedParamTypes); + } + @Override public ReflectMethod getMethod(String name, ReflectClass... parameterTypes) { resolve(); diff --git a/tools/core/src/main/java/org/teavm/tooling/TeaVMProblemRenderer.java b/tools/core/src/main/java/org/teavm/tooling/TeaVMProblemRenderer.java index e04669255..8288e45b7 100644 --- a/tools/core/src/main/java/org/teavm/tooling/TeaVMProblemRenderer.java +++ b/tools/core/src/main/java/org/teavm/tooling/TeaVMProblemRenderer.java @@ -59,7 +59,7 @@ public final class TeaVMProblemRenderer { renderCallLocation(location.getMethod(), location.getSourceLocation(), sb); if (location.getMethod() != null) { CallGraphNode node = cg.getNode(location.getMethod()); - while (true) { + for (int i = 0; i < 100; ++i) { Iterator callSites = node.getCallerCallSites().iterator(); if (!callSites.hasNext()) { break;