diff --git a/src/de/dhbwstuttgart/bytecode/BytecodeGen.java b/src/de/dhbwstuttgart/bytecode/BytecodeGen.java index 0d467b77..69acdefc 100644 --- a/src/de/dhbwstuttgart/bytecode/BytecodeGen.java +++ b/src/de/dhbwstuttgart/bytecode/BytecodeGen.java @@ -283,12 +283,16 @@ public class BytecodeGen implements ASTVisitor { break; } } - + HashMap subAndSuperTph = new HashMap<>(); for(GenericInsertPair p : allPairs) { + // Tph2.jav + if(subAndSuperTph.containsKey(p.TA1)) { + if(methodTphs.contains(subAndSuperTph.get(p.TA1))) + continue; + } subAndSuperTph.put(p.TA1, p.TA2); } - int numOfVisitedPairs = 0; for(TypePlaceholder subTph: subAndSuperTph.keySet()) { @@ -320,7 +324,6 @@ public class BytecodeGen implements ASTVisitor { TypePlaceholder subTphRes = tphsInRel.get(0); // Die größte Supertype TypePlaceholder superTphRes = tphsInRel.get(tphsInRel.size()-1); - int i = 2; while(!methodTphs.contains(superTphRes) && (tphsInRel.size()-i) >0) { superTphRes = tphsInRel.get(tphsInRel.size()-i); @@ -330,7 +333,6 @@ public class BytecodeGen implements ASTVisitor { GenericInsertPair sPair = new GenericInsertPair(subTphRes, superTphRes); simplifiedPairs.add(sPair); } - return simplifiedPairs; } diff --git a/src/de/dhbwstuttgart/bytecode/signature/Signature.java b/src/de/dhbwstuttgart/bytecode/signature/Signature.java index 2860cc83..7b222770 100644 --- a/src/de/dhbwstuttgart/bytecode/signature/Signature.java +++ b/src/de/dhbwstuttgart/bytecode/signature/Signature.java @@ -147,6 +147,33 @@ public class Signature { } } + for(GenericInsertPair p:methodPairs) { + String name = p.TA1.getName()+"$"; + if(!genericsAndBoundsMethod.containsKey(name)) { + sw.visitFormalTypeParameter(name); + sw.visitClassBound().visitTypeVariable(p.TA2.getName()+"$"); + genericsAndBoundsMethod.put(name, p.TA2.getName()+"$"); + } + } + + ArrayList types = new ArrayList<>(); + ArrayList superTypes = new ArrayList<>(); + + for(GenericInsertPair p : methodPairs) { + types.add(p.TA1); + superTypes.add(p.TA2); + } + + for(GenericInsertPair p : methodPairs) { + String name = p.TA2.getName()+"$"; + if(!types.contains(p.TA2) && !genericsAndBoundsMethod.containsKey(name)) { + String bound = Type.getInternalName(Object.class); + sw.visitFormalTypeParameter(name); + sw.visitClassBound().visitClassType(bound); + genericsAndBoundsMethod.put(name, bound); + sw.visitClassBound().visitEnd(); + } + } } // visit each method-parameter to create the signature