# JIRA plugin
atlassian-ide-plugin.xml
+/build-default/
--- /dev/null
+import java.util.List;
+import java.util.ArrayList;
+
+public class Generic<T,E> {
+
+ private T t;
+
+ public T returnT(List<String> test) {
+ return this.t;
+ }
+
+ public List<String> returnL(List<String> test) {
+ return test;
+ }
+
+ public static void main(String[] args) {
+
+ Generic gen = new Generic();
+ List<String> list = new ArrayList<>();
+ List<String> ret = gen.returnL(list);
+ }
+}
--- /dev/null
+import java.lang.reflect.Method;
+import java.lang.reflect.Type;
+import java.lang.reflect.TypeVariable;
+
+import java.util.List;
+import java.util.ArrayList;
+
+public class Reflection {
+
+ class Generic<T,E> {
+
+ }
+
+ class SampleClass {
+ private String sampleField;
+
+ public String getSampleField() {
+ return sampleField;
+ }
+
+ /*public List<String> setSampleField(List<String> listString,
+ String sampleField, int one, short two, double three, Object obj) {
+ this.sampleField = sampleField;
+ return listString;
+ }
+
+ public void setSampleField(String sampleField) {
+ this.sampleField = sampleField;
+ }*/
+
+ public List<String> setSampleField(List<String> listString) {
+ return listString;
+ }
+ }
+
+ public static void main(String[] args) {
+
+ Method[] methods = SampleClass.class.getMethods();
+ /*Type[] parameters = methods[1].getGenericParameterTypes();
+ for (int i = 0; i < parameters.length; i++) {
+ System.out.println(parameters[i]);
+ }
+ System.out.println();*/
+ Class[] parameterTypes = methods[6].getParameterTypes();
+ for(Class parameterType: parameterTypes){
+ System.out.println(parameterType.getName());
+
+ }
+ System.out.println();
+ TypeVariable[] typeParameters = Generic.class.getTypeParameters();
+ for(TypeVariable typeVar: typeParameters){
+ System.out.println(typeVar);
+
+ }
+ /*System.out.println();
+ Type returnType = methods[1].getGenericReturnType();
+ System.out.println(returnType);*/
+ }
+}
+
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!
-
+ // TODO: Fix for Groovy's model-checking
+ public native TypeVariable<Class<T>>[] getTypeParameters();
+
public Type getGenericSuperclass() {
throw new UnsupportedOperationException();
}
public native Class<?>[] getParameterTypes();
public native Type[] getGenericParameterTypes();
public native Class<?>[] getExceptionTypes();
- // TODO: DIRTY HACKS
+ // TODO: Fix for Groovy's model-checking
public native Type getGenericReturnType();
@Override
@Override
protected ClassInfo loadSystemClass (String typeName){
- System.out.println("Loading class: " + typeName);
return new ClassInfo( typeName, this);
}
import gov.nasa.jpf.Config;
import gov.nasa.jpf.annotation.MJI;
-// TODO: DIRTY HACKS!
-import java.lang.reflect.TypeVariable;
-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 NativePeer class for java.lang.Class library abstraction
*/
static final String FIELD_CLASSNAME = "java.lang.reflect.Field";
static final String METHOD_CLASSNAME = "java.lang.reflect.Method";
static final String CONSTRUCTOR_CLASSNAME = "java.lang.reflect.Constructor";
- // TODO: DIRTY HACKS!
+ // TODO: Fix for Groovy's model-checking
static final String TYPEVARIABLE_CLASSNAME = "java.lang.reflect.TypeVariable";
public static boolean init (Config conf){
return ci.getClassObjectRef();
}
- // TODO: DIRTY HACKS!
- /*int createTypeVariableObject (MJIEnv env, ClassInfo objectCi, MethodInfo mi) {
- // NOTE - we rely on Constructor and Method peers being initialized
- if (mi.isCtor()){
- return JPF_java_lang_reflect_Constructor.createConstructorObject(env, objectCi, mi);
- } else {
- return JPF_java_lang_reflect_Method.createMethodObject(env, objectCi, mi);
- }
- }
-
- // accessor for factory
- private GenericsFactory getFactory() {
- // create scope and factory
- return CoreReflectionFactory.make(this, ClassScope.make(this));
- }
-
- @MJI
- public int getTypeParameters_____3Ljava_lang_reflect_TypeVariable_2 (MJIEnv env, int objRef){
- ClassInfo tci = getInitializedClassInfo(env, TYPEVARIABLE_CLASSNAME);
- if (tci == null) {
- env.repeatInvocation();
- return MJIEnv.NULL;
- }
- // Get the object and the type parameters
- ClassInfo ci = env.getReferredClassInfo(objRef);
- String signature = ci.getType();
- ClassRepository genericInfo = ClassRepository.make(signature, getFactory());
- TypeVariable[] typeVariables = (TypeVariable[]) genericInfo.getTypeParameters();
-
- int aref = env.newObjectArray("Ljava/lang/reflect/TypeVariable;", typeVariables.length);
-
- for(int i=0, j=0; i<typeVariables.length; i++){
- if (typeVariables[i] != null) {
- int mref = env.newObject(ci);
- env.setReferenceArrayElement(aref,j++,mref);
- }
- }
-
- return aref;
- }*/
- // TODO: DIRTY HACKS!
-
@MJI
public boolean desiredAssertionStatus____Z (MJIEnv env, int robj) {
ClassInfo ci = env.getReferredClassInfo(robj);
return getParameterTypes(env, getMethodInfo(env, objRef));
}
- // TODO: DIRTY HACKS
+ // TODO: Fix for Groovy's model-checking
@MJI
public int getGenericParameterTypes_____3Ljava_lang_reflect_Type_2 (MJIEnv env, int objRef){
//return getGenericParameterTypes(env, getMethodInfo(env, objRef));
public int getGenericReturnType____Ljava_lang_reflect_Type_2 (MJIEnv env, int objRef){
return getReturnType____Ljava_lang_Class_2(env, objRef);
}
- // TODO: DIRTY HACKS
+ // TODO: Fix for Groovy's model-checking
int getExceptionTypes(MJIEnv env, MethodInfo mi) {
ThreadInfo ti = env.getThreadInfo();