diff --git a/BCEL/bcelifier/BooleanValue.java b/BCEL/bcelifier/BooleanValue.java deleted file mode 100644 index f6859aeb..00000000 --- a/BCEL/bcelifier/BooleanValue.java +++ /dev/null @@ -1,6 +0,0 @@ -package bcelifier; - -public class BooleanValue { - Boolean c = true; - Boolean b = c.booleanValue(); -} diff --git a/BCEL/bcelifier/BooleanValueCreator.java b/BCEL/bcelifier/BooleanValueCreator.java deleted file mode 100644 index d019f948..00000000 --- a/BCEL/bcelifier/BooleanValueCreator.java +++ /dev/null @@ -1,63 +0,0 @@ -package bcelifier; - -import org.apache.commons.bcel6.generic.*; -import org.apache.commons.bcel6.classfile.*; -import org.apache.commons.bcel6.*; -import java.io.*; - -public class BooleanValueCreator implements Constants { - private InstructionFactory _factory; - private ConstantPoolGen _cp; - private ClassGen _cg; - - public BooleanValueCreator() { - _cg = new ClassGen("bcelifier.BooleanValue", "java.lang.Object", "BooleanValue.java", ACC_PUBLIC | ACC_SUPER, new String[] { }); - - _cp = _cg.getConstantPool(); - _factory = new InstructionFactory(_cg, _cp); - } - - public void create(OutputStream out) throws IOException { - createFields(); - createMethod_0(); - _cg.getJavaClass().dump(out); - } - - private void createFields() { - FieldGen field; - - field = new FieldGen(0, new ObjectType("java.lang.Boolean"), "c", _cp); - _cg.addField(field.getField()); - - field = new FieldGen(0, new ObjectType("java.lang.Boolean"), "b", _cp); - _cg.addField(field.getField()); - } - - private void createMethod_0() { - InstructionList il = new InstructionList(); - MethodGen method = new MethodGen(ACC_PUBLIC, Type.VOID, Type.NO_ARGS, new String[] { }, "", "bcelifier.BooleanValue", il, _cp); - - InstructionHandle ih_0 = il.append(_factory.createLoad(Type.OBJECT, 0)); - il.append(_factory.createInvoke("java.lang.Object", "", Type.VOID, Type.NO_ARGS, Constants.INVOKESPECIAL)); - InstructionHandle ih_4 = il.append(_factory.createLoad(Type.OBJECT, 0)); - il.append(new PUSH(_cp, 1)); - il.append(_factory.createInvoke("java.lang.Boolean", "valueOf", new ObjectType("java.lang.Boolean"), new Type[] { Type.BOOLEAN }, Constants.INVOKESTATIC)); - il.append(_factory.createFieldAccess("bcelifier.BooleanValue", "c", new ObjectType("java.lang.Boolean"), Constants.PUTFIELD)); - InstructionHandle ih_12 = il.append(_factory.createLoad(Type.OBJECT, 0)); - il.append(_factory.createLoad(Type.OBJECT, 0)); - il.append(_factory.createFieldAccess("bcelifier.BooleanValue", "c", new ObjectType("java.lang.Boolean"), Constants.GETFIELD)); - il.append(_factory.createInvoke("java.lang.Boolean", "booleanValue", Type.BOOLEAN, Type.NO_ARGS, Constants.INVOKEVIRTUAL)); - il.append(_factory.createInvoke("java.lang.Boolean", "valueOf", new ObjectType("java.lang.Boolean"), new Type[] { Type.BOOLEAN }, Constants.INVOKESTATIC)); - il.append(_factory.createFieldAccess("bcelifier.BooleanValue", "b", new ObjectType("java.lang.Boolean"), Constants.PUTFIELD)); - InstructionHandle ih_26 = il.append(_factory.createReturn(Type.VOID)); - method.setMaxStack(); - method.setMaxLocals(); - _cg.addMethod(method.getMethod()); - il.dispose(); - } - - public static void main(String[] args) throws Exception { - bcelifier.BooleanValueCreator creator = new bcelifier.BooleanValueCreator(); - creator.create(new FileOutputStream("bcelifier.BooleanValue.class")); - } -} diff --git a/BCEL/bcelifier/FieldDeclaration.java b/BCEL/bcelifier/FieldDeclaration.java deleted file mode 100644 index 00fb467d..00000000 --- a/BCEL/bcelifier/FieldDeclaration.java +++ /dev/null @@ -1,11 +0,0 @@ -package bcelifier; - -public class FieldDeclaration { - - Integer field = methode(); - - Integer methode() - { - return field; - } -} diff --git a/BCEL/bcelifier/FieldDeclarationCreator.java b/BCEL/bcelifier/FieldDeclarationCreator.java deleted file mode 100644 index 21553f53..00000000 --- a/BCEL/bcelifier/FieldDeclarationCreator.java +++ /dev/null @@ -1,68 +0,0 @@ -package bcelifier; - -import org.apache.commons.bcel6.generic.*; -import org.apache.commons.bcel6.classfile.*; -import org.apache.commons.bcel6.*; -import java.io.*; - -public class FieldDeclarationCreator implements Constants { - private InstructionFactory _factory; - private ConstantPoolGen _cp; - private ClassGen _cg; - - public FieldDeclarationCreator() { - _cg = new ClassGen("bcelifier.FieldDeclaration", "java.lang.Object", "FieldDeclaration.java", ACC_PUBLIC | ACC_SUPER, new String[] { }); - - _cp = _cg.getConstantPool(); - _factory = new InstructionFactory(_cg, _cp); - } - - public void create(OutputStream out) throws IOException { - createFields(); - createMethod_0(); - createMethod_1(); - _cg.getJavaClass().dump(out); - } - - private void createFields() { - FieldGen field; - - field = new FieldGen(0, new ObjectType("java.lang.Integer"), "field", _cp); - _cg.addField(field.getField()); - } - - private void createMethod_0() { - InstructionList il = new InstructionList(); - MethodGen method = new MethodGen(ACC_PUBLIC, Type.VOID, Type.NO_ARGS, new String[] { }, "", "bcelifier.FieldDeclaration", il, _cp); - - InstructionHandle ih_0 = il.append(_factory.createLoad(Type.OBJECT, 0)); - il.append(_factory.createInvoke("java.lang.Object", "", Type.VOID, Type.NO_ARGS, Constants.INVOKESPECIAL)); - InstructionHandle ih_4 = il.append(_factory.createLoad(Type.OBJECT, 0)); - il.append(_factory.createLoad(Type.OBJECT, 0)); - il.append(_factory.createInvoke("bcelifier.FieldDeclaration", "methode", new ObjectType("java.lang.Integer"), Type.NO_ARGS, Constants.INVOKEVIRTUAL)); - il.append(_factory.createFieldAccess("bcelifier.FieldDeclaration", "field", new ObjectType("java.lang.Integer"), Constants.PUTFIELD)); - InstructionHandle ih_12 = il.append(_factory.createReturn(Type.VOID)); - method.setMaxStack(); - method.setMaxLocals(); - _cg.addMethod(method.getMethod()); - il.dispose(); - } - - private void createMethod_1() { - InstructionList il = new InstructionList(); - MethodGen method = new MethodGen(0, new ObjectType("java.lang.Integer"), Type.NO_ARGS, new String[] { }, "methode", "bcelifier.FieldDeclaration", il, _cp); - - InstructionHandle ih_0 = il.append(_factory.createLoad(Type.OBJECT, 0)); - il.append(_factory.createFieldAccess("bcelifier.FieldDeclaration", "field", new ObjectType("java.lang.Integer"), Constants.GETFIELD)); - InstructionHandle ih_4 = il.append(_factory.createReturn(Type.OBJECT)); - method.setMaxStack(); - method.setMaxLocals(); - _cg.addMethod(method.getMethod()); - il.dispose(); - } - - public static void main(String[] args) throws Exception { - bcelifier.FieldDeclarationCreator creator = new bcelifier.FieldDeclarationCreator(); - creator.create(new FileOutputStream("bcelifier.FieldDeclaration.class")); - } -} diff --git a/BCEL/bcelifier/IfStatement.java b/BCEL/bcelifier/IfStatement.java deleted file mode 100644 index 8f16e0d4..00000000 --- a/BCEL/bcelifier/IfStatement.java +++ /dev/null @@ -1,12 +0,0 @@ -package bcelifier; - -class IfStatement{ - Integer methode(Boolean b){ - if(b){ - return 1; - }else{ - return 2; - } - } - -} \ No newline at end of file diff --git a/BCEL/bcelifier/IfStatementCreator.java b/BCEL/bcelifier/IfStatementCreator.java deleted file mode 100644 index 88b43e39..00000000 --- a/BCEL/bcelifier/IfStatementCreator.java +++ /dev/null @@ -1,71 +0,0 @@ -package bcelifier; - -import org.apache.commons.bcel6.generic.*; - -import de.dhbwstuttgart.syntaxtree.type.RefType; -import de.dhbwstuttgart.bytecode.ClassGenerator; -import de.dhbwstuttgart.bytecode.MethodGenerator; -import de.dhbwstuttgart.typeinference.TypeinferenceResults; - -import org.apache.commons.bcel6.*; -import java.io.*; - -public class IfStatementCreator { - private InstructionFactory _factory; - private ConstantPoolGen _cp; - private ClassGenerator _cg; - - public IfStatementCreator() { - - TypeinferenceResults typeinferenceResults = null; - _cg = new ClassGenerator("bcelifier.IfStatement", new RefType("java.lang.Object", null, 0), "IfStatement.java", Const.ACC_SUPER, new String[] { }, typeinferenceResults); - - _cp = _cg.getConstantPool(); - _factory = new InstructionFactory(_cg, _cp); - } - - public void create(OutputStream out) throws IOException { - createMethod_0(); - createMethod_1(); - _cg.getJavaClass().dump(out); - } - - private void createMethod_0() { - InstructionList il = new InstructionList(); - MethodGen method = new MethodGenerator(0, Type.VOID, new Type[] { new ObjectType("java.lang.Boolean") }, new String[] { "arg0" }, "", "bcelifier.IfStatement", il, _cp); - - InstructionHandle ih_0 = il.append(_factory.createLoad(Type.OBJECT, 0)); - il.append(_factory.createInvoke("java.lang.Object", "", Type.VOID, Type.NO_ARGS, Const.INVOKESPECIAL)); - InstructionHandle ih_4 = il.append(_factory.createReturn(Type.VOID)); - method.setMaxStack(); - method.setMaxLocals(); - _cg.addMethod(method.getMethod()); - } - - private void createMethod_1() { - InstructionList il = new InstructionList(); - MethodGen method = new MethodGenerator(0, new ObjectType("java.lang.Integer"), new Type[] { new ObjectType("java.lang.Boolean") }, new String[] { "arg0" }, "methode", "bcelifier.IfStatement", il, _cp); - - il.append(InstructionFactory.createLoad(Type.OBJECT, 1)); - il.append(_factory.createInvoke("java.lang.Boolean", "booleanValue", Type.BOOLEAN, Type.NO_ARGS, Const.INVOKEVIRTUAL)); - BranchInstruction ifeq_4 = InstructionFactory.createBranchInstruction(Const.IFEQ, null); - il.append(ifeq_4); - il.append(new PUSH(_cp, 1)); - il.append(_factory.createInvoke("java.lang.Integer", "valueOf", new ObjectType("java.lang.Integer"), new Type[] { Type.INT }, Const.INVOKESTATIC)); - il.append(InstructionFactory.createReturn(Type.OBJECT)); - InstructionHandle ih_12 = il.append(new PUSH(_cp, 2)); - il.append(_factory.createInvoke("java.lang.Integer", "valueOf", new ObjectType("java.lang.Integer"), new Type[] { Type.INT }, Const.INVOKESTATIC)); - il.append(InstructionFactory.createReturn(Type.OBJECT)); - ifeq_4.setTarget(ih_12); - method.setMaxStack(); - method.setMaxLocals(); - _cg.addMethod(method.getMethod()); - } - - public static void main(String[] args) throws Exception { - bcelifier.IfStatementCreator creator = new bcelifier.IfStatementCreator(); - creator.create(new FileOutputStream("bcelifier.IfStatement.class")); - - System.out.println("bcelifier.IfStatement.class"); - } -} diff --git a/BCEL/bcelifier/IntLiteral.class b/BCEL/bcelifier/IntLiteral.class deleted file mode 100644 index de65701a..00000000 Binary files a/BCEL/bcelifier/IntLiteral.class and /dev/null differ diff --git a/BCEL/bcelifier/IntLiteral.java b/BCEL/bcelifier/IntLiteral.java deleted file mode 100644 index a4d38fe9..00000000 --- a/BCEL/bcelifier/IntLiteral.java +++ /dev/null @@ -1,7 +0,0 @@ -package bcelifier; - -public class IntLiteral { - Integer methode(){ - return 50000; - } -} diff --git a/BCEL/bcelifier/IntLiteralCreator.java b/BCEL/bcelifier/IntLiteralCreator.java deleted file mode 100644 index 00ed284b..00000000 --- a/BCEL/bcelifier/IntLiteralCreator.java +++ /dev/null @@ -1,56 +0,0 @@ -package bcelifier; - -import org.apache.commons.bcel6.generic.*; -import org.apache.commons.bcel6.classfile.*; -import org.apache.commons.bcel6.*; -import java.io.*; - -public class IntLiteralCreator implements Constants { - private InstructionFactory _factory; - private ConstantPoolGen _cp; - private ClassGen _cg; - - public IntLiteralCreator() { - _cg = new ClassGen("bcelifier.IntLiteral", "java.lang.Object", "IntLiteral.java", ACC_PUBLIC | ACC_SUPER, new String[] { }); - - _cp = _cg.getConstantPool(); - _factory = new InstructionFactory(_cg, _cp); - } - - public void create(OutputStream out) throws IOException { - createMethod_0(); - createMethod_1(); - _cg.getJavaClass().dump(out); - } - - private void createMethod_0() { - InstructionList il = new InstructionList(); - MethodGen method = new MethodGen(ACC_PUBLIC, Type.VOID, Type.NO_ARGS, new String[] { }, "", "bcelifier.IntLiteral", il, _cp); - - InstructionHandle ih_0 = il.append(_factory.createLoad(Type.OBJECT, 0)); - il.append(_factory.createInvoke("java.lang.Object", "", Type.VOID, Type.NO_ARGS, Constants.INVOKESPECIAL)); - InstructionHandle ih_4 = il.append(_factory.createReturn(Type.VOID)); - method.setMaxStack(); - method.setMaxLocals(); - _cg.addMethod(method.getMethod()); - il.dispose(); - } - - private void createMethod_1() { - InstructionList il = new InstructionList(); - MethodGen method = new MethodGen(0, new ObjectType("java.lang.Integer"), Type.NO_ARGS, new String[] { }, "methode", "bcelifier.IntLiteral", il, _cp); - - InstructionHandle ih_0 = il.append(new PUSH(_cp, 50000)); - il.append(_factory.createInvoke("java.lang.Integer", "valueOf", new ObjectType("java.lang.Integer"), new Type[] { Type.INT }, Constants.INVOKESTATIC)); - InstructionHandle ih_5 = il.append(_factory.createReturn(Type.OBJECT)); - method.setMaxStack(); - method.setMaxLocals(); - _cg.addMethod(method.getMethod()); - il.dispose(); - } - - public static void main(String[] args) throws Exception { - bcelifier.IntLiteralCreator creator = new bcelifier.IntLiteralCreator(); - creator.create(new FileOutputStream("bcelifier.IntLiteral.class")); - } -} diff --git a/BCEL/bcelifier/JavaToBCEL.java b/BCEL/bcelifier/JavaToBCEL.java deleted file mode 100644 index 0d162b00..00000000 --- a/BCEL/bcelifier/JavaToBCEL.java +++ /dev/null @@ -1,43 +0,0 @@ -package bcelifier; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.PrintWriter; -import java.nio.file.Files; -import java.nio.file.OpenOption; -import java.nio.file.Path; - -import org.apache.commons.bcel6.classfile.ClassFormatException; -import org.apache.commons.bcel6.classfile.ClassParser; -import org.apache.commons.bcel6.classfile.JavaClass; -import org.apache.commons.bcel6.util.BCELifier; - -public class JavaToBCEL { - - public final static String rootDirectory = System.getProperty("user.dir")+"/BCEL/bcelifier/"; - - public static void main(String args[]){ - new JavaToBCEL(); - } - - public JavaToBCEL(){ - try { - //new BCELifier(new ClassParser(rootDirectory+"Lambda1.class").parse(), new FileOutputStream(new File(rootDirectory+"Lambda1Creator.java"))).start(); - //new BCELifier(new ClassParser(rootDirectory+"This.class").parse(), new FileOutputStream(new File(rootDirectory+"ThisCreator.java"))).start(); - //new BCELifier(new ClassParser(rootDirectory+"IntLiteral.class").parse(), new FileOutputStream(new File(rootDirectory+"IntLiteralCreator.java"))).start(); - //new BCELifier(new ClassParser(rootDirectory+"MethodCall.class").parse(), new FileOutputStream(new File(rootDirectory+"MethodCallCreator.java"))).start(); - //new BCELifier(new ClassParser(rootDirectory+"FieldDeclaration.class").parse(), new FileOutputStream(new File(rootDirectory+"FieldDeclarationCreator.java"))).start(); - //new BCELifier(new ClassParser(rootDirectory+"Null.class").parse(), new FileOutputStream(new File(rootDirectory+"NullCreator.java"))).start(); - //new BCELifier(new ClassParser(rootDirectory+"LocalVarAccess.class").parse(), new FileOutputStream(new File(rootDirectory+"LocalVarAccessCreator.java"))).start(); - //new BCELifier(new ClassParser(rootDirectory+"Wildcard.class").parse(), new FileOutputStream(new File(rootDirectory+"WildcardCreator.java"))).start(); - //new BCELifier(new ClassParser(rootDirectory+"BooleanValue.class").parse(), new FileOutputStream(new File(rootDirectory+"BooleanValueCreator.java"))).start(); - //new BCELifier(new ClassParser(rootDirectory+"NewClass.class").parse(), new FileOutputStream(new File(rootDirectory+"NewClassCreator.java"))).start(); - new BCELifier(new ClassParser(rootDirectory+"IfStatement.class").parse(), new FileOutputStream(new File(rootDirectory+"IfStatementCreator.java"))).start(); - } catch (ClassFormatException | IOException e) { - e.printStackTrace(); - } - } - - -} diff --git a/BCEL/bcelifier/Lambda1.class b/BCEL/bcelifier/Lambda1.class deleted file mode 100644 index c82ddc6f..00000000 Binary files a/BCEL/bcelifier/Lambda1.class and /dev/null differ diff --git a/BCEL/bcelifier/Lambda1.class.toGenerate b/BCEL/bcelifier/Lambda1.class.toGenerate deleted file mode 100644 index c82ddc6f..00000000 Binary files a/BCEL/bcelifier/Lambda1.class.toGenerate and /dev/null differ diff --git a/BCEL/bcelifier/Lambda1.java b/BCEL/bcelifier/Lambda1.java deleted file mode 100644 index 1cbce29c..00000000 --- a/BCEL/bcelifier/Lambda1.java +++ /dev/null @@ -1,8 +0,0 @@ -package bcelifier; - -public class Lambda1 { - - Runnable methode(){ - return ()->System.out.println(this); - } -} diff --git a/BCEL/bcelifier/Lambda1Creator.java b/BCEL/bcelifier/Lambda1Creator.java deleted file mode 100644 index e69de29b..00000000 diff --git a/BCEL/bcelifier/LocalVarAccess.java b/BCEL/bcelifier/LocalVarAccess.java deleted file mode 100644 index 116becbc..00000000 --- a/BCEL/bcelifier/LocalVarAccess.java +++ /dev/null @@ -1,10 +0,0 @@ -package bcelifier; - -public class LocalVarAccess { - Integer methode(Integer i){ - Integer var; - var = 10 + i; - return var; - } - -} diff --git a/BCEL/bcelifier/LocalVarAccessCreator.java b/BCEL/bcelifier/LocalVarAccessCreator.java deleted file mode 100644 index b85fcadb..00000000 --- a/BCEL/bcelifier/LocalVarAccessCreator.java +++ /dev/null @@ -1,61 +0,0 @@ -package bcelifier; - -import org.apache.commons.bcel6.generic.*; -import org.apache.commons.bcel6.classfile.*; -import org.apache.commons.bcel6.*; -import java.io.*; - -public class LocalVarAccessCreator implements Constants { - private InstructionFactory _factory; - private ConstantPoolGen _cp; - private ClassGen _cg; - - public LocalVarAccessCreator() { - _cg = new ClassGen("bcelifier.LocalVarAccess", "java.lang.Object", "LocalVarAccess.java", ACC_PUBLIC | ACC_SUPER, new String[] { }); - - _cp = _cg.getConstantPool(); - _factory = new InstructionFactory(_cg, _cp); - } - - public void create(OutputStream out) throws IOException { - createMethod_0(); - createMethod_1(); - _cg.getJavaClass().dump(out); - } - - private void createMethod_0() { - InstructionList il = new InstructionList(); - MethodGen method = new MethodGen(ACC_PUBLIC, Type.VOID, Type.NO_ARGS, new String[] { }, "", "bcelifier.LocalVarAccess", il, _cp); - - InstructionHandle ih_0 = il.append(_factory.createLoad(Type.OBJECT, 0)); - il.append(_factory.createInvoke("java.lang.Object", "", Type.VOID, Type.NO_ARGS, Constants.INVOKESPECIAL)); - InstructionHandle ih_4 = il.append(_factory.createReturn(Type.VOID)); - method.setMaxStack(); - method.setMaxLocals(); - _cg.addMethod(method.getMethod()); - il.dispose(); - } - - private void createMethod_1() { - InstructionList il = new InstructionList(); - MethodGen method = new MethodGen(0, new ObjectType("java.lang.Integer"), new Type[] { new ObjectType("java.lang.Integer") }, new String[] { "arg0" }, "methode", "bcelifier.LocalVarAccess", il, _cp); - - InstructionHandle ih_0 = il.append(new PUSH(_cp, 10)); - il.append(_factory.createLoad(Type.OBJECT, 1)); - il.append(_factory.createInvoke("java.lang.Integer", "intValue", Type.INT, Type.NO_ARGS, Constants.INVOKEVIRTUAL)); - il.append(InstructionConstants.IADD); - il.append(_factory.createInvoke("java.lang.Integer", "valueOf", new ObjectType("java.lang.Integer"), new Type[] { Type.INT }, Constants.INVOKESTATIC)); - il.append(_factory.createStore(Type.OBJECT, 2)); - InstructionHandle ih_11 = il.append(_factory.createLoad(Type.OBJECT, 2)); - InstructionHandle ih_12 = il.append(_factory.createReturn(Type.OBJECT)); - method.setMaxStack(); - method.setMaxLocals(); - _cg.addMethod(method.getMethod()); - il.dispose(); - } - - public static void main(String[] args) throws Exception { - bcelifier.LocalVarAccessCreator creator = new bcelifier.LocalVarAccessCreator(); - creator.create(new FileOutputStream("bcelifier.LocalVarAccess.class")); - } -} diff --git a/BCEL/bcelifier/MethodCall.class b/BCEL/bcelifier/MethodCall.class deleted file mode 100644 index c37c7d5b..00000000 Binary files a/BCEL/bcelifier/MethodCall.class and /dev/null differ diff --git a/BCEL/bcelifier/MethodCall.java b/BCEL/bcelifier/MethodCall.java deleted file mode 100644 index 433957b3..00000000 --- a/BCEL/bcelifier/MethodCall.java +++ /dev/null @@ -1,12 +0,0 @@ -package bcelifier; - -public class MethodCall { - void methode(){ - } - - void methode2(Runnable r){ - methode(); - r.run(); - } -} - diff --git a/BCEL/bcelifier/MethodCallCreator.java b/BCEL/bcelifier/MethodCallCreator.java deleted file mode 100644 index 341b0357..00000000 --- a/BCEL/bcelifier/MethodCallCreator.java +++ /dev/null @@ -1,70 +0,0 @@ -package bcelifier; - -import org.apache.commons.bcel6.generic.*; -import org.apache.commons.bcel6.classfile.*; -import org.apache.commons.bcel6.*; -import java.io.*; - -public class MethodCallCreator implements Constants { - private InstructionFactory _factory; - private ConstantPoolGen _cp; - private ClassGen _cg; - - public MethodCallCreator() { - _cg = new ClassGen("bcelifier.MethodCall", "java.lang.Object", "MethodCall.java", ACC_PUBLIC | ACC_SUPER, new String[] { }); - - _cp = _cg.getConstantPool(); - _factory = new InstructionFactory(_cg, _cp); - } - - public void create(OutputStream out) throws IOException { - createMethod_0(); - createMethod_1(); - createMethod_2(); - _cg.getJavaClass().dump(out); - } - - private void createMethod_0() { - InstructionList il = new InstructionList(); - MethodGen method = new MethodGen(ACC_PUBLIC, Type.VOID, Type.NO_ARGS, new String[] { }, "", "bcelifier.MethodCall", il, _cp); - - InstructionHandle ih_0 = il.append(_factory.createLoad(Type.OBJECT, 0)); - il.append(_factory.createInvoke("java.lang.Object", "", Type.VOID, Type.NO_ARGS, Constants.INVOKESPECIAL)); - InstructionHandle ih_4 = il.append(_factory.createReturn(Type.VOID)); - method.setMaxStack(); - method.setMaxLocals(); - _cg.addMethod(method.getMethod()); - il.dispose(); - } - - private void createMethod_1() { - InstructionList il = new InstructionList(); - MethodGen method = new MethodGen(0, Type.VOID, Type.NO_ARGS, new String[] { }, "methode", "bcelifier.MethodCall", il, _cp); - - InstructionHandle ih_0 = il.append(_factory.createReturn(Type.VOID)); - method.setMaxStack(); - method.setMaxLocals(); - _cg.addMethod(method.getMethod()); - il.dispose(); - } - - private void createMethod_2() { - InstructionList il = new InstructionList(); - MethodGen method = new MethodGen(0, Type.VOID, new Type[] { new ObjectType("java.lang.Runnable") }, new String[] { "arg0" }, "methode2", "bcelifier.MethodCall", il, _cp); - - InstructionHandle ih_0 = il.append(_factory.createLoad(Type.OBJECT, 0)); - il.append(_factory.createInvoke("bcelifier.MethodCall", "methode", Type.VOID, Type.NO_ARGS, Constants.INVOKEVIRTUAL)); - InstructionHandle ih_4 = il.append(_factory.createLoad(Type.OBJECT, 1)); - il.append(_factory.createInvoke("java.lang.Runnable", "run", Type.VOID, Type.NO_ARGS, Constants.INVOKEINTERFACE)); - InstructionHandle ih_10 = il.append(_factory.createReturn(Type.VOID)); - method.setMaxStack(); - method.setMaxLocals(); - _cg.addMethod(method.getMethod()); - il.dispose(); - } - - public static void main(String[] args) throws Exception { - bcelifier.MethodCallCreator creator = new bcelifier.MethodCallCreator(); - creator.create(new FileOutputStream("bcelifier.MethodCall.class")); - } -} diff --git a/BCEL/bcelifier/NewClass.java b/BCEL/bcelifier/NewClass.java deleted file mode 100644 index af0d2eae..00000000 --- a/BCEL/bcelifier/NewClass.java +++ /dev/null @@ -1,10 +0,0 @@ -package bcelifier; - - -public class NewClass { - public NewClass(Integer i){} - void methode2(){ - new NewClass(1); - } -} - diff --git a/BCEL/bcelifier/NewClassCreator.java b/BCEL/bcelifier/NewClassCreator.java deleted file mode 100644 index 3f20eed3..00000000 --- a/BCEL/bcelifier/NewClassCreator.java +++ /dev/null @@ -1,60 +0,0 @@ -package bcelifier; - -import org.apache.commons.bcel6.generic.*; -import org.apache.commons.bcel6.classfile.*; -import org.apache.commons.bcel6.*; -import java.io.*; - -public class NewClassCreator implements Constants { - private InstructionFactory _factory; - private ConstantPoolGen _cp; - private ClassGen _cg; - - public NewClassCreator() { - _cg = new ClassGen("bcelifier.NewClass", "java.lang.Object", "NewClass.java", ACC_PUBLIC | ACC_SUPER, new String[] { }); - - _cp = _cg.getConstantPool(); - _factory = new InstructionFactory(_cg, _cp); - } - - public void create(OutputStream out) throws IOException { - createMethod_0(); - createMethod_1(); - _cg.getJavaClass().dump(out); - } - - private void createMethod_0() { - InstructionList il = new InstructionList(); - MethodGen method = new MethodGen(ACC_PUBLIC, Type.VOID, new Type[] { new ObjectType("java.lang.Integer") }, new String[] { "arg0" }, "", "bcelifier.NewClass", il, _cp); - - InstructionHandle ih_0 = il.append(_factory.createLoad(Type.OBJECT, 0)); - il.append(_factory.createInvoke("java.lang.Object", "", Type.VOID, Type.NO_ARGS, Constants.INVOKESPECIAL)); - InstructionHandle ih_4 = il.append(_factory.createReturn(Type.VOID)); - method.setMaxStack(); - method.setMaxLocals(); - _cg.addMethod(method.getMethod()); - il.dispose(); - } - - private void createMethod_1() { - InstructionList il = new InstructionList(); - MethodGen method = new MethodGen(0, Type.VOID, Type.NO_ARGS, new String[] { }, "methode2", "bcelifier.NewClass", il, _cp); - - InstructionHandle ih_0 = il.append(_factory.createNew("bcelifier.NewClass")); - il.append(InstructionConstants.DUP); - il.append(new PUSH(_cp, 1)); - il.append(_factory.createInvoke("java.lang.Integer", "valueOf", new ObjectType("java.lang.Integer"), new Type[] { Type.INT }, Constants.INVOKESTATIC)); - il.append(_factory.createInvoke("bcelifier.NewClass", "", Type.VOID, new Type[] { new ObjectType("java.lang.Integer") }, Constants.INVOKESPECIAL)); - il.append(InstructionConstants.POP); - InstructionHandle ih_12 = il.append(_factory.createReturn(Type.VOID)); - method.setMaxStack(); - method.setMaxLocals(); - _cg.addMethod(method.getMethod()); - il.dispose(); - } - - public static void main(String[] args) throws Exception { - bcelifier.NewClassCreator creator = new bcelifier.NewClassCreator(); - creator.create(new FileOutputStream("bcelifier.NewClass.class")); - } -} diff --git a/BCEL/bcelifier/Null.java b/BCEL/bcelifier/Null.java deleted file mode 100644 index d7329b7c..00000000 --- a/BCEL/bcelifier/Null.java +++ /dev/null @@ -1,7 +0,0 @@ -package bcelifier; - -public class Null { - - Integer i = null; - -} diff --git a/BCEL/bcelifier/NullCreator.java b/BCEL/bcelifier/NullCreator.java deleted file mode 100644 index d7960def..00000000 --- a/BCEL/bcelifier/NullCreator.java +++ /dev/null @@ -1,53 +0,0 @@ -package bcelifier; - -import org.apache.commons.bcel6.generic.*; -import org.apache.commons.bcel6.classfile.*; -import org.apache.commons.bcel6.*; -import java.io.*; - -public class NullCreator implements Constants { - private InstructionFactory _factory; - private ConstantPoolGen _cp; - private ClassGen _cg; - - public NullCreator() { - _cg = new ClassGen("bcelifier.Null", "java.lang.Object", "Null.java", ACC_PUBLIC | ACC_SUPER, new String[] { }); - - _cp = _cg.getConstantPool(); - _factory = new InstructionFactory(_cg, _cp); - } - - public void create(OutputStream out) throws IOException { - createFields(); - createMethod_0(); - _cg.getJavaClass().dump(out); - } - - private void createFields() { - FieldGen field; - - field = new FieldGen(0, new ObjectType("java.lang.Integer"), "i", _cp); - _cg.addField(field.getField()); - } - - private void createMethod_0() { - InstructionList il = new InstructionList(); - MethodGen method = new MethodGen(ACC_PUBLIC, Type.VOID, Type.NO_ARGS, new String[] { }, "", "bcelifier.Null", il, _cp); - - InstructionHandle ih_0 = il.append(_factory.createLoad(Type.OBJECT, 0)); - il.append(_factory.createInvoke("java.lang.Object", "", Type.VOID, Type.NO_ARGS, Constants.INVOKESPECIAL)); - InstructionHandle ih_4 = il.append(_factory.createLoad(Type.OBJECT, 0)); - il.append(InstructionConstants.ACONST_NULL); - il.append(_factory.createFieldAccess("bcelifier.Null", "i", new ObjectType("java.lang.Integer"), Constants.PUTFIELD)); - InstructionHandle ih_9 = il.append(_factory.createReturn(Type.VOID)); - method.setMaxStack(); - method.setMaxLocals(); - _cg.addMethod(method.getMethod()); - il.dispose(); - } - - public static void main(String[] args) throws Exception { - bcelifier.NullCreator creator = new bcelifier.NullCreator(); - creator.create(new FileOutputStream("bcelifier.Null.class")); - } -} diff --git a/BCEL/bcelifier/This.class b/BCEL/bcelifier/This.class deleted file mode 100644 index 76fe2494..00000000 Binary files a/BCEL/bcelifier/This.class and /dev/null differ diff --git a/BCEL/bcelifier/This.java b/BCEL/bcelifier/This.java deleted file mode 100644 index 3d239478..00000000 --- a/BCEL/bcelifier/This.java +++ /dev/null @@ -1,8 +0,0 @@ -package bcelifier; - -public class This { - - This methode(){ - return this; - } -} diff --git a/BCEL/bcelifier/ThisCreator.java b/BCEL/bcelifier/ThisCreator.java deleted file mode 100644 index 68cc58aa..00000000 --- a/BCEL/bcelifier/ThisCreator.java +++ /dev/null @@ -1,55 +0,0 @@ -package bcelifier; - -import org.apache.commons.bcel6.generic.*; -import org.apache.commons.bcel6.classfile.*; -import org.apache.commons.bcel6.*; -import java.io.*; - -public class ThisCreator implements Constants { - private InstructionFactory _factory; - private ConstantPoolGen _cp; - private ClassGen _cg; - - public ThisCreator() { - _cg = new ClassGen("bcelifier.This", "java.lang.Object", "This.java", ACC_PUBLIC | ACC_SUPER, new String[] { }); - - _cp = _cg.getConstantPool(); - _factory = new InstructionFactory(_cg, _cp); - } - - public void create(OutputStream out) throws IOException { - createMethod_0(); - createMethod_1(); - _cg.getJavaClass().dump(out); - } - - private void createMethod_0() { - InstructionList il = new InstructionList(); - MethodGen method = new MethodGen(ACC_PUBLIC, Type.VOID, Type.NO_ARGS, new String[] { }, "", "bcelifier.This", il, _cp); - - InstructionHandle ih_0 = il.append(_factory.createLoad(Type.OBJECT, 0)); - il.append(_factory.createInvoke("java.lang.Object", "", Type.VOID, Type.NO_ARGS, Constants.INVOKESPECIAL)); - InstructionHandle ih_4 = il.append(_factory.createReturn(Type.VOID)); - method.setMaxStack(); - method.setMaxLocals(); - _cg.addMethod(method.getMethod()); - il.dispose(); - } - - private void createMethod_1() { - InstructionList il = new InstructionList(); - MethodGen method = new MethodGen(0, new ObjectType("bcelifier.This"), Type.NO_ARGS, new String[] { }, "methode", "bcelifier.This", il, _cp); - - InstructionHandle ih_0 = il.append(_factory.createLoad(Type.OBJECT, 0)); - InstructionHandle ih_1 = il.append(_factory.createReturn(Type.OBJECT)); - method.setMaxStack(); - method.setMaxLocals(); - _cg.addMethod(method.getMethod()); - il.dispose(); - } - - public static void main(String[] args) throws Exception { - bcelifier.ThisCreator creator = new bcelifier.ThisCreator(); - creator.create(new FileOutputStream("bcelifier.This.class")); - } -} diff --git a/BCEL/bcelifier/Wildcard.java b/BCEL/bcelifier/Wildcard.java deleted file mode 100644 index b65144ac..00000000 --- a/BCEL/bcelifier/Wildcard.java +++ /dev/null @@ -1,5 +0,0 @@ -package bcelifier; - -public class Wildcard { - Wildcard a; -} diff --git a/BCEL/bcelifier/WildcardCreator.java b/BCEL/bcelifier/WildcardCreator.java deleted file mode 100644 index 6f83ff50..00000000 --- a/BCEL/bcelifier/WildcardCreator.java +++ /dev/null @@ -1,50 +0,0 @@ -package bcelifier; - -import org.apache.commons.bcel6.generic.*; -import org.apache.commons.bcel6.classfile.*; -import org.apache.commons.bcel6.*; -import java.io.*; - -public class WildcardCreator implements Constants { - private InstructionFactory _factory; - private ConstantPoolGen _cp; - private ClassGen _cg; - - public WildcardCreator() { - _cg = new ClassGen("bcelifier.Wildcard", "java.lang.Object", "Wildcard.java", ACC_PUBLIC | ACC_SUPER, new String[] { }); - - _cp = _cg.getConstantPool(); - _factory = new InstructionFactory(_cg, _cp); - } - - public void create(OutputStream out) throws IOException { - createFields(); - createMethod_0(); - _cg.getJavaClass().dump(out); - } - - private void createFields() { - FieldGen field; - - field = new FieldGen(0, new ObjectType("bcelifier.Wildcard"), "a", _cp); - _cg.addField(field.getField()); - } - - private void createMethod_0() { - InstructionList il = new InstructionList(); - MethodGen method = new MethodGen(ACC_PUBLIC, Type.VOID, Type.NO_ARGS, new String[] { }, "", "bcelifier.Wildcard", il, _cp); - - InstructionHandle ih_0 = il.append(_factory.createLoad(Type.OBJECT, 0)); - il.append(_factory.createInvoke("java.lang.Object", "", Type.VOID, Type.NO_ARGS, Constants.INVOKESPECIAL)); - InstructionHandle ih_4 = il.append(_factory.createReturn(Type.VOID)); - method.setMaxStack(); - method.setMaxLocals(); - _cg.addMethod(method.getMethod()); - il.dispose(); - } - - public static void main(String[] args) throws Exception { - bcelifier.WildcardCreator creator = new bcelifier.WildcardCreator(); - creator.create(new FileOutputStream("bcelifier.Wildcard.class")); - } -} diff --git a/lib/commons-bcel6-6.0-SNAPSHOT.jar b/lib/commons-bcel6-6.0-SNAPSHOT.jar index c074d7f4..fb9a8ed3 100644 Binary files a/lib/commons-bcel6-6.0-SNAPSHOT.jar and b/lib/commons-bcel6-6.0-SNAPSHOT.jar differ diff --git a/src/de/dhbwstuttgart/bytecode/MethodGenerator.java b/src/de/dhbwstuttgart/bytecode/MethodGenerator.java index effb63e2..04bab9a8 100644 --- a/src/de/dhbwstuttgart/bytecode/MethodGenerator.java +++ b/src/de/dhbwstuttgart/bytecode/MethodGenerator.java @@ -87,6 +87,7 @@ public class MethodGenerator extends MethodGen{ method.addAttribute(factory.createSignatureAttribute(paramTypesSig+retTypeSig)); + System.out.println(this.getInstructionList().size()); StackMap stackMap = new StackMapTableGen(this, cp).getStackMap(); if(stackMap != null)method.addCodeAttribute(stackMap); diff --git a/src/de/dhbwstuttgart/typeinference/EinzelElement.java b/src/de/dhbwstuttgart/typeinference/EinzelElement.java index 32cfba03..60ae48fb 100644 --- a/src/de/dhbwstuttgart/typeinference/EinzelElement.java +++ b/src/de/dhbwstuttgart/typeinference/EinzelElement.java @@ -23,8 +23,8 @@ public class EinzelElement implements KomplexeMenge{ Menge i = new Menge(); i.add(item); ret.add(i); - //return ret; - throw new NotImplementedException(); + return ret; + //throw new NotImplementedException(); } @Override diff --git a/test/bytecode/WhileTest.jav b/test/bytecode/WhileTest.jav index fa39c905..903020d5 100644 --- a/test/bytecode/WhileTest.jav +++ b/test/bytecode/WhileTest.jav @@ -1,4 +1,5 @@ class WhileTest{ + void method(){ Integer i; i = 1; diff --git a/test/bytecode/WhileTest.java b/test/bytecode/WhileTest.java index dde969ed..025f4d30 100644 --- a/test/bytecode/WhileTest.java +++ b/test/bytecode/WhileTest.java @@ -21,7 +21,6 @@ public class WhileTest extends SourceFileBytecodeTest{ Class cls = classLoader.loadClass(testName); - Object obj = cls.newInstance(); assertTrue(true); } } \ No newline at end of file