diff --git a/src/de/dhbwstuttgart/parser/JavaClassName.java b/src/de/dhbwstuttgart/parser/JavaClassName.java index 14005560..857680f0 100644 --- a/src/de/dhbwstuttgart/parser/JavaClassName.java +++ b/src/de/dhbwstuttgart/parser/JavaClassName.java @@ -18,6 +18,7 @@ public class JavaClassName { public JavaClassName(String name){ if(name == null)throw new NullPointerException(); + String[] names = name.split("[.]"); boolean match = true; if(names.length == 1){ diff --git a/src/de/dhbwstuttgart/syntaxtree/factory/ASTFactory.java b/src/de/dhbwstuttgart/syntaxtree/factory/ASTFactory.java index 557ff35b..060ea12c 100644 --- a/src/de/dhbwstuttgart/syntaxtree/factory/ASTFactory.java +++ b/src/de/dhbwstuttgart/syntaxtree/factory/ASTFactory.java @@ -53,4 +53,10 @@ public class ASTFactory { return generatedClass; } + + public static Class createObjectClass() { + Class generatedClass = new Class("java.lang.Object", 0); + + return generatedClass; + } } diff --git a/src/de/dhbwstuttgart/syntaxtree/type/RefType.java b/src/de/dhbwstuttgart/syntaxtree/type/RefType.java index 1c62c1e6..3fe126b4 100755 --- a/src/de/dhbwstuttgart/syntaxtree/type/RefType.java +++ b/src/de/dhbwstuttgart/syntaxtree/type/RefType.java @@ -850,14 +850,15 @@ public class RefType extends ObjectType implements IMatchable //TODO: bytecode woher bekommt ich die parent klasse String combinedType = getCombinedType(cg); - if(!combinedType.equals(get_Name())){ - // TODO bytecode createClass - Class generatedClass = ASTFactory.createClass(getCombinedType(cg), getParentClass()); + if(!combinedType.equals(getName().toString())){ + // TODO bytecode statt getParentClass die eigene Class?!?! + Class classObject = ASTFactory.createClass(getName().toString(), ASTFactory.createObjectClass()); + Class generatedClass = ASTFactory.createClass(getCombinedType(cg), classObject); cg.addExtraClass(generatedClass.genByteCode(new TypeinferenceResultSet(generatedClass, new Menge<>(), new ResultSet())).getByteCode()); } - return "L"+getCombinedType(cg)+";"; + return "L"+combinedType+";"; } public String getCombinedType(ClassGenerator cg){ @@ -865,14 +866,14 @@ public class RefType extends ObjectType implements IMatchable StringBuilder sb = new StringBuilder(); if(parameter != null && parameter.size() > 0){ - sb.append(this.get_Name().replace(".", "%")); + sb.append(getName().toString().replace(".", "%")); sb.append("%%"); for(Type type: parameter){ sb.append(((RefType) type).getCombinedType(cg).replace(".", "%")); sb.append("%"); } }else{ - sb.append(this.get_Name()); + sb.append(this.getName().toString()); } return sb.toString(); diff --git a/test/bytecode/types/Test.java b/test/bytecode/types/Test.java new file mode 100644 index 00000000..78235be2 --- /dev/null +++ b/test/bytecode/types/Test.java @@ -0,0 +1,12 @@ +import java.util.Vector; + +public class Test { + + public static void main(String[] args) { + Overloading o = new Overloading(); + Vector stringVector = new Vector(); + + o.method(stringVector); + } + +}