Richtiger Import von Generischen Typen aus der JRE

This commit is contained in:
JanUlrich 2014-10-07 15:36:18 +02:00
parent 3db9b069c7
commit 81416b8bf4
16 changed files with 58 additions and 31 deletions

View File

@ -162,6 +162,26 @@ public class Class extends SyntaxTreeNode implements AClassOrInterface, IItemWit
}
// ino.end
/**
* Erstellt eine Klasse, welche nur für die Assumptions verwendet wird.
* Sie enthält keine unnötigen Informationen, wie Offset oder ClassBody.
* @param name
* @param superClass
* @param modifiers
* @param supertypeGenPara - Eine Liste von Namen, welche die Generischen Parameter der Klasse darstellen.
*/
public Class(String name, RefType superClass, Modifiers modifiers,
Vector<String> supertypeGenPara) {
this(name,superClass,modifiers,0);
if(supertypeGenPara == null)return;
Vector<GenericTypeVar> gtvs = new Vector<>();
for(String gname : supertypeGenPara){
GenericTypeVar newGTV=new GenericTypeVar(gname,this,0);
gtvs.add(newGTV);
}
this.genericClassParameters = new GenericDeclarationList(gtvs,0);
}
public Class(String name, RefType superClass, Modifiers mod, int offset){
this(name,mod,offset);
this.superClass = superClass;
@ -244,6 +264,7 @@ public class Class extends SyntaxTreeNode implements AClassOrInterface, IItemWit
}
// ino.end
public Vector<Field> getFields()
{
return fielddecl;

View File

@ -1179,7 +1179,7 @@ public class SourceFile
GenericTypeVar newGTV=new GenericTypeVar(superclassTVS[tvi].getName(),parentClass,-1);
supertypeGenPara.addElement(newGTV);
}
if(supertypeGenPara.size()==0){
supertypeGenPara=null;
}
@ -1267,9 +1267,17 @@ public class SourceFile
if(s == null){
return new Class("java.lang.Object",new Modifiers(), 0);
}
Vector<String> supertypeGenPara = new Vector<>();//Die Generischen Parameter für die Superklasse berechnen:
java.lang.reflect.TypeVariable[] superclassTVS=s.getTypeParameters();
for(int tvi=0;tvi<superclassTVS.length;tvi++){
supertypeGenPara.addElement(superclassTVS[tvi].getName());
}
Class ss = this.getSuperClassOfJREClass(s, ass);
ret = new Class(s.getName(),ss.getType(),new Modifiers(),0);
ret = new Class(s.getName(),ss.getType(),new Modifiers(),supertypeGenPara);
ass.addClassAssumption(new ClassAssumption(ss)); //Die beiden SuperKlassen den Assumptions anfügen...
ass.addClassAssumption(new ClassAssumption(ret));
@ -1311,18 +1319,21 @@ public class SourceFile
return(new GenericTypeVar(jreSpiderRegistry.get(tvi.getName()).getName().toString(),parentClass,-1));
}else{
*/
//String jccNameForClass=baseTypeTranslationTable.get(cl.getSimpleName());
String jccNameForClass=baseTypeTranslationTable.get(cl.getName());
if(cl.getSimpleName().equalsIgnoreCase("void")){
return(new Void(parentClass,-1));
}else if(jccNameForClass!=null){
RefType rt=new RefType(jccNameForClass,parentClass,-1);
rt.setPrimitiveFlag(true);
return(rt);
}else{
//return(new RefType(cl.getSimpleName()));
return(new RefType(cl.getName(),parentClass,-1));
}
GenericTypeVar gtv = jreSpiderRegistry.get(type.getTypeName());
if(gtv != null)return gtv;
//new GenericTypeVar(jreSpiderRegistry.get(type.getTypeName()).getName().toString(),parentClass,-1));
//String jccNameForClass=baseTypeTranslationTable.get(cl.getSimpleName());
String jccNameForClass=baseTypeTranslationTable.get(cl.getName());
if(cl.getSimpleName().equalsIgnoreCase("void")){
return(new Void(parentClass,-1));
}else if(jccNameForClass!=null){
RefType rt=new RefType(jccNameForClass,parentClass,-1);
rt.setPrimitiveFlag(true);
return(rt);
}else{
//return(new RefType(cl.getSimpleName()));
return(new RefType(cl.getName(),parentClass,-1));
}
//}
}
// ino.end

View File

@ -37,7 +37,6 @@ import de.dhbwstuttgart.typeinference.SingleConstraint;
import de.dhbwstuttgart.typeinference.UndConstraint;
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
import de.dhbwstuttgart.typeinference.unify.CSubstitutionSet;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;

View File

