From b069bb7b8fa6e3ebc183b6963e29026cab880344 Mon Sep 17 00:00:00 2001
From: JanUlrich <andi@michlaustderaffe.de>
Date: Tue, 12 Jan 2016 13:32:16 +0100
Subject: [PATCH] StackMapTable Notizen

---
 notizen/stan/lambdaBytecode/Notizen.md        |   6 +
 notizen/stan/lambdaBytecode/cat               | 104 ------------------
 notizen/stan/stackmaptable/.Notizen.md.swp    | Bin 0 -> 12288 bytes
 notizen/stan/stackmaptable/Notizen.md         |  10 ++
 notizen/stan/stackmaptable/StackMapTest.java  |   6 +
 notizen/stan/stackmaptable/StackMapTest2.java |   8 ++
 notizen/stan/stackmaptable/StackMapTest3.java |  14 +++
 7 files changed, 44 insertions(+), 104 deletions(-)
 delete mode 100644 notizen/stan/lambdaBytecode/cat
 create mode 100644 notizen/stan/stackmaptable/.Notizen.md.swp
 create mode 100644 notizen/stan/stackmaptable/Notizen.md
 create mode 100644 notizen/stan/stackmaptable/StackMapTest.java
 create mode 100644 notizen/stan/stackmaptable/StackMapTest2.java
 create mode 100644 notizen/stan/stackmaptable/StackMapTest3.java

diff --git a/notizen/stan/lambdaBytecode/Notizen.md b/notizen/stan/lambdaBytecode/Notizen.md
index 661abd821..c234266bd 100644
--- a/notizen/stan/lambdaBytecode/Notizen.md
+++ b/notizen/stan/lambdaBytecode/Notizen.md
@@ -35,3 +35,9 @@
 # TODO:
 * Matrix Beispiel muss funktionieren (verschachtelter Lambda Ausdruck)
 * Automatisch Bytecode generieren, wenn alle Typen eingesetzt sind
