Skip to content
Snippets Groups Projects
Commit 53e5770b authored by Léa Рая DÉCORNOD's avatar Léa Рая DÉCORNOD
Browse files

add missing Reflection support from 2020 tag

parent 074493d6
Branches
No related merge requests found
package org.teavm.classlib.support;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import java.util.TreeSet;
import org.teavm.classlib.ReflectionContext;
import org.teavm.classlib.ReflectionSupplier;
import org.teavm.model.ClassReader;
import org.teavm.model.MethodDescriptor;
import org.teavm.model.MethodReader;
public class ReflectionSupplierImpl implements ReflectionSupplier {
@Override
public Collection<String> getAccessibleFields(ReflectionContext context, String className) {
return Collections.emptyList();
}
private static Set<String> REFLECTABLE = new TreeSet() {{
add("Temperature3::setTemperature");
add("EauChaude6::getEtatφ");
add("generique.AimeLesChats::getAnimalDeCompagnie");
}};
@Override
public Collection<MethodDescriptor> getAccessibleMethods(ReflectionContext context, String className) {
if (className.contains(".")
&& !className.startsWith("generique."))
return Collections.emptyList();
ClassReader cls = context.getClassSource().get(className);
if (cls == null)
return Collections.emptyList();
Set<MethodDescriptor> methods = new HashSet<>();
for (MethodReader method : cls.getMethods())
if (REFLECTABLE.contains(className+"::"+method.getName()))
methods.add(method.getDescriptor());
return methods;
}
}
\ No newline at end of file
org.teavm.classlib.support.ReflectionSupplierImpl
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment