mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 08:14:09 -08:00
Fix bugs in metaprogramming. Add run configuration that rebuilds TeaVM
This commit is contained in:
parent
751587bddc
commit
5e44c13caf
28
.idea/runConfigurations/build_teavm_fast.xml
Normal file
28
.idea/runConfigurations/build_teavm_fast.xml
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
<component name="ProjectRunConfigurationManager">
|
||||||
|
<configuration default="false" name="build-teavm-fast" type="MavenRunConfiguration" factoryName="Maven">
|
||||||
|
<MavenSettings>
|
||||||
|
<option name="myGeneralSettings" />
|
||||||
|
<option name="myRunnerSettings" />
|
||||||
|
<option name="myRunnerParameters">
|
||||||
|
<MavenRunnerParameters>
|
||||||
|
<option name="profiles">
|
||||||
|
<set />
|
||||||
|
</option>
|
||||||
|
<option name="goals">
|
||||||
|
<list>
|
||||||
|
<option value="install" />
|
||||||
|
<option value="-DskipTests" />
|
||||||
|
<option value="-Dteavm.build.all=false" />
|
||||||
|
</list>
|
||||||
|
</option>
|
||||||
|
<option name="profilesMap">
|
||||||
|
<map />
|
||||||
|
</option>
|
||||||
|
<option name="resolveToWorkspace" value="false" />
|
||||||
|
<option name="workingDirPath" value="$PROJECT_DIR$" />
|
||||||
|
</MavenRunnerParameters>
|
||||||
|
</option>
|
||||||
|
</MavenSettings>
|
||||||
|
<method />
|
||||||
|
</configuration>
|
||||||
|
</component>
|
|
@ -15,7 +15,6 @@
|
||||||
*/
|
*/
|
||||||
package org.teavm.metaprogramming;
|
package org.teavm.metaprogramming;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import org.teavm.metaprogramming.reflect.ReflectAnnotatedElement;
|
import org.teavm.metaprogramming.reflect.ReflectAnnotatedElement;
|
||||||
import org.teavm.metaprogramming.reflect.ReflectField;
|
import org.teavm.metaprogramming.reflect.ReflectField;
|
||||||
import org.teavm.metaprogramming.reflect.ReflectMethod;
|
import org.teavm.metaprogramming.reflect.ReflectMethod;
|
||||||
|
@ -49,15 +48,9 @@ public interface ReflectClass<T> extends ReflectAnnotatedElement {
|
||||||
|
|
||||||
<U> ReflectClass<U> asSubclass(Class<U> cls);
|
<U> ReflectClass<U> asSubclass(Class<U> cls);
|
||||||
|
|
||||||
default boolean isAssignableFrom(ReflectClass<?> cls) {
|
boolean isAssignableFrom(ReflectClass<?> cls);
|
||||||
return cls == this
|
|
||||||
|| cls.getSuperclass() != null && this.isAssignableFrom(cls.getSuperclass())
|
|
||||||
|| Arrays.stream(cls.getInterfaces()).anyMatch(this::isAssignableFrom);
|
|
||||||
}
|
|
||||||
|
|
||||||
default boolean isAssignableFrom(Class<?> cls) {
|
boolean isAssignableFrom(Class<?> cls);
|
||||||
return isAssignableFrom(Metaprogramming.findClass(cls));
|
|
||||||
}
|
|
||||||
|
|
||||||
ReflectMethod[] getDeclaredMethods();
|
ReflectMethod[] getDeclaredMethods();
|
||||||
|
|
||||||
|
@ -65,21 +58,11 @@ public interface ReflectClass<T> extends ReflectAnnotatedElement {
|
||||||
|
|
||||||
ReflectMethod getDeclaredMethod(String name, ReflectClass<?>... parameterTypes);
|
ReflectMethod getDeclaredMethod(String name, ReflectClass<?>... parameterTypes);
|
||||||
|
|
||||||
default ReflectMethod getDeclaredJMethod(String name, Class<?>... parameterTypes) {
|
ReflectMethod getDeclaredJMethod(String name, Class<?>... parameterTypes);
|
||||||
ReflectClass<?>[] mappedParamTypes = Arrays.stream(parameterTypes)
|
|
||||||
.map(Metaprogramming::findClass)
|
|
||||||
.toArray(ReflectClass[]::new);
|
|
||||||
return getDeclaredMethod(name, mappedParamTypes);
|
|
||||||
}
|
|
||||||
|
|
||||||
ReflectMethod getMethod(String name, ReflectClass<?>... parameterTypes);
|
ReflectMethod getMethod(String name, ReflectClass<?>... parameterTypes);
|
||||||
|
|
||||||
default ReflectMethod getJMethod(String name, Class<?>... parameterTypes) {
|
ReflectMethod getJMethod(String name, Class<?>... parameterTypes);
|
||||||
ReflectClass<?>[] mappedParamTypes = Arrays.stream(parameterTypes)
|
|
||||||
.map(Metaprogramming::findClass)
|
|
||||||
.toArray(ReflectClass[]::new);
|
|
||||||
return getMethod(name, mappedParamTypes);
|
|
||||||
}
|
|
||||||
|
|
||||||
ReflectField[] getDeclaredFields();
|
ReflectField[] getDeclaredFields();
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@ import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import org.teavm.metaprogramming.ReflectClass;
|
import org.teavm.metaprogramming.ReflectClass;
|
||||||
|
import org.teavm.metaprogramming.impl.MetaprogrammingImpl;
|
||||||
import org.teavm.metaprogramming.reflect.ReflectField;
|
import org.teavm.metaprogramming.reflect.ReflectField;
|
||||||
import org.teavm.metaprogramming.reflect.ReflectMethod;
|
import org.teavm.metaprogramming.reflect.ReflectMethod;
|
||||||
import org.teavm.model.AccessLevel;
|
import org.teavm.model.AccessLevel;
|
||||||
|
@ -197,6 +198,18 @@ public class ReflectClassImpl<T> implements ReflectClass<T> {
|
||||||
return (ReflectClass<U>) this;
|
return (ReflectClass<U>) 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
|
@Override
|
||||||
public ReflectMethod[] getDeclaredMethods() {
|
public ReflectMethod[] getDeclaredMethods() {
|
||||||
resolve();
|
resolve();
|
||||||
|
@ -273,6 +286,22 @@ public class ReflectClassImpl<T> implements ReflectClass<T> {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@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
|
@Override
|
||||||
public ReflectMethod getMethod(String name, ReflectClass<?>... parameterTypes) {
|
public ReflectMethod getMethod(String name, ReflectClass<?>... parameterTypes) {
|
||||||
resolve();
|
resolve();
|
||||||
|
|
|
@ -59,7 +59,7 @@ public final class TeaVMProblemRenderer {
|
||||||
renderCallLocation(location.getMethod(), location.getSourceLocation(), sb);
|
renderCallLocation(location.getMethod(), location.getSourceLocation(), sb);
|
||||||
if (location.getMethod() != null) {
|
if (location.getMethod() != null) {
|
||||||
CallGraphNode node = cg.getNode(location.getMethod());
|
CallGraphNode node = cg.getNode(location.getMethod());
|
||||||
while (true) {
|
for (int i = 0; i < 100; ++i) {
|
||||||
Iterator<? extends CallSite> callSites = node.getCallerCallSites().iterator();
|
Iterator<? extends CallSite> callSites = node.getCallerCallSites().iterator();
|
||||||
if (!callSites.hasNext()) {
|
if (!callSites.hasNext()) {
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user