@ -27,9 +27,9 @@ import de.dhbwstuttgart.typeinference.JavaCodeResult;
import de.dhbwstuttgart.typeinference.ResultSet;
import de.dhbwstuttgart.typeinference.SingleConstraint;
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
import de.dhbwstuttgart.typeinference.exceptions.NotImplementedException;
import de.dhbwstuttgart.typeinference.exceptions.TypeinferenceException;
import de.dhbwstuttgart.typeinference.unify.CSubstitutionSet;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;

View File

@ -26,8 +26,6 @@ import de.dhbwstuttgart.typeinference.JavaCodeResult;
import de.dhbwstuttgart.typeinference.ResultSet;
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
import de.dhbwstuttgart.typeinference.unify.CSubstitutionSet;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
// ino.end

View File

@ -5,8 +5,8 @@ package de.dhbwstuttgart.syntaxtree.statement;
import java.util.Hashtable;
import java.util.Vector;
import org.apache.log4j.Logger;
import de.dhbwstuttgart.bytecode.ClassFile;
import de.dhbwstuttgart.bytecode.CodeAttribute;
import de.dhbwstuttgart.myexception.CTypeReconstructionException;
@ -19,8 +19,8 @@ import de.dhbwstuttgart.typeinference.ConstraintsSet;
import de.dhbwstuttgart.typeinference.JavaCodeResult;
import de.dhbwstuttgart.typeinference.ResultSet;
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
import de.dhbwstuttgart.typeinference.exceptions.NotImplementedException;
import de.dhbwstuttgart.typeinference.unify.CSubstitutionSet;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;

View File

@ -14,7 +14,7 @@ import de.dhbwstuttgart.syntaxtree.type.Type;
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
import de.dhbwstuttgart.typeinference.ConstraintsSet;
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
import de.dhbwstuttgart.typeinference.exceptions.NotImplementedException;

View File

@ -27,9 +27,8 @@ import de.dhbwstuttgart.typeinference.JavaCodeResult;
import de.dhbwstuttgart.typeinference.Pair;
import de.dhbwstuttgart.typeinference.ResultSet;
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
import de.dhbwstuttgart.typeinference.exceptions.NotImplementedException;
import de.dhbwstuttgart.typeinference.unify.Unify;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;

View File

@ -33,9 +33,9 @@ import de.dhbwstuttgart.typeinference.Pair;
import de.dhbwstuttgart.typeinference.ResultSet;
import de.dhbwstuttgart.typeinference.SingleConstraint;
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
import de.dhbwstuttgart.typeinference.exceptions.NotImplementedException;
import de.dhbwstuttgart.typeinference.unify.MUB;
import de.dhbwstuttgart.typeinference.unify.Unify;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;

View File

@ -22,7 +22,6 @@ import de.dhbwstuttgart.typeinference.JavaCodeResult;
import de.dhbwstuttgart.typeinference.ResultSet;
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
import de.dhbwstuttgart.typeinference.unify.CSubstitutionSet;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;

View File

@ -28,7 +28,6 @@ import de.dhbwstuttgart.typeinference.SingleConstraint;
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
import de.dhbwstuttgart.typeinference.exceptions.TypeinferenceException;
import de.dhbwstuttgart.typeinference.unify.CSubstitutionSet;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;

View File

@ -25,8 +25,6 @@ import de.dhbwstuttgart.typeinference.JavaCodeResult;
import de.dhbwstuttgart.typeinference.ResultSet;
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
import de.dhbwstuttgart.typeinference.unify.CSubstitutionSet;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
// ino.end

View File

@ -24,7 +24,6 @@ import de.dhbwstuttgart.typeinference.ResultSet;
import de.dhbwstuttgart.typeinference.SingleConstraint;
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
import de.dhbwstuttgart.typeinference.unify.CSubstitutionSet;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;

View File

@ -23,7 +23,6 @@ import de.dhbwstuttgart.typeinference.Pair;
import de.dhbwstuttgart.typeinference.ResultSet;
import de.dhbwstuttgart.typeinference.Typeable;
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;

View File

@ -31,9 +31,9 @@ import de.dhbwstuttgart.typeinference.Pair;
import de.dhbwstuttgart.typeinference.ResultSet;
import de.dhbwstuttgart.typeinference.SingleConstraint;
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
import de.dhbwstuttgart.typeinference.exceptions.NotImplementedException;
import de.dhbwstuttgart.typeinference.unify.CSubstitutionSet;
import de.dhbwstuttgart.typeinference.unify.Unify;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;

View File

@ -0,0 +1,5 @@
package de.dhbwstuttgart.typeinference.exceptions;
public class NotImplementedException extends RuntimeException {
}