+
+## StackMapTable
+* Attribute für Codeattribut
+* Wird für Sprünge im Bytecode benötigt
+* Quelle: https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.7.4
+
diff --git a/notizen/stan/lambdaBytecode/cat b/notizen/stan/lambdaBytecode/cat
deleted file mode 100644
index f886214b1..000000000
--- a/notizen/stan/lambdaBytecode/cat
+++ /dev/null
@@ -1,104 +0,0 @@
-Classfile /home/janulrich/Development/eclipseworkspace/JavaCompilerCore/notizen/stan/lambdaBytecode/Lambda1.class
-  Last modified 20.08.2015; size 903 bytes
-  MD5 checksum acb53c553588f3c919f2b0e6359bbd94
-class Lambda1
-  InnerClasses:
-       public static final #46= #45 of #49; //Lookup=class java/lang/invoke/MethodHandles$Lookup of class java/lang/invoke/MethodHandles
-  BootstrapMethods:
-    0: #18 invokestatic java/lang/invoke/LambdaMetafactory.metafactory:(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite;
-      Method arguments:
-        #19 ()V
-        #20 invokestatic Lambda1.lambda$methode$0:()V
-        #19 ()V
-  minor version: 0
-  major version: 52
-  flags: ACC_SUPER
-Constant pool:
-   #1 = Methodref          #8.#16         //  java/lang/Object."<init>":()V
-   #2 = InvokeDynamic      #0:#21         //  #0:run:()Ljava/lang/Runnable;
-   #3 = Methodref          #7.#22         //  Lambda1.methode:()Ljava/lang/Runnable;
-   #4 = InterfaceMethodref #23.#24        //  java/lang/Runnable.run:()V
-   #5 = Fieldref           #25.#26        //  java/lang/System.out:Ljava/io/PrintStream;
-   #6 = Methodref          #27.#28        //  java/io/PrintStream.println:()V
-   #7 = Class              #29            //  Lambda1
-   #8 = Class              #30            //  java/lang/Object
-   #9 = Utf8               <init>
-  #10 = Utf8               ()V
-  #11 = Utf8               Code
-  #12 = Utf8               methode
-  #13 = Utf8               ()Ljava/lang/Runnable;
-  #14 = Utf8               methode2
-  #15 = Utf8               lambda$methode$0
-  #16 = NameAndType        #9:#10         //  "<init>":()V
-  #17 = Utf8               BootstrapMethods
-  #18 = MethodHandle       #6:#31         //  invokestatic java/lang/invoke/LambdaMetafactory.metafactory:(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite;
-  #19 = MethodType         #10            //  ()V
-  #20 = MethodHandle       #6:#32         //  invokestatic Lambda1.lambda$methode$0:()V
-  #21 = NameAndType        #33:#13        //  run:()Ljava/lang/Runnable;
-  #22 = NameAndType        #12:#13        //  methode:()Ljava/lang/Runnable;
-  #23 = Class              #34            //  java/lang/Runnable
-  #24 = NameAndType        #33:#10        //  run:()V
-  #25 = Class              #35            //  java/lang/System
-  #26 = NameAndType        #36:#37        //  out:Ljava/io/PrintStream;
-  #27 = Class              #38            //  java/io/PrintStream
-  #28 = NameAndType        #39:#10        //  println:()V
-  #29 = Utf8               Lambda1
-  #30 = Utf8               java/lang/Object
-  #31 = Methodref          #40.#41        //  java/lang/invoke/LambdaMetafactory.metafactory:(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite;
-  #32 = Methodref          #7.#42         //  Lambda1.lambda$methode$0:()V
-  #33 = Utf8               run
-  #34 = Utf8               java/lang/Runnable
-  #35 = Utf8               java/lang/System
-  #36 = Utf8               out
-  #37 = Utf8               Ljava/io/PrintStream;
-  #38 = Utf8               java/io/PrintStream
-  #39 = Utf8               println
-  #40 = Class              #43            //  java/lang/invoke/LambdaMetafactory
-  #41 = NameAndType        #44:#48        //  metafactory:(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite;
-  #42 = NameAndType        #15:#10        //  lambda$methode$0:()V
-  #43 = Utf8               java/lang/invoke/LambdaMetafactory
-  #44 = Utf8               metafactory
-  #45 = Class              #50            //  java/lang/invoke/MethodHandles$Lookup
-  #46 = Utf8               Lookup
-  #47 = Utf8               InnerClasses
-  #48 = Utf8               (Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite;
-  #49 = Class              #51            //  java/lang/invoke/MethodHandles
-  #50 = Utf8               java/lang/invoke/MethodHandles$Lookup
-  #51 = Utf8               java/lang/invoke/MethodHandles
-{
-  Lambda1();
-    Signature: ()V
-    flags: 
-    Code:
-      stack=1, locals=1, args_size=1
-         0: aload_0       
-         1: invokespecial #1                  // Method java/lang/Object."<init>":()V
-         4: return        
-
-  java.lang.Runnable methode();
-    Signature: ()Ljava/lang/Runnable;
-    flags: 
-    Code:
-      stack=1, locals=1, args_size=1
-         0: invokedynamic #2,  0              // InvokeDynamic #0:run:()Ljava/lang/Runnable;
-         5: areturn       
-
-  void methode2();
-    Signature: ()V
-    flags: 
-    Code:
-      stack=1, locals=1, args_size=1
-         0: aload_0       
-         1: invokevirtual #3                  // Method methode:()Ljava/lang/Runnable;
-         4: invokeinterface #4,  1            // InterfaceMethod java/lang/Runnable.run:()V
-         9: return        
-
-  private static void lambda$methode$0();
-    Signature: ()V
-    flags: ACC_PRIVATE, ACC_STATIC, ACC_SYNTHETIC
-    Code:
-      stack=1, locals=0, args_size=0
-         0: getstatic     #5                  // Field java/lang/System.out:Ljava/io/PrintStream;
-         3: invokevirtual #6                  // Method java/io/PrintStream.println:()V
-         6: return        
-}
diff --git a/notizen/stan/stackmaptable/.Notizen.md.swp b/notizen/stan/stackmaptable/.Notizen.md.swp
new file mode 100644
index 0000000000000000000000000000000000000000..61f9c4c6b94a9d15a3f68cac30587a71205236da
GIT binary patch
literal 12288
zcmeI&&2H2%5CCA86BG&vUSP`JswQc-Mg6%TSR_=WB0-^?9cOmqZepjllc*fvC3pwk
zpr_vUz@0M}-hfA7k}gG{ihI?GG;w~M@yvIP)3w9Beb|aO1s(T=Sp5F^@QDcG=B^M&
z($t01D(~L?=P0a_MQ(kF`>V{BQkzTWf4oSTJjVtLTa{=+f~wG!$JV;3ucX4{rEKKL
zmX$8hjjY4O*q}e4Nqms~Nli;x1(_C@ygGjsm)Ru?@*@^tfpdX6jHB%(u`yg<>mCdq
zEyKeH?^uTgSbzmsfCX591z3OuSl}87gla*2qJD48dtRK63;&GsTOL?|1z3OuSbzms
zfCX591z3OuSbzntpn#<R=3keDxP6z3@BaVKd-!=zh;I~MC=MvzP>d*k(7Y3hI~4sl
zSFmR;nFUyY1z3OuSbzmsfCX591+KHetrZXydjYfuT@*Nx1q2JZY!H;q5ac+Z18JZ(
z%9>0EZ4J#yoir+kR)^fy0VL2SZ8ZhjpbcXuON11)nLy=iqchB4Y#rzjixtR2sQhly
z?dn!j+n^g4wvCl7lj9nFm)<AC&7I-a&dx^C<}yT6ZL-LYqa)fN9(6@U4v%Z?&_{g|
zS~Thx^#l5FW9{*9oz^+%^6$&)ZMR_@rn6IH0>T6hI*l$si!MX63X~j6&?TfN0sEFG
z=v6MMt5&;g6<P}im7ATJ2|{CCp^=irVlaRg^JKM|2wL%VjU>2x(P3tlkFArcz`nn(
zevgT-Q2FGjDShH`JIO;?^mox_++7d4H+0=?&R>D|R051=XYNl8RO++erKV_Rr$J8w
YO??`I(`ijj_VY&sCFhUC;BOA`3l!J&lK=n!

literal 0
HcmV?d00001

diff --git a/notizen/stan/stackmaptable/Notizen.md b/notizen/stan/stackmaptable/Notizen.md
new file mode 100644
index 000000000..4050403ec
--- /dev/null
+++ b/notizen/stan/stackmaptable/Notizen.md
@@ -0,0 +1,10 @@
+# StackMapTable
+* Attribute für Codeattribut
+* Wird für Sprünge im Bytecode benötigt
+* Quelle: https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.7.4
+
+## Generierung
+* StackMapTable könnte generiert werden, indem im bytecode geschaut wird, wo Sprünge vorliegen.
+* https://stackoverflow.com/questions/24927993/what-kind-of-java-code-requires-stackmap-frames#24930521
+	* It is illegal to have code after an unconditional branch without a stack map frame being provided for it.
+
diff --git a/notizen/stan/stackmaptable/StackMapTest.java b/notizen/stan/stackmaptable/StackMapTest.java
new file mode 100644
index 000000000..b2e02b35c
--- /dev/null
+++ b/notizen/stan/stackmaptable/StackMapTest.java
@@ -0,0 +1,6 @@
+class StackMapTest{
+
+void methode(){
+while(true){}
+}
+}
diff --git a/notizen/stan/stackmaptable/StackMapTest2.java b/notizen/stan/stackmaptable/StackMapTest2.java
new file mode 100644
index 000000000..b0851b004
--- /dev/null
+++ b/notizen/stan/stackmaptable/StackMapTest2.java
@@ -0,0 +1,8 @@
+class StackMapTest2{
+
+void methode(){
+Integer i = 1;
+while(System.out == null){
+i+=1;}
+}
+}
diff --git a/notizen/stan/stackmaptable/StackMapTest3.java b/notizen/stan/stackmaptable/StackMapTest3.java
new file mode 100644
index 000000000..420ac3c66
--- /dev/null
+++ b/notizen/stan/stackmaptable/StackMapTest3.java
@@ -0,0 +1,14 @@
+class StackMapTest3{
+
+void methode(){
+Integer i = 1;
+while(System.out == null){
+i+=1;
+}
+System.out.println(i);
+StackMapTest3 o = new StackMapTest3();
+while(i<0){
+i++;
+}
+}
+}