Bug fix where two isolated heap regions with empty reachability sets have
[IRC.git] / Robust / src / Tests / OwnershipAnalysisTest / test01 / test01.java
index 088fd08486284d8032cfa31f3108353212a2f208..77510319076c93dc45d50d32db42ea954f5b350c 100644 (file)
-/*
-public class Parameter {
-    flag w;
-    int a, b;
-    Parameter f, g;
-    Penguin p;
-    Foo h;
 
-    public Parameter() { a = 0; b = 0; f = null; g = null; }
+public class Parameter {
+  flag w;
+  int a;
+  int b;
+  //Parameter f;
+  //Parameter g;
+  //Penguin p;
+  //Foo h;
+  
+  public Parameter() {} // a = 0; b = 0; f = null; g = null; }
+  
+  //public void bar() { foo(); }
+  //public void foo() { bar(); }
+
+  static public void proof( Fooz p0, Fooz p1 ) {
+    Fooz c = new Fooz();
+    Fooz d = new Fooz();
+
+    c.x  = d;
+    p0.x = c;
+    p1.x = d;
+  }
+}
 
-    public void bar() { foo(); }
-    public void foo() { bar(); }
+public class Fooz {
+  public Fooz() {}
+  public Fooz x;
 }
 
+/*
 public class Penguin {
-    int x, y;
-    Foo h;    
-
-    public Penguin() { x = 0; y = 0; }
-
-    public void bar() { x = 1; }
+  int x;
+  int y;
+  Foo h;    
+  
+  public Penguin() { x = 0; y = 0; }
+  
+  public void bar() { x = 1; }
 }
 
 public class Voo {
-    flag f; int x; Baw b; Baw bb;
-
-    public Voo() {}
+  flag f; int x; Baw b; Baw bb;
+  
+  public Voo() {}
+  
+  static Voo getAVoo( Voo bogus ) {
+    while( false ) {
+      if( false ) {
+       return new Voo();
+      } else {
+       return new Voo();
+      }
+    }
+    return new Voo();
+  }
 }
 
 public class Baw {
-    int y;
-    Foo f;
+  int y;
+  Foo f;
+  String s;
 
-    public Baw() {}
-
-    public void doTheBaw( Voo v ) { v = new Voo(); }
+  public Baw() {}
+  
+  public void doTheBaw( Voo v ) { v = new Voo(); }
 }
-*/
-
-public class Foo {
-    flag f;
-
-    public Foo() {}
 
-    public Foo x;
-    public Foo y;
-    public Foo z;
 
-    /*
-    public void ruinSomeFoos( Foo a, Foo b ) {
-       a.x = b.x;
-    }
-
-    static public void aStaticMethod( Foo p0, Foo p1 ) {
-       Foo f0 = new Foo();
-       Foo f1 = new Foo();
-       Foo f2 = new Foo();
+public class Foo {
+  flag f;
+  
+  public Foo() {}
+  
+  public Foo x;
+  public Foo y;
+  public Foo z;
+  public Baw b;
+
+  public Foo getAFoo() {
+    return new Foo();
+  }
 
-       f0.x = f1;
-       p0.x = f0;
-       p1.x = f1;
-       p1.x = f2;
-    }
-    */
+  public Foo newFooChain( Foo a ) {
+    Foo b = new Foo();
+    b.x = a;
+    return b;
+  }
 
+  public void ruinSomeFoos( Foo a, Foo b ) {
+    a.x = b.x;
+  }
+  
+  static public void aStaticMethod( Foo p0, Foo p1 ) {
+    Foo f0 = new Foo();
+    Foo f1 = new Foo();
+    Foo f2 = new Foo();
+    
+    f0.x = f1;
+    p0.x = f0;
+    p1.x = f1;
+    p1.x = f2;
+  }
+  
   static public void m1_( Foo p0 ) {
     Foo g0 = new Foo();
     Foo g1 = new Foo();
-
+    
     g0.x = p0;
     p0.x = g1;
   }
 
   static public void m2_( Foo p0 ) {
     Foo g0 = new Foo();
-
+    
     g0.x = p0;
     g0.y = p0;
   }
-
+  
   static public void m3_( Foo p0 ) {
     Foo g0 = new Foo();
-
+    
     p0.x = g0;
     p0.y = g0;
   }
@@ -142,6 +181,7 @@ public class Foo {
     p1.y = p0;
   }
 }
+*/
 
 
 // this empty task should still create a non-empty
