From bdbe20552e4493212661d36c2f009e715a964a3a Mon Sep 17 00:00:00 2001 From: JanUlrich Date: Thu, 29 Oct 2015 15:16:19 +0100 Subject: [PATCH 1/5] =?UTF-8?q?Tests=20zu=20Bytecodegenerierung=20anf?= =?UTF-8?q?=C3=BCgen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/bytecode/Binary.jav | 10 ++++++ test/bytecode/Binary2.jav | 16 +++++++++ test/bytecode/BinaryTest.java | 34 +++++++++++++++++++ test/bytecode/BinaryTest2.java | 34 +++++++++++++++++++ .../MultipleTypesInsertTester.java | 6 ++-- 5 files changed, 98 insertions(+), 2 deletions(-) create mode 100644 test/bytecode/Binary.jav create mode 100644 test/bytecode/Binary2.jav create mode 100644 test/bytecode/BinaryTest.java create mode 100644 test/bytecode/BinaryTest2.java diff --git a/test/bytecode/Binary.jav b/test/bytecode/Binary.jav new file mode 100644 index 00000000..3ea073fb --- /dev/null +++ b/test/bytecode/Binary.jav @@ -0,0 +1,10 @@ +class Binary{ + +void method() { +a; +a = 20; +b; +b=59 + a; +} + +} \ No newline at end of file diff --git a/test/bytecode/Binary2.jav b/test/bytecode/Binary2.jav new file mode 100644 index 00000000..f587c123 --- /dev/null +++ b/test/bytecode/Binary2.jav @@ -0,0 +1,16 @@ +class OL { + + Integer m(Integer x) { return x + x; } + + Boolean m(Boolean x) {return x || x; } +} + +class Binary2 { + + main(x) { + ol; + ol = new OL(); + return ol.m(x); + } + +} \ No newline at end of file diff --git a/test/bytecode/BinaryTest.java b/test/bytecode/BinaryTest.java new file mode 100644 index 00000000..37b0ab82 --- /dev/null +++ b/test/bytecode/BinaryTest.java @@ -0,0 +1,34 @@ +package bytecode; + +import static org.junit.Assert.*; + +import java.io.File; +import java.io.IOException; + +import junit.framework.TestCase; + +import org.junit.Test; + +import plugindevelopment.TypeInsertTester; +import de.dhbwstuttgart.core.MyCompiler; +import de.dhbwstuttgart.core.MyCompilerAPI; +import de.dhbwstuttgart.logger.LoggerConfiguration; +import de.dhbwstuttgart.logger.Section; +import de.dhbwstuttgart.parser.JavaParser.yyException; +import de.dhbwstuttgart.typeinference.ByteCodeResult; +import de.dhbwstuttgart.typeinference.Menge; +import de.dhbwstuttgart.typeinference.TypeinferenceResultSet; +import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet; + +public class BinaryTest { + + public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/"; + public final static String testFile = "Binary.jav"; + public final static String outputFile = "Binary.class"; + + @Test + public void test() { + SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile); + } + +} diff --git a/test/bytecode/BinaryTest2.java b/test/bytecode/BinaryTest2.java new file mode 100644 index 00000000..8660ef0e --- /dev/null +++ b/test/bytecode/BinaryTest2.java @@ -0,0 +1,34 @@ +package bytecode; + +import static org.junit.Assert.*; + +import java.io.File; +import java.io.IOException; + +import junit.framework.TestCase; + +import org.junit.Test; + +import plugindevelopment.TypeInsertTester; +import de.dhbwstuttgart.core.MyCompiler; +import de.dhbwstuttgart.core.MyCompilerAPI; +import de.dhbwstuttgart.logger.LoggerConfiguration; +import de.dhbwstuttgart.logger.Section; +import de.dhbwstuttgart.parser.JavaParser.yyException; +import de.dhbwstuttgart.typeinference.ByteCodeResult; +import de.dhbwstuttgart.typeinference.Menge; +import de.dhbwstuttgart.typeinference.TypeinferenceResultSet; +import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet; + +public class BinaryTest2 { + + public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/"; + public final static String testFile = "Binary2.jav"; + public final static String outputFile = "Binary2.class"; + + @Test + public void test() { + SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile); + } + +} diff --git a/test/plugindevelopment/TypeInsertTests/MultipleTypesInsertTester.java b/test/plugindevelopment/TypeInsertTests/MultipleTypesInsertTester.java index 80628a37..d4fee620 100755 --- a/test/plugindevelopment/TypeInsertTests/MultipleTypesInsertTester.java +++ b/test/plugindevelopment/TypeInsertTests/MultipleTypesInsertTester.java @@ -14,6 +14,7 @@ import de.dhbwstuttgart.logger.Section; import de.dhbwstuttgart.logger.SectionLogger; import de.dhbwstuttgart.logger.Timewatch; import de.dhbwstuttgart.parser.JavaParser.yyException; +import de.dhbwstuttgart.syntaxtree.SourceFile; import de.dhbwstuttgart.typeinference.TypeinferenceResultSet; import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertPoint; import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet; @@ -78,8 +79,9 @@ public class MultipleTypesInsertTester extends TypeInsertTester{ String inferedSource = ""; MyCompilerAPI compiler = MyCompiler.getAPI(logConfig); try { - compiler.parse(new File(rootDirectory + sourceFileToInfere)); - Menge results = compiler.typeReconstruction(); + Menge parsedSource = new Menge<>(); + parsedSource.add(compiler.parse(new File(rootDirectory + sourceFileToInfere))); + Menge results = compiler.typeReconstruction(parsedSource); //TestCase.assertTrue("Es darf nicht mehr als eine Lösungsmöglichkeit geben und nicht "+results.size(), results.size()==1); for(TypeinferenceResultSet result : results){ TypeInsertSet point = result.getTypeInsertionPoints(); From 6619b73d803b7123ba39276aa0b124f613b4ec78 Mon Sep 17 00:00:00 2001 From: JanUlrich Date: Fri, 30 Oct 2015 16:37:12 +0100 Subject: [PATCH 2/5] =?UTF-8?q?Binary2=20Test=20=C3=A4ndern?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/bytecode/Binary2.jav | 12 ++---------- test/bytecode/BinaryTest2.java | 2 +- test/bytecode/types/OverloadingTest.java | 1 - 3 files changed, 3 insertions(+), 12 deletions(-) diff --git a/test/bytecode/Binary2.jav b/test/bytecode/Binary2.jav index f587c123..e89672ac 100644 --- a/test/bytecode/Binary2.jav +++ b/test/bytecode/Binary2.jav @@ -1,16 +1,8 @@ -class OL { + +class Binary2 { Integer m(Integer x) { return x + x; } Boolean m(Boolean x) {return x || x; } -} - -class Binary2 { - - main(x) { - ol; - ol = new OL(); - return ol.m(x); - } } \ No newline at end of file diff --git a/test/bytecode/BinaryTest2.java b/test/bytecode/BinaryTest2.java index 8660ef0e..842af094 100644 --- a/test/bytecode/BinaryTest2.java +++ b/test/bytecode/BinaryTest2.java @@ -28,7 +28,7 @@ public class BinaryTest2 { @Test public void test() { - SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile); + SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory); } } diff --git a/test/bytecode/types/OverloadingTest.java b/test/bytecode/types/OverloadingTest.java index 9e6b3a22..f8f6a862 100644 --- a/test/bytecode/types/OverloadingTest.java +++ b/test/bytecode/types/OverloadingTest.java @@ -17,7 +17,6 @@ public class OverloadingTest extends BytecodeTest{ } - @Test public void testString() { try{ From 1a0c76accfb9c11fc4cab7723e1086b836896785 Mon Sep 17 00:00:00 2001 From: JanUlrich Date: Fri, 6 Nov 2015 15:18:43 +0100 Subject: [PATCH 3/5] Anpassungen im Test --- .../TypeInsertTests/MultipleTypesInsertTester.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/plugindevelopment/TypeInsertTests/MultipleTypesInsertTester.java b/test/plugindevelopment/TypeInsertTests/MultipleTypesInsertTester.java index d4fee620..db3346a1 100755 --- a/test/plugindevelopment/TypeInsertTests/MultipleTypesInsertTester.java +++ b/test/plugindevelopment/TypeInsertTests/MultipleTypesInsertTester.java @@ -47,8 +47,10 @@ public class MultipleTypesInsertTester extends TypeInsertTester{ MyCompilerAPI compiler = MyCompiler.getAPI(logConfig); try { - compiler.parse(new File(rootDirectory + sourceFileToInfere)); - Menge results = compiler.typeReconstruction(); + SourceFile parsedFile = compiler.parse(new File(rootDirectory + sourceFileToInfere)); + Menge parsedFiles = new Menge<>(); + parsedFiles.add(parsedFile); + Menge results = compiler.typeReconstruction(parsedFiles); System.out.println("Typinferenz ausgeführt!"); //TestCase.assertTrue("Es darf nicht mehr als eine Lösungsmöglichkeit geben und nicht "+results.size(), results.size()==1); for(TypeinferenceResultSet result : results){ From 0048d5f305abe3a9b1bbbade2f03ff0d4a02f34b Mon Sep 17 00:00:00 2001 From: JanUlrich Date: Fri, 6 Nov 2015 18:27:47 +0100 Subject: [PATCH 4/5] NewStatement bytecode --- BCEL/bcelifier/JavaToBCEL.java | 1 + .../syntaxtree/statement/ArgumentList.java | 45 ++++++++------- .../syntaxtree/statement/NewClass.java | 43 +++++++-------- .../syntaxtree/type/RefType.java | 4 +- test/bytecode/NewStatement.jav | 10 ++++ test/bytecode/NewStatementTest.java | 55 +++++++++++++++++++ test/bytecode/Test2.java | 6 ++ 7 files changed, 118 insertions(+), 46 deletions(-) create mode 100644 test/bytecode/NewStatement.jav create mode 100644 test/bytecode/NewStatementTest.java create mode 100644 test/bytecode/Test2.java diff --git a/BCEL/bcelifier/JavaToBCEL.java b/BCEL/bcelifier/JavaToBCEL.java index 10c74c32..c96990dd 100644 --- a/BCEL/bcelifier/JavaToBCEL.java +++ b/BCEL/bcelifier/JavaToBCEL.java @@ -32,6 +32,7 @@ public class JavaToBCEL { 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(); } catch (ClassFormatException | IOException e) { e.printStackTrace(); diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/ArgumentList.java b/src/de/dhbwstuttgart/syntaxtree/statement/ArgumentList.java index 3644ec30..1b50ed01 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/ArgumentList.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/ArgumentList.java @@ -1,39 +1,26 @@ -// ino.module.ArgumentList.8621.package package de.dhbwstuttgart.syntaxtree.statement; -// ino.end -// ino.module.ArgumentList.8621.import -import java.util.Iterator; -import de.dhbwstuttgart.typeinference.Menge; +import java.util.Iterator; + +import org.apache.commons.bcel6.generic.InstructionList; + +import de.dhbwstuttgart.typeinference.Menge; +import de.dhbwstuttgart.bytecode.ClassGenerator; import de.dhbwstuttgart.myexception.JVMCodeException; import de.dhbwstuttgart.syntaxtree.FormalParameter; import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode; import de.dhbwstuttgart.typeinference.JavaCodeResult; import de.dhbwstuttgart.typeinference.ResultSet; - - - -// ino.class.ArgumentList.24911.declaration public class ArgumentList extends SyntaxTreeNode -// ino.end -// ino.class.ArgumentList.24911.body { - // ino.attribute.expr.24914.declaration public Menge expr = new Menge(); - // ino.end - // ino.method.get_firstElement.24923.definition public Object get_firstElement() - // ino.end - // ino.method.get_firstElement.24923.body { return expr.firstElement(); } - // ino.end - - /** * @author Andreas Stadelmeier, a10023 @@ -93,6 +80,22 @@ public class ArgumentList extends SyntaxTreeNode public Menge getChildren() { return expr; } - + + public InstructionList generateBytecode(ClassGenerator cg){ + InstructionList ret = new InstructionList(); + for(Expr e : expr){ + ret.append(e.genByteCode(cg)); + } + return ret; + } + + public org.apache.commons.bcel6.generic.Type[] getBytecodeTypeList(ClassGenerator cg){ + org.apache.commons.bcel6.generic.Type[] ret = new org.apache.commons.bcel6.generic.Type[expr.size()]; + int i = 0; + for(Expr e : expr){ + ret[i] = e.getType().getBytecodeType(cg); + i++; + } + return ret; + } } -// ino.end diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/NewClass.java b/src/de/dhbwstuttgart/syntaxtree/statement/NewClass.java index cc6d68b3..6d4d89d7 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/NewClass.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/NewClass.java @@ -6,8 +6,11 @@ import java.util.Enumeration; import java.util.Hashtable; import java.util.Iterator; +import org.apache.commons.bcel6.Constants; import org.apache.commons.bcel6.generic.ClassGen; +import org.apache.commons.bcel6.generic.InstructionConstants; import org.apache.commons.bcel6.generic.InstructionList; +import org.apache.commons.bcel6.generic.ObjectType; import de.dhbwstuttgart.typeinference.Menge; import de.dhbwstuttgart.bytecode.ClassGenerator; @@ -55,6 +58,7 @@ public class NewClass extends Expr // ino.attribute.arglist.25837.declaration private ArgumentList arglist; + private boolean isStatement = false; // ino.end // ino.attribute.parserlog.25840.declaration protected static Logger parserlog = Logger.getLogger("parser"); @@ -129,15 +133,7 @@ public class NewClass extends Expr //TODO: Das hier noch vervollständigen ConstraintsSet ret = new ConstraintsSet(); UndConstraint callConstraints = new UndConstraint(); - //Die Auskommentierten Zeilen gehören zu MethodRefNew - //Menge argumentTypeList = new Menge(); - //for(Expr expr : this.arglist.expr){ - // argumentTypeList.add(expr.getTypeVariable()); - //} - //FunN funN= new FunN(null,argumentTypeList); - //Constraint newClassTypeConstraint = new Constraint(null,null); - //ret.add(newClassTypeConstraint); int numArgs = 0; if(this.arglist != null)numArgs = this.arglist.size(); ConstructorAssumption cA = assumptions.getConstructorAssumption(this.get_Name(), numArgs); @@ -147,22 +143,9 @@ public class NewClass extends Expr ret.add(this.arglist.expr.elementAt(i).TYPEExpr(assumptions)); callConstraints.addConstraint( this.arglist.expr.elementAt(i).getType().TYPE(assumptions, this), cA.getParameterType(i).TYPE(assumptions, this)); } - //if(this.arglist != null && this.arglist.expr != null)for(Expr arg : this.arglist.expr){ - // ret.add(arg.TYPEExpr(assumptions)); - //} Type thisT = assumptions.checkType(new RefType(this.get_Name(),this,0), (SyntaxTreeNode)this); this.setType(thisT); - - /* - //Ein new-Aufruf ist nichts anderes als ein MethodCall der Methode - MethodCall newAufruf = new MethodCall(0,0); - this.setType(assumptions.getTypeFor(new RefType(this.get_Name(),0))); - newAufruf.type = this.getType(); - newAufruf.set_Name(""); - newAufruf.set_Receiver(null); - ret.add(new Overloading(assumptions, newAufruf, this.getType()).generateConsstraints()); - */ return ret; } @@ -176,6 +159,7 @@ public class NewClass extends Expr public ConstraintsSet TYPEStmt(TypeAssumptions assumptions){ ConstraintsSet ret = this.TYPEExpr(assumptions); //TypeExpr aufrufen this.setType(new Void(this,0)); //Typ des Statments auf Void setzen. + this.isStatement = true; return ret; } @@ -208,8 +192,21 @@ public class NewClass extends Expr @Override public InstructionList genByteCode(ClassGenerator _cg) { - // TODO Bytecode - throw new NotImplementedException(); + InstructionList il = new InstructionList(); + if(arglist!=null){ + il.append(arglist.generateBytecode(_cg)); + il.append(_cg.getInstructionFactory().createInvoke(this.get_Name(), "", + org.apache.commons.bcel6.generic.Type.VOID, + this.arglist.getBytecodeTypeList(_cg), Constants.INVOKESPECIAL)); + }else{ + il.append(_cg.getInstructionFactory().createInvoke(this.get_Name(), "", + org.apache.commons.bcel6.generic.Type.VOID, + new org.apache.commons.bcel6.generic.Type[]{}, Constants.INVOKESPECIAL)); + } + if(this.isStatement){ + il.append(InstructionConstants.POP); + } + return il; } diff --git a/src/de/dhbwstuttgart/syntaxtree/type/RefType.java b/src/de/dhbwstuttgart/syntaxtree/type/RefType.java index 9f33148b..ef88050d 100755 --- a/src/de/dhbwstuttgart/syntaxtree/type/RefType.java +++ b/src/de/dhbwstuttgart/syntaxtree/type/RefType.java @@ -857,8 +857,8 @@ public class RefType extends ObjectType implements IMatchable cg.addExtraClass(generatedClass.genByteCode(new TypeinferenceResultSet(generatedClass, new Menge<>(), new ResultSet())).getByteCode()); } - - return "L"+combinedType+";"; + String ret = new org.apache.commons.bcel6.generic.ObjectType(combinedType).getSignature(); + return ret; } public String getCombinedType(ClassGenerator cg){ diff --git a/test/bytecode/NewStatement.jav b/test/bytecode/NewStatement.jav new file mode 100644 index 00000000..c654c116 --- /dev/null +++ b/test/bytecode/NewStatement.jav @@ -0,0 +1,10 @@ +class NewStatement{ +public NewStatement(Integer i){} +public NewStatement(String i){} +method() { + NewStatement n; + n = new NewStatement("hallo"); + n = new NewStatement(1); +} + +} \ No newline at end of file diff --git a/test/bytecode/NewStatementTest.java b/test/bytecode/NewStatementTest.java new file mode 100644 index 00000000..ff692332 --- /dev/null +++ b/test/bytecode/NewStatementTest.java @@ -0,0 +1,55 @@ +package bytecode; + +import static org.junit.Assert.*; + +import java.io.File; +import java.io.IOException; +import java.lang.reflect.Method; +import java.net.URL; +import java.net.URLClassLoader; + +import junit.framework.TestCase; + +import org.junit.Test; + +import plugindevelopment.TypeInsertTester; +import de.dhbwstuttgart.core.MyCompiler; +import de.dhbwstuttgart.core.MyCompilerAPI; +import de.dhbwstuttgart.logger.LoggerConfiguration; +import de.dhbwstuttgart.logger.Section; +import de.dhbwstuttgart.parser.JavaParser.yyException; +import de.dhbwstuttgart.typeinference.ByteCodeResult; +import de.dhbwstuttgart.typeinference.Menge; +import de.dhbwstuttgart.typeinference.TypeinferenceResultSet; +import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet; + +public class NewStatementTest { + + public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/"; + public final static String testFile = "NewStatement.jav"; + public final static String outputFile = "NewStatement.class"; + + @Test + public void test() { + SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory); + } + @Test + public void testUntypedVectorDeclaredMethods() { + try{ + File file = new File(System.getProperty("user.dir")+"/test/bytecode/types/"); + URL url = file.toURL(); + URL[] urls = new URL[]{url}; + + ClassLoader classLoader = new URLClassLoader(urls); + + Class untypedVectorTest = classLoader.loadClass("UntypedVector"); + + for(Method method: untypedVectorTest.getDeclaredMethods()){ + System.out.println(method.toGenericString()); + } + }catch(Exception e){ + throw new RuntimeException(e); + } + } + +} diff --git a/test/bytecode/Test2.java b/test/bytecode/Test2.java new file mode 100644 index 00000000..767f6522 --- /dev/null +++ b/test/bytecode/Test2.java @@ -0,0 +1,6 @@ +class Test2{ + + public static void main(java.lang.String[] args){ + new NewStatement(1).method(); +} +} From 4c908abedeacff4303c2e3eeaa796642cbbbe06d Mon Sep 17 00:00:00 2001 From: JanUlrich Date: Fri, 13 Nov 2015 12:23:45 +0100 Subject: [PATCH 5/5] NewClassCreator --- BCEL/bcelifier/NewClass.java | 9 +++++ BCEL/bcelifier/NewClassCreator.java | 60 +++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 BCEL/bcelifier/NewClass.java create mode 100644 BCEL/bcelifier/NewClassCreator.java diff --git a/BCEL/bcelifier/NewClass.java b/BCEL/bcelifier/NewClass.java new file mode 100644 index 00000000..69181ebc --- /dev/null +++ b/BCEL/bcelifier/NewClass.java @@ -0,0 +1,9 @@ +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 new file mode 100644 index 00000000..3f20eed3 --- /dev/null +++ b/BCEL/bcelifier/NewClassCreator.java @@ -0,0 +1,60 @@ +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")); + } +}