TypeInfo.getClassObject(), for now implemented via reflection
This commit is contained in:
@@ -2,6 +2,7 @@ package jet.typeinfo;
|
||||
|
||||
import jet.JetObject;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
@@ -26,6 +27,17 @@ public class TypeInfo<T> implements JetObject {
|
||||
this.typeParameters = typeParameters;
|
||||
}
|
||||
|
||||
public Object getClassObject() {
|
||||
try {
|
||||
final Class implClass = theClass.getClassLoader().loadClass(theClass.getCanonicalName() + "$$Impl");
|
||||
final Field classobj = implClass.getField("$classobj");
|
||||
return classobj.get(null);
|
||||
}
|
||||
catch(Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isInstance(Object obj) {
|
||||
if (obj instanceof JetObject) {
|
||||
return isSubtypeOf(((JetObject) obj).getTypeInfo());
|
||||
|
||||
Reference in New Issue
Block a user