@@ -149,9 +189,26 @@ public class Foo {
 // look for the parameter s as a label referencing
 // a heap region that is multi-object, flagged, not summary
 task Startup( StartupObject s{ initialstate } ) {
-    taskexit( s{ !initialstate } );
+
+  //Parameter p0 = new Parameter();
+
+  //int a, b, c;
+
+  Parameter.proof( null, null );
+
+  /*
+  int a = 1;
+  int b = 2;
+  int c = 3;
+
+  b = c;
+  a = b;
+  */
+
+  taskexit( s{ !initialstate } );
 }
 
+
 /*
 task NewObjectA( Foo a{ f }, Foo b{ f } ) {
 
@@ -164,6 +221,7 @@ task NewObjectA( Foo a{ f }, Foo b{ f } ) {
     taskexit( a{ !f }, b{ !f } );
 }
 
+
 task NewObjectB( Foo a{ f }, Foo b{ f } ) {
 
     Foo c = new Foo();
@@ -174,9 +232,8 @@ task NewObjectB( Foo a{ f }, Foo b{ f } ) {
 
     taskexit( a{ !f }, b{ !f } );
 }
-*/
 
-/*
+
 task NewObjectC( Foo a{ f }, Foo b{ f } ) {
 
     Foo z = new Foo();
@@ -194,9 +251,8 @@ task NewObjectC( Foo a{ f }, Foo b{ f } ) {
 
     taskexit( a{ !f }, b{ !f } );
 }
-*/
 
-/*
+
 task forMethod( Foo p0{ f } ) {
 
     Foo a0;
@@ -216,10 +272,8 @@ task forMethod( Foo p0{ f } ) {
 
     taskexit( p0{ !f } );
 }
-*/
 
 
-/*
 // this task allocates a new object, so there should
 // be a heap region for the parameter, and several
 // heap regions for the allocation site, but the label
@@ -310,6 +364,74 @@ task strongUpdates( Foo p0{ f } ) {
 }
 
 
+task ObjectChainByMethodCalls( Foo a{ f } ) {
+
+  Foo f = a.getAFoo();
+  Foo g = a.newFooChain( f );
+  // g -> f
+
+  taskexit( a{ !f } );
+}
+
+
+task arrayAssignments( Foo a{ f } ) {
+
+  Foo f[] = new Foo[3];
+
+  Foo g = new Foo();
+  Foo h = new Foo();
+
+  f[1] = g;
+  f[2] = h;
+
+  Foo i = f[0];
+
+  taskexit( a{ !f } );
+}
+
+
+public class Zool {
+  public Zool() {}
+
+  public static void FooToBaw( Baw x, Foo y ) {
+    x.f.b = y.b;
+  }
+}
+
+task showPrunedEdgesInMethodCall( Foo a{ f } ) {
+
+  Foo b = new Foo();
+  b.x   = a;
+  b.y   = new Foo();
+  b.b   = new Baw();
+
+  Baw c = new Baw();
+  c.f   = new Foo();
+  c.f.b = new Baw();
+  
+  Zool.FooToBaw( c, b );
+
+  taskexit( a{ !f } );
+}
+
+task showStringIsImmutable( Foo a{ f } ) {
+
+  Baw x = new Baw();
+  Baw y = new Baw();
+
+  Foo f = new Foo();
+  String s = new String();
+
+  x.f = f;
+  y.f = f;
+
+  x.s = s;
+  y.s = s;
+
+  taskexit( a{ !f } );
+}
+
+
 task methodTest( Foo p0{ f } ) {
 
     Foo up0 = new Foo();
@@ -342,9 +464,16 @@ task methodTest( Foo p0{ f } ) {
 
     taskexit( p0{ !f } );
 }
-*/
 
 
+task getNewFromMethod( Foo p0{ f } ) { 
+  Voo g = Voo.getAVoo( null );
+
+  taskexit( p0{ !f } );
+}
+*/
+
+/*
 task methodTest01_( Foo p0{ f }, Foo p1{ f } ) {
 
   Foo a0before = new Foo();
@@ -366,8 +495,9 @@ task methodTest01_( Foo p0{ f }, Foo p1{ f } ) {
 
   taskexit( p0{ !f }, p1{ !f } );
 }
+*/
 
-
+/*
 task methodTest02_( Foo p0{ f }, Foo p1{ f } ) {
 
   Foo a0before = new Foo();
@@ -569,3 +699,4 @@ task methodTest08_( Foo p0{ f }, Foo p1{ f } ) {
 
   taskexit( p0{ !f }, p1{ !f } );
 }
+*/