You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've run into an issue I haven't been able to work through with reflection. It occurs when a reflected class implements any interface. The error that's produced is something like this:
Uncaught TypeError: b is undefined
If I remove the interface from the class the error doesn't occur. The error is triggered on Class.getMethods(). I found that I can call Class.getName() without exception, it appears to only be on getMethods().
Class<?> aclass = ...
aclass.getMethods()
Here is my ReflectionSupplierImpl:
public class ReflectionSupplierImpl implements ReflectionSupplier {
@Override
public Collection<String> getAccessibleFields(ReflectionContext context, String className) {
var cls = context.getClassSource().get(className);
console.get().info("ReflectionSupplierImpl.getAccessibleFields(): " + className);
var fields = new HashSet<String>();
for (var field : cls.getFields()) {
if (field.getAnnotations().get(Reflectable.class.getName()) != null) {
fields.add(field.getName());
}
}
return fields;
}
@Override
public Collection<MethodDescriptor> getAccessibleMethods(ReflectionContext context, String className) {
var cls = context.getClassSource().get(className);
console.get().info("ReflectionSupplierImpl.getAccessibleMethods(): " + className);
var methods = new HashSet<MethodDescriptor>();
for (var method : cls.getMethods()) {
if (method.getAnnotations().get(Reflectable.class.getName()) != null) {
methods.add(method.getDescriptor());
}
}
return methods;
}
}
Thanks for your assistance.
The text was updated successfully, but these errors were encountered:
I've run into an issue I haven't been able to work through with reflection. It occurs when a reflected class implements any interface. The error that's produced is something like this:
If I remove the interface from the class the error doesn't occur. The error is triggered on Class.getMethods(). I found that I can call Class.getName() without exception, it appears to only be on getMethods().
Here is my ReflectionSupplierImpl:
Thanks for your assistance.
The text was updated successfully, but these errors were encountered: