import java.io.InputStream;
import java.io.Serializable;
import java.lang.annotation.Annotation;
-import java.lang.reflect.AnnotatedElement;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Field;
-import java.lang.reflect.GenericDeclaration;
-import java.lang.reflect.Method;
-import java.lang.reflect.Type;
-import java.lang.reflect.TypeVariable;
+import java.lang.reflect.*;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import sun.reflect.ConstantPool;
import sun.reflect.annotation.AnnotationType;
+// TODO: DIRTY HACKS!
+import sun.reflect.generics.factory.CoreReflectionFactory;
+import sun.reflect.generics.factory.GenericsFactory;
+import sun.reflect.generics.repository.ClassRepository;
+import sun.reflect.generics.scope.ClassScope;
/**
* MJI model class for java.lang.Class library abstraction
native AnnotationType getAnnotationType();
+ // TODO: DIRTY HACKS!
+ //public native TypeVariable<Class<T>>[] getTypeParameters();
+ /*
@Override
public TypeVariable<Class<T>>[] getTypeParameters() {
throw new UnsupportedOperationException();
}
+ // Generic info repository; lazily initialized
+ private volatile transient ClassRepository genericInfo;
+
+ // Generic signature handling
+ //private native String getGenericSignature0();
+
+ // accessor for factory
+ private GenericsFactory getFactory() {
+ // create scope and factory
+ return CoreReflectionFactory.make(this, ClassScope.make(this));
+ }
+
+ // accessor for generic info repository;
+ // generic info is lazily initialized
+ private ClassRepository getGenericInfo() {
+ ClassRepository genericInfo = this.genericInfo;
+ if (genericInfo == null) {
+ //String signature = getGenericSignature0();
+ //String signature = "Ljava/lang/Object;";
+ String signature = null;
+ if (signature == null) {
+ genericInfo = ClassRepository.NONE;
+ } else {
+ genericInfo = ClassRepository.make(signature, getFactory());
+ }
+ this.genericInfo = genericInfo;
+ }
+ return (genericInfo != ClassRepository.NONE) ? genericInfo : null;
+ }
+
+ @Override
+ public TypeVariable<Class<T>>[] getTypeParameters() {
+ //throw new UnsupportedOperationException();
+ ClassRepository info = getGenericInfo();
+ if (info != null)
+ return (TypeVariable<Class<T>>[])info.getTypeParameters();
+ else
+ return (TypeVariable<Class<T>>[])new TypeVariable<?>[0];
+ }*/
+ @Override
+ public TypeVariable<Class<T>>[] getTypeParameters() {
+ //throw new UnsupportedOperationException();
+ System.out.println("Calling getTypeParameters for: " + this.name);
+ TypeVariable[] typeVariables = (TypeVariable<Class<T>>[])new TypeVariable<?>[1];
+ //Object obj = new Object();
+ //typeVariables[0] = (TypeVariable<Class<T>>) obj;
+ return typeVariables;
+ }
+ // TODO: DIRTY HACKS!
+
public Type getGenericSuperclass() {
throw new UnsupportedOperationException();
}