From c181f333105f388cc14f9b9fe9281e4c04c2aaac Mon Sep 17 00:00:00 2001 From: dolby-oss Date: Tue, 16 Dec 2008 15:14:00 +0000 Subject: [PATCH] move CAst Java test data to separate project to ease use in plugin tests git-svn-id: https://wala.svn.sourceforge.net/svnroot/wala/trunk@3139 f5eafffb-2e1d-0410-98e4-8ec43c5233c4 --- com.ibm.wala.cast.java.test.data/.classpath | 8 ++ com.ibm.wala.cast.java.test.data/.project | 28 ++++ .../.settings/org.eclipse.jdt.core.prefs | 7 + .../Java60RegressionExclusions.txt | 6 + .../META-INF/MANIFEST.MF | 10 ++ .../build.properties | 4 + .../src/AnonymousClass.java | 46 +++++++ .../src/Array1.java | 19 +++ .../src/ArrayLiteral1.java | 8 ++ .../src/ArrayLiteral2.java | 7 + .../src/Breaks.java | 35 +++++ .../src/CastFromNull.java | 7 + .../src/Casts.java | 27 ++++ .../src/DefaultConstructors.java | 61 +++++++++ .../src/Exception1.java | 37 ++++++ .../src/Exception2.java | 41 ++++++ .../src/Finally1.java | 25 ++++ .../src/Finally2.java | 29 ++++ .../src/FunkySupers.java | 28 ++++ .../src/Inheritance1.java | 28 ++++ .../src/InheritedField.java | 20 +++ .../src/InnerClass.java | 49 +++++++ .../src/InnerClassA.java | 125 ++++++++++++++++++ .../src/InnerClassLexicalReads.java | 47 +++++++ .../src/InnerClassSuper.java | 19 +++ .../src/InterfaceTest1.java | 21 +++ .../src/LocalClass.java | 33 +++++ .../src/MiniaturList.java | 53 ++++++++ .../src/MiniaturSliceBug.java | 73 ++++++++++ .../src/Monitor.java | 11 ++ .../src/Monitor2.java | 15 +++ .../src/NullArrayInit.java | 15 +++ .../src/QualifiedStatic.java | 10 ++ .../src/Scoping1.java | 13 ++ .../src/Scoping2.java | 18 +++ .../src/Simple1.java | 31 +++++ .../src/SimpleCalls.java | 22 +++ .../src/StaticInit.java | 31 +++++ .../src/StaticNesting.java | 12 ++ .../src/Switch1.java | 42 ++++++ .../src/Thread1.java | 26 ++++ .../src/TwoClasses.java | 40 ++++++ .../src/WelcomeInitializers.java | 24 ++++ .../src/WhileTest1.java | 20 +++ .../wala/cast/java/test/data/Activator.java | 50 +++++++ .../src/fetch_tests.sh | 25 ++++ 46 files changed, 1306 insertions(+) create mode 100644 com.ibm.wala.cast.java.test.data/.classpath create mode 100644 com.ibm.wala.cast.java.test.data/.project create mode 100644 com.ibm.wala.cast.java.test.data/.settings/org.eclipse.jdt.core.prefs create mode 100644 com.ibm.wala.cast.java.test.data/Java60RegressionExclusions.txt create mode 100644 com.ibm.wala.cast.java.test.data/META-INF/MANIFEST.MF create mode 100644 com.ibm.wala.cast.java.test.data/build.properties create mode 100644 com.ibm.wala.cast.java.test.data/src/AnonymousClass.java create mode 100644 com.ibm.wala.cast.java.test.data/src/Array1.java create mode 100644 com.ibm.wala.cast.java.test.data/src/ArrayLiteral1.java create mode 100644 com.ibm.wala.cast.java.test.data/src/ArrayLiteral2.java create mode 100644 com.ibm.wala.cast.java.test.data/src/Breaks.java create mode 100644 com.ibm.wala.cast.java.test.data/src/CastFromNull.java create mode 100644 com.ibm.wala.cast.java.test.data/src/Casts.java create mode 100644 com.ibm.wala.cast.java.test.data/src/DefaultConstructors.java create mode 100644 com.ibm.wala.cast.java.test.data/src/Exception1.java create mode 100644 com.ibm.wala.cast.java.test.data/src/Exception2.java create mode 100644 com.ibm.wala.cast.java.test.data/src/Finally1.java create mode 100644 com.ibm.wala.cast.java.test.data/src/Finally2.java create mode 100644 com.ibm.wala.cast.java.test.data/src/FunkySupers.java create mode 100644 com.ibm.wala.cast.java.test.data/src/Inheritance1.java create mode 100644 com.ibm.wala.cast.java.test.data/src/InheritedField.java create mode 100644 com.ibm.wala.cast.java.test.data/src/InnerClass.java create mode 100644 com.ibm.wala.cast.java.test.data/src/InnerClassA.java create mode 100644 com.ibm.wala.cast.java.test.data/src/InnerClassLexicalReads.java create mode 100644 com.ibm.wala.cast.java.test.data/src/InnerClassSuper.java create mode 100644 com.ibm.wala.cast.java.test.data/src/InterfaceTest1.java create mode 100644 com.ibm.wala.cast.java.test.data/src/LocalClass.java create mode 100644 com.ibm.wala.cast.java.test.data/src/MiniaturList.java create mode 100644 com.ibm.wala.cast.java.test.data/src/MiniaturSliceBug.java create mode 100644 com.ibm.wala.cast.java.test.data/src/Monitor.java create mode 100644 com.ibm.wala.cast.java.test.data/src/Monitor2.java create mode 100644 com.ibm.wala.cast.java.test.data/src/NullArrayInit.java create mode 100644 com.ibm.wala.cast.java.test.data/src/QualifiedStatic.java create mode 100644 com.ibm.wala.cast.java.test.data/src/Scoping1.java create mode 100644 com.ibm.wala.cast.java.test.data/src/Scoping2.java create mode 100644 com.ibm.wala.cast.java.test.data/src/Simple1.java create mode 100644 com.ibm.wala.cast.java.test.data/src/SimpleCalls.java create mode 100644 com.ibm.wala.cast.java.test.data/src/StaticInit.java create mode 100644 com.ibm.wala.cast.java.test.data/src/StaticNesting.java create mode 100644 com.ibm.wala.cast.java.test.data/src/Switch1.java create mode 100644 com.ibm.wala.cast.java.test.data/src/Thread1.java create mode 100644 com.ibm.wala.cast.java.test.data/src/TwoClasses.java create mode 100644 com.ibm.wala.cast.java.test.data/src/WelcomeInitializers.java create mode 100644 com.ibm.wala.cast.java.test.data/src/WhileTest1.java create mode 100644 com.ibm.wala.cast.java.test.data/src/com/ibm/wala/cast/java/test/data/Activator.java create mode 100755 com.ibm.wala.cast.java.test.data/src/fetch_tests.sh diff --git a/com.ibm.wala.cast.java.test.data/.classpath b/com.ibm.wala.cast.java.test.data/.classpath new file mode 100644 index 000000000..5836c8d8e --- /dev/null +++ b/com.ibm.wala.cast.java.test.data/.classpath @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/com.ibm.wala.cast.java.test.data/.project b/com.ibm.wala.cast.java.test.data/.project new file mode 100644 index 000000000..24acf0364 --- /dev/null +++ b/com.ibm.wala.cast.java.test.data/.project @@ -0,0 +1,28 @@ + + + com.ibm.wala.cast.java.test.data + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.pde.PluginNature + + diff --git a/com.ibm.wala.cast.java.test.data/.settings/org.eclipse.jdt.core.prefs b/com.ibm.wala.cast.java.test.data/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..a1ef38d20 --- /dev/null +++ b/com.ibm.wala.cast.java.test.data/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,7 @@ +#Thu Dec 11 09:45:37 EST 2008 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.5 diff --git a/com.ibm.wala.cast.java.test.data/Java60RegressionExclusions.txt b/com.ibm.wala.cast.java.test.data/Java60RegressionExclusions.txt new file mode 100644 index 000000000..eb4f198ce --- /dev/null +++ b/com.ibm.wala.cast.java.test.data/Java60RegressionExclusions.txt @@ -0,0 +1,6 @@ +java\/awt\/.* +javax\/swing\/.* +sun\/awt\/.* +sun\/swing\/.* +com\/sun\/.* +sun\/.* diff --git a/com.ibm.wala.cast.java.test.data/META-INF/MANIFEST.MF b/com.ibm.wala.cast.java.test.data/META-INF/MANIFEST.MF new file mode 100644 index 000000000..6108acc35 --- /dev/null +++ b/com.ibm.wala.cast.java.test.data/META-INF/MANIFEST.MF @@ -0,0 +1,10 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Data Plug-in +Bundle-SymbolicName: com.ibm.wala.cast.java.test.data +Bundle-Version: 1.0.0 +Bundle-Activator: com.ibm.wala.cast.java.test.data.Activator +Bundle-Vendor: IBM +Require-Bundle: org.eclipse.core.runtime +Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Bundle-ActivationPolicy: lazy diff --git a/com.ibm.wala.cast.java.test.data/build.properties b/com.ibm.wala.cast.java.test.data/build.properties new file mode 100644 index 000000000..34d2e4d2d --- /dev/null +++ b/com.ibm.wala.cast.java.test.data/build.properties @@ -0,0 +1,4 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + . diff --git a/com.ibm.wala.cast.java.test.data/src/AnonymousClass.java b/com.ibm.wala.cast.java.test.data/src/AnonymousClass.java new file mode 100644 index 000000000..1792d0c1b --- /dev/null +++ b/com.ibm.wala.cast.java.test.data/src/AnonymousClass.java @@ -0,0 +1,46 @@ +public class AnonymousClass { + private interface Foo { + public int getValue(); + public int getValueBase(); + } + + public static void main(String[] args) { + final Integer base = new Integer(6); + + Foo f= new Foo() { + int value = 3; + public int getValue() { return value; } + public int getValueBase() { return value - base.intValue(); } + }; + + System.out.println(f.getValue()); + System.out.println(f.getValueBase()); + + (new AnonymousClass()).method(); + } + + public void method() { + final Integer base = new Integer(7); + + abstract class FooImpl implements Foo { + int y; + + public abstract int getValue(); + + FooImpl(int _y) { + y = _y; + } + + public int getValueBase() { + return y + getValue() - base.intValue(); + } + } + + Foo f= new FooImpl(-4) { + public int getValue() { return 7; } + }; + + System.out.println(f.getValue()); + System.out.println(f.getValueBase()); + } +} diff --git a/com.ibm.wala.cast.java.test.data/src/Array1.java b/com.ibm.wala.cast.java.test.data/src/Array1.java new file mode 100644 index 000000000..ced3334c2 --- /dev/null +++ b/com.ibm.wala.cast.java.test.data/src/Array1.java @@ -0,0 +1,19 @@ +public class Array1 { + public static void main(String[] args) { + Array1 f= new Array1(); + f.foo(); + } + public void foo() { + int[] ary = new int[5]; + + for(int i= 0; i < ary.length; i++) { + ary[i]= i; + } + + int sum = 0; + + for(int j= 0; j < ary.length; j++) { + sum += ary[j]; + } + } +} \ No newline at end of file diff --git a/com.ibm.wala.cast.java.test.data/src/ArrayLiteral1.java b/com.ibm.wala.cast.java.test.data/src/ArrayLiteral1.java new file mode 100644 index 000000000..b69e1102e --- /dev/null +++ b/com.ibm.wala.cast.java.test.data/src/ArrayLiteral1.java @@ -0,0 +1,8 @@ +public class ArrayLiteral1 { + public static void main(String[] args) { + ArrayLiteral1 al1= new ArrayLiteral1(); + int[] a= new int[] { 0, 1, 2, 3, 5 }; + Object[] b= new Object[] { null, "hi", new Integer(55), new int[] { 3, 1, 4 } }; + + } +} \ No newline at end of file diff --git a/com.ibm.wala.cast.java.test.data/src/ArrayLiteral2.java b/com.ibm.wala.cast.java.test.data/src/ArrayLiteral2.java new file mode 100644 index 000000000..ab52b6f47 --- /dev/null +++ b/com.ibm.wala.cast.java.test.data/src/ArrayLiteral2.java @@ -0,0 +1,7 @@ +public class ArrayLiteral2 { + public static void main(String[] args) { + ArrayLiteral2 al2= new ArrayLiteral2(); + int[] x= {}; + int[] y= { 1, 2, 3, 4 }; + } +} diff --git a/com.ibm.wala.cast.java.test.data/src/Breaks.java b/com.ibm.wala.cast.java.test.data/src/Breaks.java new file mode 100644 index 000000000..a376376e8 --- /dev/null +++ b/com.ibm.wala.cast.java.test.data/src/Breaks.java @@ -0,0 +1,35 @@ +public class Breaks { + + private static class Ref { + String[] classes; + + String[] getClasses() { + return classes; + } + + private Ref(String[] classes) { + this.classes = classes; + } + } + + private void testBreakFromIf(String objectClass, Ref reference) { + objectClassCheck: + if (objectClass != null) { + String[] classes = reference.getClasses(); + int size = classes.length; + for (int i = 0; i < size; i++) { + if (classes[i] == objectClass) + break objectClassCheck; + } + return; + } + if (objectClass == null) { + reference.classes = null; + } + } + + public static void main(String[] args) { + (new Breaks()).testBreakFromIf("whatever", new Ref(args)); + } + +} \ No newline at end of file diff --git a/com.ibm.wala.cast.java.test.data/src/CastFromNull.java b/com.ibm.wala.cast.java.test.data/src/CastFromNull.java new file mode 100644 index 000000000..72476c7e3 --- /dev/null +++ b/com.ibm.wala.cast.java.test.data/src/CastFromNull.java @@ -0,0 +1,7 @@ +public class CastFromNull { + public static void main(String args[]) { + new CastFromNull(); + Object x = (Object) null; + String y = (String) null; + } +} diff --git a/com.ibm.wala.cast.java.test.data/src/Casts.java b/com.ibm.wala.cast.java.test.data/src/Casts.java new file mode 100644 index 000000000..a9752789d --- /dev/null +++ b/com.ibm.wala.cast.java.test.data/src/Casts.java @@ -0,0 +1,27 @@ +public class Casts { + + public static void main(String[] args) { + (new Casts()).test(args); + } + + private void test(String[] args) { + long l1 = Long.parseLong(args[0]); + int i1 = Integer.parseInt(args[1]); + short s1 = Short.parseShort(args[2]); + float f1 = Float.parseFloat(args[3]); + double d1 = Double.parseDouble(args[4]); + + double d2 = d1 + f1; + double d3 = d1 + l1; + double d4 = d1 + i1; + + float f2 = f1 + i1; + float f3 = f1 + s1; + + long l2 = l1 + i1; + long l3 = l1 + s1; + + int i2 = i1 + s1; + } + +} \ No newline at end of file diff --git a/com.ibm.wala.cast.java.test.data/src/DefaultConstructors.java b/com.ibm.wala.cast.java.test.data/src/DefaultConstructors.java new file mode 100644 index 000000000..f159d9d61 --- /dev/null +++ b/com.ibm.wala.cast.java.test.data/src/DefaultConstructors.java @@ -0,0 +1,61 @@ + +public class DefaultConstructors { + public static void main(String args[]) { + E e = new E(); +// System.out.println(e.x); +// System.out.println(e.y); + e = new E(7,8); +// System.out.println(e.x); +// System.out.println(e.y); + + Object x[] = new Object[4]; + x.clone(); + x.equals(new Object()); + x.toString(); + } +} + +class dcA { + int x; + dcA() { + x = 5; + } + dcA(int a) { + x = a; + } +} + +class dcB extends dcA { + dcB() { + super(); + } +} + +class C extends dcA { + C() { + // implicit call to super(). we want to see if it's the same as above + } +} + +class D extends dcA { + // implicit constructor, should be same as above +} + +class E extends dcA { + int y; + E() { + // no implicit call + this(6); + } + + E(int z) { + // implicit call to A() + this.y = z; + } + + E(int a, int b) { + // no implicit call + super(a); + y = b; + } +} diff --git a/com.ibm.wala.cast.java.test.data/src/Exception1.java b/com.ibm.wala.cast.java.test.data/src/Exception1.java new file mode 100644 index 000000000..cceec5737 --- /dev/null +++ b/com.ibm.wala.cast.java.test.data/src/Exception1.java @@ -0,0 +1,37 @@ +public class Exception1 { + public static void main(String[] args) { + Exception1 e1= new Exception1(); + try { + FooEx1 f = new FooEx1(); + + f.bar(); + } catch(BadLanguageExceptionEx1 e) { + e.printStackTrace(); + } + try { + FooEx2 f = new FooEx2(); + + f.bar(); + } catch(Throwable e) { + e.printStackTrace(); + } + } +} + +class FooEx1 { + public void bar() throws BadLanguageExceptionEx1 { + throw new BadLanguageExceptionEx1(); + } +} + +class FooEx2 { + public void bar() { + throw new NullPointerException(); + } +} + +class BadLanguageExceptionEx1 extends Exception { + public BadLanguageExceptionEx1() { + super("Try using a real language, like Perl"); + } +} diff --git a/com.ibm.wala.cast.java.test.data/src/Exception2.java b/com.ibm.wala.cast.java.test.data/src/Exception2.java new file mode 100644 index 000000000..678a6f148 --- /dev/null +++ b/com.ibm.wala.cast.java.test.data/src/Exception2.java @@ -0,0 +1,41 @@ +import java.io.*; + +public final class Exception2 { + + public static void main(String[] args) { + Exception2 e2= new Exception2(); + FileInputStream fis = null; + FileOutputStream fos = null; + + try { + fis = new FileInputStream( args[0] ); + fos = new FileOutputStream( args[1] ); + + int data; + while ( (data = fis.read()) != -1 ) { + fos.write(data); + } + } catch (FileNotFoundException e) { + System.err.println( "File not found" ); + // whatever + } catch (IOException e) { + System.err.print( "I/O problem " ); + System.err.println( e.getMessage() ); + } finally { + if (fis != null) { + try { + fis.close(); + } catch (IOException e) { + System.exit(-1); + } + } + if (fos != null) { + try { + fos.close(); + } catch (IOException e) { + System.exit(-1); + } + } + } + } +} diff --git a/com.ibm.wala.cast.java.test.data/src/Finally1.java b/com.ibm.wala.cast.java.test.data/src/Finally1.java new file mode 100644 index 000000000..1869d88cb --- /dev/null +++ b/com.ibm.wala.cast.java.test.data/src/Finally1.java @@ -0,0 +1,25 @@ +public class Finally1 { + public static void main(String[] args) throws BadLanguageExceptionF1 { + Finally1 f1= new Finally1(); + try { + FooF1 f = new FooF1(); + + f.bar(); + } finally { + System.out.println("blah"); + } + System.out.println("feep"); + } +} +class FooF1 { + public void bar() throws BadLanguageExceptionF1 { + if (true) + throw new BadLanguageExceptionF1(); + System.out.println("feh"); + } +} +class BadLanguageExceptionF1 extends Exception { + public BadLanguageExceptionF1() { + super("Try using a real language, like Perl"); + } +} diff --git a/com.ibm.wala.cast.java.test.data/src/Finally2.java b/com.ibm.wala.cast.java.test.data/src/Finally2.java new file mode 100644 index 000000000..c06d0ffd2 --- /dev/null +++ b/com.ibm.wala.cast.java.test.data/src/Finally2.java @@ -0,0 +1,29 @@ +import java.io.IOException; + +public class Finally2 { + public static void main(String[] args) throws IOException { + try { + FooF2 f = new FooF2(); + + f.bar(); + f.bletch(); + } catch (BadLanguageExceptionF2 e) { + e.printStackTrace(); + } finally { + System.out.println("blah"); + } + } +} +class FooF2 { + public void bar() throws BadLanguageExceptionF2 { + throw new BadLanguageExceptionF2(); + } + public void bletch() throws IOException { + throw new IOException("Burp!"); + } +} +class BadLanguageExceptionF2 extends Exception { + public BadLanguageExceptionF2() { + super("Try using a real language, like Perl"); + } +} diff --git a/com.ibm.wala.cast.java.test.data/src/FunkySupers.java b/com.ibm.wala.cast.java.test.data/src/FunkySupers.java new file mode 100644 index 000000000..9c5094b10 --- /dev/null +++ b/com.ibm.wala.cast.java.test.data/src/FunkySupers.java @@ -0,0 +1,28 @@ + + +public class FunkySupers { + int y; + int funky(FunkySupers fs) { + return 5; + } + + public static void main(String args[]) { + new SubFunkySupers().funky(new FunkySupers()); + } +} + +class SubFunkySupers extends FunkySupers { + int funky(FunkySupers fs) { + SubFunkySupers.super.funky(fs); + SubFunkySupers.this.funky(fs); + SubFunkySupers.this.y = 7; + SubFunkySupers.super.y = 7; + super.y = 7; + super.funky(fs); + return 6; + } +} + +//class EE { class X {} } +//class Y extends EE.X { Y(EE e) { e.super(); } } +// DOESNT WORK IN POLYGLOT!!! \ No newline at end of file diff --git a/com.ibm.wala.cast.java.test.data/src/Inheritance1.java b/com.ibm.wala.cast.java.test.data/src/Inheritance1.java new file mode 100644 index 000000000..c797ccc27 --- /dev/null +++ b/com.ibm.wala.cast.java.test.data/src/Inheritance1.java @@ -0,0 +1,28 @@ +public class Inheritance1 { + public static void main(String[] args) { + Inheritance1 ih1= new Inheritance1(); + Base b1 = new Base(); + Base b2 = new Derived(); + + b1.foo(); + b2.foo(); + b1.bar(3); + b2.bar(5); + } +} +class Base { + public void foo() { + int i= 0; + } + public String bar(int x) { + return Integer.toOctalString(x); + } +} +class Derived extends Base { + public void foo() { + super.foo(); + } + public String bar(int x) { + return Integer.toHexString(x); + } +} \ No newline at end of file diff --git a/com.ibm.wala.cast.java.test.data/src/InheritedField.java b/com.ibm.wala.cast.java.test.data/src/InheritedField.java new file mode 100644 index 000000000..3ad5ae085 --- /dev/null +++ b/com.ibm.wala.cast.java.test.data/src/InheritedField.java @@ -0,0 +1,20 @@ +public class InheritedField { + public static void main(String[] args) { + InheritedField if1= new InheritedField(); + B b = new B(); + + b.foo(); + b.bar(); + } +} +class A { + protected int value; +} +class B extends A { + public void foo() { + value = 10; + } + public void bar() { + this.value *= 2; + } +} diff --git a/com.ibm.wala.cast.java.test.data/src/InnerClass.java b/com.ibm.wala.cast.java.test.data/src/InnerClass.java new file mode 100644 index 000000000..e75789993 --- /dev/null +++ b/com.ibm.wala.cast.java.test.data/src/InnerClass.java @@ -0,0 +1,49 @@ +public class InnerClass { + public static void main(String[] args) { + (new InnerClass()).method(); + } + + public int fromInner(int v) { + return v + 1; + } + + public int fromInner2(int v) { + return v + 3; + } + + public void method() { + WhatsIt w= new WhatsIt(); + } + + class WhatsThat { + private int otherValue; + + WhatsThat() { + otherValue = 3; + fromInner2( otherValue ); + } + } + + class WhatsIt { + private int value; + + public WhatsIt() { + value= 0; + fromInner(value); + anotherMethod(); + } + + private NotAgain anotherMethod() { + return new NotAgain(); + } + + class NotAgain { + Object x; + + public NotAgain() { + x = new WhatsThat(); + } + + } + } +} diff --git a/com.ibm.wala.cast.java.test.data/src/InnerClassA.java b/com.ibm.wala.cast.java.test.data/src/InnerClassA.java new file mode 100644 index 000000000..f51541ad2 --- /dev/null +++ b/com.ibm.wala.cast.java.test.data/src/InnerClassA.java @@ -0,0 +1,125 @@ +// other stranger test cases +// +// combininations of: +// o.new() form +// function calls +// getting enclosings from one AND multiple levels up +// new Foo() which requires an enclosing instruction before (ie calling new Inner() from ReallyInner() +// invariants and non-invariants (immediate 'new' in that function) +// subclasses + +public class InnerClassA { + int a_x; + + public static void main(String args[]) { + // prints out 5 5 9 7 5 5 7 5 7 5 + InnerClassA a = new InnerClassA(); + AA aa = a.new AA(); + AB ab = aa.makeAB(); + a.a_x = 5; + + // tests + int myx = ab.getA_X_from_AB(); + System.out.println(myx); // 5 + int myx2 = ab.getA_X_thru_AB(); + System.out.println(myx2); // 5 + + aa.doSomeCrazyStuff(); + } + + public int getA_X() { + return a_x; + } + + class AA { + int a2a_var; + + public AB makeAB() { + return new AB(); + } + + public void doSomeCrazyStuff() { + AB ab = new AB(); + AB.ABSubA absuba = ab.new ABSubA(); + absuba.aba_x = 7; + AB.ABA.ABAA abaa2 = ab.new ABA().new ABAA(); // just used to add ABA instance key in ABAA.getABA_X() + + AB.ABA aba = ab.new ABA(); + aba.aba_x = 9; + AB.ABA.ABAB abab = aba.new ABAB(); + System.out.println(abab.getABA_X()); // 9 + + AB.ABA.ABAA abaa = absuba.new ABAA(); + int myaba_x = abaa.getABA_X(); + int mya_x = abaa.getA_X(); + System.out.println(myaba_x); // 7 + System.out.println(mya_x); // 5 + + + doMoreWithABSubA(absuba); + } + + private void doMoreWithABSubA(InnerClassA.AB.ABSubA absuba) { + System.out.println(absuba.getA_X()); // 5 + + AB.ABSubA.ABSubAA absubaa = absuba.new ABSubAA(); + int myaba_x2 = absubaa.getABA_X(); + int mya_x2 = absubaa.getA_X(); + System.out.println(myaba_x2); // 7 + System.out.println(mya_x2); // 5 + // TODO Auto-generated method stub + + AB.ABA.ABAA abaa = absubaa.makeABAA(); + int myaba_x3 = abaa.getABA_X(); + int mya_x3 = abaa.getA_X(); + System.out.println(myaba_x3); // 7 + System.out.println(mya_x3); // 5 + + } + } + + class AB { + public int getA_X_from_AB() { + return a_x; // CHECK enclosing is an A + } + + public int getA_X_thru_AB() { + return getA_X(); // CHECK enclosing is an A + } + + class ABA { + int aba_x; + class ABAA { + int getABA_X() { + return aba_x; // CHECK enclosing is an ABA or ABSubA + } + int getA_X() { + return a_x; // CHECK enclosing is an A + } + } + class ABAB { + int getABA_X() { + return aba_x; // CHECK enclosing is an ABA + } + } + } + + class ABSubA extends ABA { + class ABSubAA { + int getABA_X() { + return aba_x; // CHECK enclosing is an ABSubA + } + int getA_X() { + return a_x; // CHECK enclosing is an A + } + ABA.ABAA makeABAA() { + return new ABAA(); // this new instruction requires us to know that ABSubA is a subclass of ABA. + // thus when we call getABA_X() on the result, it will need to find a EORK(this site,class ABA) -> THIS (of type ABSubAA) + } + } + int getA_X() { + return a_x; // CHECK enclosing is an A + } + } + } +} diff --git a/com.ibm.wala.cast.java.test.data/src/InnerClassLexicalReads.java b/com.ibm.wala.cast.java.test.data/src/InnerClassLexicalReads.java new file mode 100644 index 000000000..6d15249d2 --- /dev/null +++ b/com.ibm.wala.cast.java.test.data/src/InnerClassLexicalReads.java @@ -0,0 +1,47 @@ +interface IntConstant { + int getConstant(); +} + +public class InnerClassLexicalReads { + + /* + * CAst Instructions: + * 2 v3 = new $9$9>@2[9:9] -> [13:3] + * 3 invokespecial < Source, LInnerClassLexicalReads/makeIntConstant(I)LIntConstant;/$9$9, ()V > v3 @3 exception:v5[9:9] -> [13:3] + * 4 return v3 [9:2] -> [13:4] + */ + public static IntConstant makeIntConstant(int x) { + final int y = x * x; + return new IntConstant() { +// CAst CONSTRUCTOR Instructions: +// 1 invokespecial < Source, Ljava/lang/Object, ()V > v1 @1 exception:v3[20:9] -> [32:3] + + /* + * CAst Instructions: + * 0 v2:com.ibm.wala.ssa.SymbolTable$1@16b18b6 = lexical:y@LInnerClassLexicalReads/makeIntConstant(I)LIntConstant; + * 1 return v2:com.ibm.wala.ssa.SymbolTable$1@16b18b6[11:4] -> [11:13] + */ + public int getConstant() { + return y; + } + }; + } + + + /* + * CAst Instructions: + * 1 v2:com.ibm.wala.ssa.SymbolTable$1@4272b2 = invokestatic < Source, LInnerClassLexicalReads, makeIntConstant(I)LIntConstant; > v3:#123 @1 exception:v4[17:19] -> [17:39] + * 2 v7 = getstatic < Source, Ljava/lang/System, out, >[18:2] -> [18:12] + * 3 v8 = invokeinterface < Source, LIntConstant, getConstant()I > v2:com.ibm.wala.ssa.SymbolTable$1@4272b2 @3 exception:v9[18:21] -> [18:37] + * 4 invokevirtual < Source, Ljava/io/PrintStream, println(I)V > v7,v8 @4 exception:v10[18:2] -> [18:38] + */ + public static void main(String args[]) { + InnerClassLexicalReads ignored = new InnerClassLexicalReads(); // call this just to make reachable (test checks for unreachable methods) + int foo = 5; + int haha = foo * foo; + IntConstant ic = makeIntConstant(haha); + System.out.println(ic.getConstant()); + int x = ic.getConstant(); + System.out.println(x); + } +} diff --git a/com.ibm.wala.cast.java.test.data/src/InnerClassSuper.java b/com.ibm.wala.cast.java.test.data/src/InnerClassSuper.java new file mode 100644 index 000000000..d61a98685 --- /dev/null +++ b/com.ibm.wala.cast.java.test.data/src/InnerClassSuper.java @@ -0,0 +1,19 @@ +public class InnerClassSuper { + int x = 5; + class SuperOuter { + public void test() { + System.out.println(x); + } + } + public static void main(String args[]) { + new Sub().new SubInner(); + } +} +class Sub extends InnerClassSuper { + class SubInner { + public SubInner() { + InnerClassSuper.SuperOuter so = new InnerClassSuper.SuperOuter(); + so.test(); + } + } +} \ No newline at end of file diff --git a/com.ibm.wala.cast.java.test.data/src/InterfaceTest1.java b/com.ibm.wala.cast.java.test.data/src/InterfaceTest1.java new file mode 100644 index 000000000..d7e5dcb24 --- /dev/null +++ b/com.ibm.wala.cast.java.test.data/src/InterfaceTest1.java @@ -0,0 +1,21 @@ +public class InterfaceTest1 { + public static void main(String[] args) { + InterfaceTest1 it= new InterfaceTest1(); + IFoo foo = new FooIT1('a'); + char ch2 = foo.getValue(); + } +} + +interface IFoo { + char getValue(); +} + +class FooIT1 implements IFoo { + private char fValue; + public FooIT1(char ch) { + fValue= ch; + } + public char getValue() { + return fValue; + } +} diff --git a/com.ibm.wala.cast.java.test.data/src/LocalClass.java b/com.ibm.wala.cast.java.test.data/src/LocalClass.java new file mode 100644 index 000000000..19d6f832c --- /dev/null +++ b/com.ibm.wala.cast.java.test.data/src/LocalClass.java @@ -0,0 +1,33 @@ +public class LocalClass { + public static void main(String[] args) { + final Integer base = new Integer(6); + + class Foo { + int value; + public Foo(int v) { value= v; } + public int getValue() { return value; } + public int getValueBase() { return value - base.intValue(); } + } + Foo f= new Foo(3); + + System.out.println(f.getValue()); + System.out.println(f.getValueBase()); + + (new LocalClass()).method(); + } + + public void method() { + final Integer base = new Integer(6); + + class Foo { + int value; + public Foo(int v) { value= v; } + public int getValue() { return value; } + public int getValueBase() { return value - base.intValue(); } + } + Foo f= new Foo(3); + + System.out.println(f.getValue()); + System.out.println(f.getValueBase()); + } +} diff --git a/com.ibm.wala.cast.java.test.data/src/MiniaturList.java b/com.ibm.wala.cast.java.test.data/src/MiniaturList.java new file mode 100644 index 000000000..13d023ba0 --- /dev/null +++ b/com.ibm.wala.cast.java.test.data/src/MiniaturList.java @@ -0,0 +1,53 @@ +public class MiniaturList { + MiniaturList next; + + int data; + + public MiniaturList remove(int elt) { + MiniaturList xp = null; + MiniaturList head = this; + MiniaturList x = head; + + while (x != null) { + if (x.data == elt) { + if (xp == null) + head = x.next; + else + xp.next = x.next; + break; + } + xp = x; + x = x.next; + } + return head; + } + + public static MiniaturList cons(int elt, MiniaturList l) { + MiniaturList ret = new MiniaturList(); + ret.data = elt; + ret.next = l; + return ret; + } + + public boolean contains(int elt) { + MiniaturList head = this; + while (head != null) { + if (head.data == elt) + return true; + head = head.next; + } + return false; + } + + public static void main(String[] args) { + MiniaturList l1 = cons(1, cons(2, cons(3, cons(2, null)))); + MiniaturList l2 = cons(5, null); + + l1 = l1.remove(2); + //assert 2 !in l1.*next.data + + System.out.println(l1.contains(3)); + System.out.println(l2.contains(6)); + + } +} diff --git a/com.ibm.wala.cast.java.test.data/src/MiniaturSliceBug.java b/com.ibm.wala.cast.java.test.data/src/MiniaturSliceBug.java new file mode 100644 index 000000000..85f341382 --- /dev/null +++ b/com.ibm.wala.cast.java.test.data/src/MiniaturSliceBug.java @@ -0,0 +1,73 @@ +abstract class PrimitiveWrapper { + + /** + * Sets the integer representation of the underlying primitive + * to the given value. + * @effects this.intVal' = i + */ + public abstract void setIntValue(int i); + + /** + * Returns the integer representation of the underlying primitive. + * @return this.intVal + */ + public abstract int intValue(); + + /** + * Returns true if this and the given object are + * pri + * {@inheritDoc} + * @see java.lang.Object#equals(java.lang.Object) + */ + abstract public boolean equals(Object o); +} + +final class IntWrapper extends PrimitiveWrapper { + private int val; + + /** + * Constructs a wrapper for the given int. + * @effects this.intVal' = val + */ + public IntWrapper(int val) { + this.val = val; + } + + /** + * {@inheritDoc} + * @see com.ibm.miniatur.tests.sequential.PrimitiveWrapper#intValue() + */ + public int intValue() { + return val; + } + + /** + * {@inheritDoc} + * @see com.ibm.miniatur.tests.sequential.PrimitiveWrapper#setIntValue(int) + */ + public void setIntValue(int i) { + this.val = i; + } + + /** + * {@inheritDoc} + * @see com.ibm.miniatur.tests.sequential.PrimitiveWrapper#equals(java.lang.Object) + */ + public boolean equals(Object o) { + return o instanceof IntWrapper && ((IntWrapper)o).val==val; + } +} + +public class MiniaturSliceBug { + + public void validNonDispatchedCall(IntWrapper wrapper) { + wrapper.setIntValue(3); + assert wrapper.intValue() == 3; + wrapper.equals(wrapper); + } + + public static void main(String[] args) { + (new MiniaturSliceBug()).validNonDispatchedCall(new IntWrapper(-1)); + } + +} \ No newline at end of file diff --git a/com.ibm.wala.cast.java.test.data/src/Monitor.java b/com.ibm.wala.cast.java.test.data/src/Monitor.java new file mode 100644 index 000000000..2c74d2557 --- /dev/null +++ b/com.ibm.wala.cast.java.test.data/src/Monitor.java @@ -0,0 +1,11 @@ +public class Monitor { + int i = 0; + + public Monitor() { } + + public void incr() { synchronized(this) { i++; } } + + public static void main(String[] a) { + new Monitor().incr(); + } +} diff --git a/com.ibm.wala.cast.java.test.data/src/Monitor2.java b/com.ibm.wala.cast.java.test.data/src/Monitor2.java new file mode 100644 index 000000000..ede873dc5 --- /dev/null +++ b/com.ibm.wala.cast.java.test.data/src/Monitor2.java @@ -0,0 +1,15 @@ +public class Monitor2 { + int i = 0; + + public Monitor2() { } + + public void incr() { synchronized(this) { i++; } } + + private static boolean test(Object o) { + return true; + } + + public static void main(String[] a) { + new Monitor2().incr(); + } +} diff --git a/com.ibm.wala.cast.java.test.data/src/NullArrayInit.java b/com.ibm.wala.cast.java.test.data/src/NullArrayInit.java new file mode 100644 index 000000000..4f57a58d2 --- /dev/null +++ b/com.ibm.wala.cast.java.test.data/src/NullArrayInit.java @@ -0,0 +1,15 @@ +public class NullArrayInit { + String[] x = {null}; + + public static void main(String[] args) { + new NullArrayInit(); + Object a[] = new Object[] {null,null}; + Object b[] = {null}; + String c[] = {null}; + String d[] = {null,null}; + String e[] = {null,"hello",null}; + String f[] = new String[] {null}; + String g[] = new String[] {null,null,null}; + String j[][] = { {null,null}, {null} }; + } +} diff --git a/com.ibm.wala.cast.java.test.data/src/QualifiedStatic.java b/com.ibm.wala.cast.java.test.data/src/QualifiedStatic.java new file mode 100644 index 000000000..0adf1a533 --- /dev/null +++ b/com.ibm.wala.cast.java.test.data/src/QualifiedStatic.java @@ -0,0 +1,10 @@ +public class QualifiedStatic { + public static void main(String[] args) { + QualifiedStatic qs= new QualifiedStatic(); + FooQ fq= new FooQ(); + int x = FooQ.value; + } +} +class FooQ { + static int value= 0; +} diff --git a/com.ibm.wala.cast.java.test.data/src/Scoping1.java b/com.ibm.wala.cast.java.test.data/src/Scoping1.java new file mode 100644 index 000000000..1d30c6ba2 --- /dev/null +++ b/com.ibm.wala.cast.java.test.data/src/Scoping1.java @@ -0,0 +1,13 @@ +public class Scoping1 { + public static void main(String[] args) { + Scoping1 s1= new Scoping1(); + { + int x= 5; + System.out.println(x); + } + { + double x= 3.14; + System.out.println(x); + } + } +} \ No newline at end of file diff --git a/com.ibm.wala.cast.java.test.data/src/Scoping2.java b/com.ibm.wala.cast.java.test.data/src/Scoping2.java new file mode 100644 index 000000000..9a6221669 --- /dev/null +++ b/com.ibm.wala.cast.java.test.data/src/Scoping2.java @@ -0,0 +1,18 @@ +public class Scoping2 { + public static void main(String[] args) { + Scoping2 s2= new Scoping2(); + { + final int x= 5; + System.out.println(x); + (new Object() { + public void foo() { + System.out.println("x = " + x); + } + }).foo(); + } + { + double x= 3.14; + System.out.println(x); + } + } +} \ No newline at end of file diff --git a/com.ibm.wala.cast.java.test.data/src/Simple1.java b/com.ibm.wala.cast.java.test.data/src/Simple1.java new file mode 100644 index 000000000..40e3cade3 --- /dev/null +++ b/com.ibm.wala.cast.java.test.data/src/Simple1.java @@ -0,0 +1,31 @@ +public class Simple1 { + private int value; + private final float fval = 3.14F; + private float fval1 = 3.2F; + public Simple1(int x) { + value = x; + } + public Simple1() { + this(0); + } + public static void doStuff(int N) { + int prod = 1; + for(int j=0; j < N; j++) + prod *= j; + } + public static void main(String[] args) { + int sum= 0; + for(int i=0; i < 10; i++) { + sum += i; + } + Simple1.doStuff(sum); + Simple1 s = new Simple1(); + s.instanceMethod1(); + } + public void instanceMethod1() { + instanceMethod2(); + } + public float instanceMethod2() { + return fval * fval1; + } +} diff --git a/com.ibm.wala.cast.java.test.data/src/SimpleCalls.java b/com.ibm.wala.cast.java.test.data/src/SimpleCalls.java new file mode 100644 index 000000000..f56f032c1 --- /dev/null +++ b/com.ibm.wala.cast.java.test.data/src/SimpleCalls.java @@ -0,0 +1,22 @@ + +interface ISimpleCalls { + public void helloWorld(); +} +public class SimpleCalls implements ISimpleCalls { + public void helloWorld() { + System.out.println("hello world!"); + } + public int anotherCall() { + this.helloWorld(); + ((this)).helloWorld(); + System.out.println("another call"); + return 5; + } + public static void main (String args[]) { + SimpleCalls sc = new SimpleCalls(); + ISimpleCalls isc = sc; + isc.helloWorld(); + int y = sc.anotherCall(); + y = y + y; + } +} diff --git a/com.ibm.wala.cast.java.test.data/src/StaticInit.java b/com.ibm.wala.cast.java.test.data/src/StaticInit.java new file mode 100644 index 000000000..b8d012f71 --- /dev/null +++ b/com.ibm.wala.cast.java.test.data/src/StaticInit.java @@ -0,0 +1,31 @@ +public class StaticInit { + + static class X { + int x; + int y; + + int sum() { + return x+y; + } + + int diff() { + return x+-y; + } + } + + private static X x = new X(); + private static X y; + + static { + y = new X(); + } + + private static int sum() { + return x.sum() * y.diff(); + } + + public static void main(String[] args) { + StaticInit SI = new StaticInit(); + SI.sum(); + } +} diff --git a/com.ibm.wala.cast.java.test.data/src/StaticNesting.java b/com.ibm.wala.cast.java.test.data/src/StaticNesting.java new file mode 100644 index 000000000..f63c2a470 --- /dev/null +++ b/com.ibm.wala.cast.java.test.data/src/StaticNesting.java @@ -0,0 +1,12 @@ +public class StaticNesting { + public static void main(String[] args) { + StaticNesting sn= new StaticNesting(); + WhatsIt w= new WhatsIt(); + } + static class WhatsIt { + private int value; + public WhatsIt() { + value= 0; + } + } +} \ No newline at end of file diff --git a/com.ibm.wala.cast.java.test.data/src/Switch1.java b/com.ibm.wala.cast.java.test.data/src/Switch1.java new file mode 100644 index 000000000..6a781e8db --- /dev/null +++ b/com.ibm.wala.cast.java.test.data/src/Switch1.java @@ -0,0 +1,42 @@ +public class Switch1 { + public static void main(String[] args) { + Switch1 s1= new Switch1(); + s1.testOne(args); + s1.testTwo(args); + s1.testThree(args); + } + + public void testOne(String[] args) { + char ch; + switch(Integer.parseInt(args[0])) { + case 0: ch=Character.forDigit(Integer.parseInt(args[1]), 10); break; + case 1: ch=Character.forDigit(Integer.parseInt(args[2]), 10); break; + case 2: ch=Character.forDigit(Integer.parseInt(args[3]), 10); break; + case 3: ch=Character.forDigit(Integer.parseInt(args[4]), 10); break; + default: ch= '?'; break; + } + System.out.println(ch); + } + + public char testTwo(String[] args) { + switch(Integer.parseInt(args[0])) { + case 0: return Character.forDigit(Integer.parseInt(args[1]), 10); + case 1: return Character.forDigit(Integer.parseInt(args[2]), 10); + case 2: return Character.forDigit(Integer.parseInt(args[3]), 10); + case 3: return Character.forDigit(Integer.parseInt(args[4]), 10); + default: return '?'; + } + } + + public void testThree(String[] args) { + char ch = '?'; + switch(Integer.parseInt(args[0])) { + case 0: ch=Character.forDigit(Integer.parseInt(args[1]), 10); break; + case 1: ch=Character.forDigit(Integer.parseInt(args[2]), 10); break; + case 2: ch=Character.forDigit(Integer.parseInt(args[3]), 10); break; + case 3: ch=Character.forDigit(Integer.parseInt(args[4]), 10); break; + } + System.out.println(ch); + } + +} diff --git a/com.ibm.wala.cast.java.test.data/src/Thread1.java b/com.ibm.wala.cast.java.test.data/src/Thread1.java new file mode 100644 index 000000000..8327c015f --- /dev/null +++ b/com.ibm.wala.cast.java.test.data/src/Thread1.java @@ -0,0 +1,26 @@ +class R implements Runnable { + public int i; + + R(int i) { this.i = i; } + + public void run() { + return; + } + +} + +public class Thread1 { + + private void test() { + R r = new R(2); + Thread t = new Thread(r); + t.start(); + } + + public static void main(String[] a) { + (new Thread1()).test(); + } + +} + + diff --git a/com.ibm.wala.cast.java.test.data/src/TwoClasses.java b/com.ibm.wala.cast.java.test.data/src/TwoClasses.java new file mode 100644 index 000000000..62147be56 --- /dev/null +++ b/com.ibm.wala.cast.java.test.data/src/TwoClasses.java @@ -0,0 +1,40 @@ +public class TwoClasses { + private int value; + private float fval= 3.14F; + public TwoClasses(int x) { + value = x; + } + public TwoClasses() { + this(0); + } + public static void doStuff(int N) { + int prod= 1; + TwoClasses tc= new TwoClasses(); + tc.instanceMethod1(); + for(int j=0; j < N; j++) + prod *= j; + } + public static void main(String[] args) { + int sum= 0; + for(int i=0; i < 10; i++) { + sum += i; + } + TwoClasses.doStuff(sum); + } + public void instanceMethod1() { + instanceMethod2(); + } + public void instanceMethod2() { + Bar b= Bar.create('a'); + } +} +class Bar { + private final char fChar; + + private Bar(char c) { + fChar= c; + } + public static Bar create(char c) { + return new Bar(c); + } +} diff --git a/com.ibm.wala.cast.java.test.data/src/WelcomeInitializers.java b/com.ibm.wala.cast.java.test.data/src/WelcomeInitializers.java new file mode 100644 index 000000000..4a7322066 --- /dev/null +++ b/com.ibm.wala.cast.java.test.data/src/WelcomeInitializers.java @@ -0,0 +1,24 @@ + +public class WelcomeInitializers { + int x; + int y = 6; + static int sX; + static int sY = 6; + + { + x = 7 / 7; + } + + static { + sX = 9 / 3; + } + + public WelcomeInitializers() { + + } + public void hey() {} + + public static void main(String args[]) { + new WelcomeInitializers().hey(); + } +} diff --git a/com.ibm.wala.cast.java.test.data/src/WhileTest1.java b/com.ibm.wala.cast.java.test.data/src/WhileTest1.java new file mode 100644 index 000000000..b845bada4 --- /dev/null +++ b/com.ibm.wala.cast.java.test.data/src/WhileTest1.java @@ -0,0 +1,20 @@ +public class WhileTest1 { + public static void main(String[] args) { + WhileTest1 wt1= new WhileTest1(); + int x= 235834; + boolean stop= false; + + while (!stop) { + x += 3; + x ^= 0xAAAA5555; + stop= (x & 0x1248) != 0; + } + + while (!stop) { + x += 3; + if (x < 7) continue; + x ^= 0xAAAA5555; + stop= (x & 0x1248) != 0; + } + } +} diff --git a/com.ibm.wala.cast.java.test.data/src/com/ibm/wala/cast/java/test/data/Activator.java b/com.ibm.wala.cast.java.test.data/src/com/ibm/wala/cast/java/test/data/Activator.java new file mode 100644 index 000000000..3968057b1 --- /dev/null +++ b/com.ibm.wala.cast.java.test.data/src/com/ibm/wala/cast/java/test/data/Activator.java @@ -0,0 +1,50 @@ +package com.ibm.wala.cast.java.test.data; + +import org.eclipse.core.runtime.Plugin; +import org.osgi.framework.BundleContext; + +/** + * The activator class controls the plug-in life cycle + */ +public class Activator extends Plugin { + + // The plug-in ID + public static final String PLUGIN_ID = "com.ibm.wala.cast.java.test.data"; + + // The shared instance + private static Activator plugin; + + /** + * The constructor + */ + public Activator() { + } + + /* + * (non-Javadoc) + * @see org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext) + */ + public void start(BundleContext context) throws Exception { + super.start(context); + plugin = this; + } + + /* + * (non-Javadoc) + * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext) + */ + public void stop(BundleContext context) throws Exception { + plugin = null; + super.stop(context); + } + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static Activator getDefault() { + return plugin; + } + +} diff --git a/com.ibm.wala.cast.java.test.data/src/fetch_tests.sh b/com.ibm.wala.cast.java.test.data/src/fetch_tests.sh new file mode 100755 index 000000000..1566249a2 --- /dev/null +++ b/com.ibm.wala.cast.java.test.data/src/fetch_tests.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +if [[ `uname` = "Linux" ]]; then + REAL_NAME=`realpath $0` + MY_DIR=`dirname $REAL_NAME` +else + MY_DIR=`pwd` +fi + +TMP=$MY_DIR/tmp + +if [[ ! -e $MY_DIR/JLex/Main.java ]]; then + mkdir -p $TMP + + cd $TMP + + mkdir JLex + wget -O JLex/Main.java http://www.cs.princeton.edu/~appel/modern/java/JLex/current/Main.java + + cp -r JLex $MY_DIR + + cd $MY_DIR + rm -rf $TMP +fi +