Permalink
Browse files

files for 1st byteman tutorial

  • Loading branch information...
0 parents commit f0fa6ac769fd8d4a4671dfc3ba3dffa400dfef24 @adinn committed Nov 14, 2011
Showing with 98 additions and 0 deletions.
  1. +16 −0 appmain.btm
  2. +11 −0 org/my/AppMain.java
  3. +21 −0 org/my/AppMain2.java
  4. +28 −0 org/my/AppMain3.java
  5. +8 −0 skip.btm
  6. +8 −0 skip2.btm
  7. +6 −0 thread.btm
@@ -0,0 +1,16 @@
+RULE trace main entry
+CLASS AppMain
+METHOD main
+AT ENTRY
+IF TRUE
+DO traceln("entering main")
+ENDRULE
+
+
+RULE trace main exit
+CLASS AppMain
+METHOD main
+AT EXIT
+IF TRUE
+DO traceln("exiting main")
+ENDRULE
@@ -0,0 +1,11 @@
+package org.my;
+
+class AppMain
+{
+ public static void main(String[] args)
+ {
+ for (int i = 0; i < args.length; i++) {
+ System.out.println(args[i]);
+ }
+ }
+}
@@ -0,0 +1,21 @@
+package org.my;
+
+class AppMain2
+{
+ public static void main(String[] args)
+ {
+ for (int i = 0; i < args.length; i++) {
+ final String arg = args[i];
+ Thread thread = new Thread(arg) {
+ public void run() {
+ System.out.println(arg);
+ }
+ };
+ thread.start();
+ try {
+ thread.join();
+ } catch (Exception e){
+ }
+ }
+ }
+}
@@ -0,0 +1,28 @@
+package org.my;
+import java.io.DataInputStream;
+
+class AppMain3
+{
+ public static void main(String[] args)
+ {
+ try {
+ DataInputStream in = new DataInputStream(System.in);
+ String next = in.readLine();
+ while (next != null && next.length() > 0 && !next.contains("end")) {
+ final String arg = next;
+ Thread thread = new Thread(arg) {
+ public void run() {
+ System.out.println(arg);
+ }
+ };
+ thread.start();
+ try {
+ thread.join();
+ } catch (Exception e){
+ }
+ next = in.readLine();
+ }
+ } catch (Exception e) {
+ }
+ }
+}
@@ -0,0 +1,8 @@
+RULE skip loop iteration
+CLASS AppMain2
+METHOD main
+AFTER CALL join
+IF TRUE
+DO $i = $i + 1 ;
+ traceln("skipping iteration " + $i)
+ENDRULE
@@ -0,0 +1,8 @@
+RULE skip loop iteration
+CLASS AppMain2
+METHOD main
+AFTER CALL join
+IF ($args[$i]).contains("foo")
+DO $i = $i + 1 ;
+ traceln("skipping iteration " + $i)
+ENDRULE
@@ -0,0 +1,6 @@
+RULE trace thread start
+CLASS java.lang.Thread
+METHOD start()
+IF true
+DO traceln("*** start for thread " + $0.getName())
+ENDRULE

0 comments on commit f0fa6ac

Please sign in to comment.