diff --git a/lib/commons-bcel6-6.0-SNAPSHOT.jar b/lib/commons-bcel6-6.0-SNAPSHOT.jar index d1d1b6079..11dcfef95 100644 Binary files a/lib/commons-bcel6-6.0-SNAPSHOT.jar and b/lib/commons-bcel6-6.0-SNAPSHOT.jar differ diff --git a/notizen/stan/stackmaptable/Notizen.md b/notizen/stan/stackmaptable/Notizen.md index 6090e1f8e..a86ff0c24 100644 --- a/notizen/stan/stackmaptable/Notizen.md +++ b/notizen/stan/stackmaptable/Notizen.md @@ -10,6 +10,12 @@ ## BCEL Patch https://issues.apache.org/jira/browse/BCEL-268 +* Submitting patch: https://commons.apache.org/patches.html +### Änderungen im BCEL-Projekt +* Neue Datei StackMapTableGen +* Testen TODO: + * Mittels BCELifier Code generieren lassen, welcher Methoden erstellt, die Branches enthalten + * Dies dann dem StackMapTableGen übergeben und auf das erstellen von StackMapEntries abprüfen # Literatur * Zu JVM allgemein: http://blog.jamesdbloom.com/JVMInternals.html diff --git a/notizen/stan/stackmaptable/StackMapTest5.java b/notizen/stan/stackmaptable/StackMapTest5.java new file mode 100644 index 000000000..d5a3b9789 --- /dev/null +++ b/notizen/stan/stackmaptable/StackMapTest5.java @@ -0,0 +1,12 @@ +class StackMapTest5{ + +void methode(){ +int i = 0; +while(System.out == null){ +i+=1; +while(true){ +String s = "2"; +} +} +} +} diff --git a/src/de/dhbwstuttgart/bytecode/ClassGenerator.java b/src/de/dhbwstuttgart/bytecode/ClassGenerator.java index 8e2a86d19..a13ed9145 100644 --- a/src/de/dhbwstuttgart/bytecode/ClassGenerator.java +++ b/src/de/dhbwstuttgart/bytecode/ClassGenerator.java @@ -95,7 +95,7 @@ public class ClassGenerator extends ClassGen{ int innerClassesUTF8 = this.getConstantPool().addUtf8("InnerClasses"); this.addAttribute(new InnerClasses(innerClassesUTF8,numberOfInnerClasses*8+2,innerClasses,this.getConstantPool().getConstantPool())); } - + public int addBootstrapMethod(BootstrapMethod bMethod) { int numberOfBootstrapMethods = 1; int name_index = this.getConstantPool().addUtf8("BootstrapMethods"); diff --git a/src/de/dhbwstuttgart/bytecode/MethodGenerator.java b/src/de/dhbwstuttgart/bytecode/MethodGenerator.java index d92bd1cce..887766cec 100644 --- a/src/de/dhbwstuttgart/bytecode/MethodGenerator.java +++ b/src/de/dhbwstuttgart/bytecode/MethodGenerator.java @@ -18,6 +18,7 @@ import org.apache.commons.bcel6.generic.ConstantPoolGen; import org.apache.commons.bcel6.generic.Instruction; import org.apache.commons.bcel6.generic.InstructionList; import org.apache.commons.bcel6.generic.MethodGen; +import org.apache.commons.bcel6.generic.StackMapTableGen; import org.apache.commons.bcel6.generic.Type; import org.apache.commons.bcel6.Const; @@ -72,36 +73,13 @@ public class MethodGenerator extends MethodGen{ String retTypeSig = retType.getBytecodeSignature(cg, rs); method.addAttribute(factory.createSignatureAttribute(paramTypesSig+retTypeSig)); - StackMap stackMap = this.generateStackMapFrame(); + + StackMap stackMap = new StackMapTableGen(this.getInstructionList(), cp).getStackMap(); if(stackMap != null)method.addCodeAttribute(stackMap); return method.getMethod(); } - /** - * - * @return null - falls kein StackMapFrame für die Methode notwendig ist - */ - private StackMap generateStackMapFrame(){ - int length=2; //+2 wegen NumberOfEntries - Menge entries = CodeHelper.getStackMapEntries(getInstructionList(), cp); - if(entries.size()==0)return null; - StackMapEntry[] entryArray = new StackMapEntry[entries.size()]; - for(int i = 0; i outputStack = new ArrayList<>(); - /** - * Pushes a new type onto the output frame stack. - * - * @param type - * the type that must be pushed. - */ - private void push(final int type) { - outputStack.add(type); - } - /** * Generiert die StackMapEntrys zu einer gegebenen Methode * @param forCode @@ -177,10 +171,9 @@ public class CodeHelper { Instruction[] instructions = forCode.getInstructions(); InstructionHandle[] instructionHandles = forCode.getInstructionHandles(); int lastPosition = 0; - for(int i = 0; i test; + + void method(){ + method(test); + } + + void method(Vector v) { + + } + + void method(Vector v) { + + } +} \ No newline at end of file