diff --git a/jode/test/AnonymousClass.java b/jode/test/AnonymousClass.java index a6d910d..49b33c7 100644 --- a/jode/test/AnonymousClass.java +++ b/jode/test/AnonymousClass.java @@ -17,8 +17,6 @@ * $Id$ */ -package jode.test; - import java.util.Vector; public class AnonymousClass { @@ -42,7 +40,18 @@ public class AnonymousClass { Hello(String info) { System.err.println("construct: "+info); } - +///#ifndef JAVAC11 +///#ifndef JAVAC12 +///#ifndef JIKES +/// Hello(int i) { +/// this("If you find a compiler that can compile this," +/// +" please comment this out and tell me if " +/// +"decompilation works.\n" +/// +"jikes 0.47, javac 1.2 are both broken!"); +/// } +///#endif +///#endif +///#endif public void hello() { this.hashCode(); Inner.this.hashCode(); @@ -78,11 +87,13 @@ public class AnonymousClass { return o.toString(); } }; +///#ifndef JAVAC12 Hello blah = new Hello("Hello World") { public void hello() { System.err.println("overwritten"); } }; +///#endif Inner blub = new AnonymousClass().new Inner("Inner param") { public void test() { @@ -97,7 +108,7 @@ public class AnonymousClass { } Vector v = new Vector(hi.var, new Inner("blah").var) { - public String toString() { + public String newMethod() { return super.toString(); } }; @@ -146,11 +157,13 @@ public class AnonymousClass { return o.toString(); } }; +///#ifndef JAVAC12 Hello blah = new Hello("Hello World") { public void hello() { System.err.println("overwritten"); } }; +///#endif Inner blub = new Inner("Inner param") { public void test() { @@ -165,7 +178,7 @@ public class AnonymousClass { } Vector v = new Vector(hi.var, new Inner("blah").var) { - public String toString() { + public String newMethod() { return super.toString(); } }; diff --git a/jode/test/AnonymousJavac.java b/jode/test/AnonymousJavac.java index cb6ab69..37750f0 100644 --- a/jode/test/AnonymousJavac.java +++ b/jode/test/AnonymousJavac.java @@ -17,7 +17,6 @@ * $Id$ */ -package jode.test; import java.util.Vector; diff --git a/jode/test/ArrayCloneTest.java b/jode/test/ArrayCloneTest.java index dc628a4..f709d27 100644 --- a/jode/test/ArrayCloneTest.java +++ b/jode/test/ArrayCloneTest.java @@ -17,7 +17,6 @@ * $Id$ */ -package jode.test; public class ArrayCloneTest { diff --git a/jode/test/ArrayTest.java b/jode/test/ArrayTest.java index f40daf1..61f4722 100644 --- a/jode/test/ArrayTest.java +++ b/jode/test/ArrayTest.java @@ -17,7 +17,6 @@ * $Id$ */ -package jode.test; import java.io.*; import java.lang.reflect.*; diff --git a/jode/test/AssignOp.java b/jode/test/AssignOp.java index b1faae7..680b7c5 100644 --- a/jode/test/AssignOp.java +++ b/jode/test/AssignOp.java @@ -17,7 +17,6 @@ * $Id$ */ -package jode.test; public class AssignOp { static short static_short; diff --git a/jode/test/Base.j b/jode/test/Base.j index ef07e40..c6a3daa 100644 --- a/jode/test/Base.j +++ b/jode/test/Base.j @@ -1,4 +1,4 @@ -.class public jode/test/Base +.class public Base .super java/lang/Object .field public static test I diff --git a/jode/test/Child.j b/jode/test/Child.j index faa2038..2b07e27 100644 --- a/jode/test/Child.j +++ b/jode/test/Child.j @@ -1,5 +1,5 @@ -.class public jode/test/Child -.super jode/test/Base +.class public Child +.super Base .field private test I @@ -7,17 +7,17 @@ .limit locals 1 .limit stack 2 aload_0 - invokespecial jode/test/Base/()V - getstatic jode/test/Base/test I + invokespecial Base/()V + getstatic Base/test I pop aload_0 - getfield jode/test/Base/test J + getfield Base/test J pop2 aload_0 - getfield jode/test/Child/test I + getfield Child/test I pop aload_0 - getfield jode/test/Child/test J + getfield Child/test J pop2 return .end method diff --git a/jode/test/ClassOpTest.java b/jode/test/ClassOpTest.java index 1e01af3..c487f40 100644 --- a/jode/test/ClassOpTest.java +++ b/jode/test/ClassOpTest.java @@ -17,7 +17,6 @@ * $Id$ */ -package jode.test; public class ClassOpTest { static void test1() { diff --git a/jode/test/Conflicts.java b/jode/test/Conflicts.java deleted file mode 100644 index c12088f..0000000 --- a/jode/test/Conflicts.java +++ /dev/null @@ -1,112 +0,0 @@ -/* Conflicts Copyright (C) 1999 Jochen Hoenicke. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * - * $Id$ - */ - -package jode.test; - -/** - * This class tests name conflicts and their resolvation. Note that every - * name in this file should be the shortest possible name. - */ -public class Conflicts -{ - int Conflicts; - - class Blah - { - Conflicts Inner; - - void Conflicts() { - Inner = jode.test.Conflicts.this; - } - } - - class Inner - { - int Conflicts; - Conflicts Inner; - - class Blah - extends Conflicts.Blah - { - int Blah; - - void Inner() { - this.Inner.Inner(); -// jode.test.Conflicts.Inner.this.Inner.Inner(); - this.Conflicts(); -// jode.test.Conflicts.Inner.this.Conflicts(); - } - - Blah() { - /* empty */ - } - - Blah(Conflicts Conflicts) { - Conflicts.super(); - } - } - - void Conflicts() { - int Conflicts = 4; - Conflicts(); - new Object() { - void Inner() { - jode.test.Conflicts.this.Inner(); - } - }; - this.Conflicts = Conflicts; - Inner(); - jode.test.Conflicts.this.Conflicts = this.Conflicts; - } - - Conflicts Conflicts(Inner Conflicts) { -// Conflicts.this$0.Conflicts = 9; - return jode.test.Conflicts.this; - } - } - - class Second - extends Conflicts.Inner.Blah - { - Inner Blah = new Inner(); - - class Inner extends Conflicts.Inner - { - } - - Conflicts.Inner create() { - return jode.test.Conflicts.this.new Inner(); - } - - Second(Conflicts.Inner Blah) { - Blah.super(); - } - } - - public void Inner() { - /* empty */ - } - - public Conflicts() { - int Conflicts = this.Conflicts; - Inner Inner = new Inner(); - Inner.Conflicts = 5; - new Inner().Conflicts(Inner).Inner(); - } -} diff --git a/jode/test/ConstantTypes.java b/jode/test/ConstantTypes.java index 4fc82db..2d20721 100644 --- a/jode/test/ConstantTypes.java +++ b/jode/test/ConstantTypes.java @@ -17,7 +17,6 @@ * $Id$ */ -package jode.test; public class ConstantTypes { static boolean bool = true; diff --git a/jode/test/EvilTypes.j b/jode/test/EvilTypes.j index a67428f..0807d4b 100644 --- a/jode/test/EvilTypes.j +++ b/jode/test/EvilTypes.j @@ -1,7 +1,7 @@ ; This class converts between boolean and ints without type casts. ; You can't decompile this directly, the decompiler probably gives type errors. -.class public jode/test/EvilTypes +.class public EvilTypes .super java/lang/Object .field public static runner Ljava/lang/Runnable; @@ -33,7 +33,7 @@ .limit locals 2 .limit stack 2 iconst_1 - invokestatic jode/test/EvilTypes/intToBool(I)Z + invokestatic EvilTypes/intToBool(I)Z istore 0 iconst_2 istore 1 @@ -67,7 +67,7 @@ second: done: dup astore_2 - invokestatic jode/test/EvilTypes/useSerial(Ljava/io/Serializable;)V + invokestatic EvilTypes/useSerial(Ljava/io/Serializable;)V aload_2 areturn .end method @@ -115,9 +115,9 @@ loop: aload_0 iconst_0 aaload - invokestatic jode/test/EvilTypes/test(Ljava/lang/String;)Ljava/lang/Runnable; - putstatic jode/test/EvilTypes/runner Ljava/lang/Runnable; - getstatic jode/test/EvilTypes/runner Ljava/lang/Runnable; + invokestatic EvilTypes/test(Ljava/lang/String;)Ljava/lang/Runnable; + putstatic EvilTypes/runner Ljava/lang/Runnable; + getstatic EvilTypes/runner Ljava/lang/Runnable; invokeinterface java/lang/Runnable/run()V 1 return .end method diff --git a/jode/test/Expressions.java b/jode/test/Expressions.java index ede9e11..dfbeffd 100644 --- a/jode/test/Expressions.java +++ b/jode/test/Expressions.java @@ -17,7 +17,6 @@ * $Id$ */ -package jode.test; public class Expressions { double cd; float cf; diff --git a/jode/test/Flow.java b/jode/test/Flow.java index b4b955c..b73ade5 100644 --- a/jode/test/Flow.java +++ b/jode/test/Flow.java @@ -17,7 +17,6 @@ * $Id$ */ -package jode.test; public abstract class Flow { int g; diff --git a/jode/test/For.java b/jode/test/For.java index a5eefba..c8b95dd 100644 --- a/jode/test/For.java +++ b/jode/test/For.java @@ -17,7 +17,6 @@ * $Id$ */ -package jode.test; public class For { diff --git a/jode/test/HintTypeTest.java b/jode/test/HintTypeTest.java index 89609b8..5be1a6d 100644 --- a/jode/test/HintTypeTest.java +++ b/jode/test/HintTypeTest.java @@ -17,7 +17,6 @@ * $Id$ */ -package jode.test; /** * The primitive types can give some headaches. You almost never can say diff --git a/jode/test/IfCombine.java b/jode/test/IfCombine.java index ad16480..f4033db 100644 --- a/jode/test/IfCombine.java +++ b/jode/test/IfCombine.java @@ -17,7 +17,6 @@ * $Id$ */ -package jode.test; public class IfCombine { boolean a,b,c; diff --git a/jode/test/InlineTest.java b/jode/test/InlineTest.java index 6bb24d9..3e9b05f 100644 --- a/jode/test/InlineTest.java +++ b/jode/test/InlineTest.java @@ -17,7 +17,6 @@ * $Id$ */ -package jode.test; /** * Check if inlines are allowed over package borders. You should put it diff --git a/jode/test/InlinedAnon.java b/jode/test/InlinedAnon.java index 11d0433..bcb3dde 100644 --- a/jode/test/InlinedAnon.java +++ b/jode/test/InlinedAnon.java @@ -1,4 +1,3 @@ -package jode.test; public class InlinedAnon { diff --git a/jode/test/InnerClass.java b/jode/test/InnerClass.java index ed9dce5..667f74e 100644 --- a/jode/test/InnerClass.java +++ b/jode/test/InnerClass.java @@ -17,7 +17,6 @@ * $Id$ */ -package jode.test; public class InnerClass { diff --git a/jode/test/InnerCompat.java b/jode/test/InnerCompat.java index be7a681..71bc963 100644 --- a/jode/test/InnerCompat.java +++ b/jode/test/InnerCompat.java @@ -17,7 +17,6 @@ * $Id$ */ -package jode.test; public class InnerCompat { int x; diff --git a/jode/test/JavacBug.java b/jode/test/JavacBug.java index 40a1df8..64d5a53 100644 --- a/jode/test/JavacBug.java +++ b/jode/test/JavacBug.java @@ -1,4 +1,3 @@ -package jode.test; /** * This class shows a bug in javac 1.2-pre2 compiler. diff --git a/jode/test/LocalTypes.java b/jode/test/LocalTypes.java index fecb02b..1340e3a 100644 --- a/jode/test/LocalTypes.java +++ b/jode/test/LocalTypes.java @@ -17,7 +17,6 @@ * $Id$ */ -package jode.test; class A { } diff --git a/jode/test/Makefile.am b/jode/test/Makefile.am index e69de29..b4cdef2 100644 --- a/jode/test/Makefile.am +++ b/jode/test/Makefile.am @@ -0,0 +1,6 @@ +JAVA = @JAVA@ +JAVAC = @JAVAC@ +JFLAGS = +TESTS_ENVIRONMENT=JAVA=$(JAVA) JAVAC=$(JAVAC) JFLAGS=$(JFLAGS) srcdir=$(srcdir) top_srcdir=$(top_srcdir) top_builddir=$(top_builddir) + +TESTS = simpletests.sh diff --git a/jode/test/NestedAnon.java b/jode/test/NestedAnon.java index 228ca8b..dfe0089 100644 --- a/jode/test/NestedAnon.java +++ b/jode/test/NestedAnon.java @@ -1,4 +1,3 @@ -package jode.test; public class NestedAnon { public NestedAnon(int maxdepth) { diff --git a/jode/test/ObfuscateStrings.j b/jode/test/ObfuscateStrings.j index 20c8273..47e17e3 100644 --- a/jode/test/ObfuscateStrings.j +++ b/jode/test/ObfuscateStrings.j @@ -2,7 +2,7 @@ ; string obfuscating method. Maybe I will use it in the Obfuscator ; some day, but probably the decompiler will handle those string, too. -.class public jode/test/ObfuscateStrings +.class public ObfuscateStrings .super java/lang/Object .method private static obf(Ljava/lang/String;)Ljava/lang/String; diff --git a/jode/test/OptimizeTest.java b/jode/test/OptimizeTest.java index 97ff275..3a6789e 100644 --- a/jode/test/OptimizeTest.java +++ b/jode/test/OptimizeTest.java @@ -17,7 +17,6 @@ * $Id$ */ -package jode.test; public class OptimizeTest { @@ -63,13 +62,13 @@ public class OptimizeTest { System.err.println("result: "+(g++ + sideInline(g) + g++) + "g: "+g); longInline("Hallo", 3); System.err.println("result:"+ - (g++ + jode.test.InlineTest + (g++ + InlineTest .difficultSideInline(this, g) + g++) + "g: "+g); // This was a check which methods are inlined. The result: // Only methods in the same package or in sub packages. // System.err.println("result:"+ -// (g++ + jode.test.inline.InlineTest +// (g++ + inline.InlineTest // .difficultSideInline(this, g) // + g++) + "g: "+g); // System.err.println("result:"+ diff --git a/jode/test/OptimizerTest.java b/jode/test/OptimizerTest.java index b2509de..9bb298f 100644 --- a/jode/test/OptimizerTest.java +++ b/jode/test/OptimizerTest.java @@ -5,7 +5,6 @@ * java jode.Obfuscator --dest tmp.zip --preserve 'jode.test.OptimizerTest.test.(*)*' jode * */ -package jode.test; public class OptimizerTest { String blah, blub; diff --git a/jode/test/ResolveConflicts.java b/jode/test/ResolveConflicts.java new file mode 100644 index 0000000..ecaab58 --- /dev/null +++ b/jode/test/ResolveConflicts.java @@ -0,0 +1,112 @@ +/* Conflicts Copyright (C) 1999 Jochen Hoenicke. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * + * $Id$ + */ + +/** + * This class tests name conflicts and their resolvation. Note that every + * name in this file should be the shortest possible name. + */ +public class ResolveConflicts +{ + public class Conflicts + { + int Conflicts; + + class Blah + { + Conflicts Inner; + + void Conflicts() { + Inner = ResolveConflicts.Conflicts.this; + } + } + + class Inner + { + int Conflicts; + Conflicts Inner; + + class Blah + extends Conflicts.Blah + { + int Blah; + + void Inner() { + this.Inner.Inner(); + ResolveConflicts.Conflicts.Inner.this.Inner.Inner(); + this.Conflicts(); + ResolveConflicts.Conflicts.Inner.this.Conflicts(); + } + + Blah() { + /* empty */ + } + + Blah(Conflicts Conflicts) { + Conflicts.super(); + } + } + + void Conflicts() { + int Conflicts = 4; + Conflicts(); + new Object() { + void Inner() { + ResolveConflicts.Conflicts.this.Inner(); + } + }; + this.Conflicts = Conflicts; + Inner(); + ResolveConflicts.Conflicts.this.Conflicts = this.Conflicts; + } + + Conflicts Conflicts(Inner Conflicts) { + return ResolveConflicts.Conflicts.this; + } + } + + class Second + extends Conflicts.Inner.Blah + { + Inner Blah = new Inner(); + + class Inner extends Conflicts.Inner + { + } + + Conflicts.Inner create() { + return ResolveConflicts.Conflicts.this.new Inner(); + } + + Second(Conflicts.Inner Blah) { + Blah.super(); + } + } + + public void Inner() { + /* empty */ + } + + public Conflicts() { + int Conflicts = this.Conflicts; + Inner Inner = new Inner(); + Inner.Conflicts = 5; + new Inner().Conflicts(Inner).Inner(); + } + } +} diff --git a/jode/test/StackOps.j b/jode/test/StackOps.j index 332fa29..92ed496 100644 --- a/jode/test/StackOps.j +++ b/jode/test/StackOps.j @@ -1,7 +1,7 @@ ; This class contains evil stack operations, that make it very hard to ; produce correct code. -.class public jode/test/StackOps +.class public StackOps .super java/lang/Object .method public static concatSwaped(ZLjava/lang/String;Ljava/lang/String;)Ljava/lang/String; diff --git a/jode/test/TriadicExpr.java b/jode/test/TriadicExpr.java index 6a4835a..7252da2 100644 --- a/jode/test/TriadicExpr.java +++ b/jode/test/TriadicExpr.java @@ -17,7 +17,6 @@ * $Id$ */ -package jode.test; public class TriadicExpr { int a,b,c,d,e,f,g,h,i,j; diff --git a/jode/test/TryCatch.java b/jode/test/TryCatch.java index 734f3ab..8f95c89 100644 --- a/jode/test/TryCatch.java +++ b/jode/test/TryCatch.java @@ -17,7 +17,6 @@ * $Id$ */ -package jode.test; /** * This tests everything that has to do with a ExceptionHandler, that @@ -120,7 +119,7 @@ class TryCatch { synchronized (local) { local.foo(); } - if (true) { + if (simple() == 0) { synchronized (this) { try { System.err.println(); diff --git a/jode/test/Unreach.java b/jode/test/Unreach.java index 1fb79b6..56fb487 100644 --- a/jode/test/Unreach.java +++ b/jode/test/Unreach.java @@ -3,7 +3,6 @@ * $Id$ */ -package jode.test; /* A test class submitted by dave@onekiwi.demon.co.uk */ class Unreach diff --git a/jode/test/simpletests.sh b/jode/test/simpletests.sh new file mode 100755 index 0000000..3f2290a --- /dev/null +++ b/jode/test/simpletests.sh @@ -0,0 +1,66 @@ +#!/bin/sh + +TEMP=`mktemp -d tmp.XXXXXX` + +if echo $JAVAC | grep jikes >/dev/null; then + compiler=JIKES; +elif echo $JAVAC | grep javac >/dev/null; then + compiler=`$JAVAC -J-version 2>&1 | grep version | \ + perl -pe's/^.*version \"?([0-9]+)\.([0-9]+).*$/JAVAC\1\2/'` +else + compiler=UNKNOWN +fi + +echo "detected compiler $compiler" + +error="" + +EXPECT_FAIL="ResolveConflicts.java AnonymousClass.java InnerClass.java" + +for testclass in \ +ArrayCloneTest.java \ +ArrayTest.java \ +AssignOp.java \ +ClassOpTest.java \ +ConstantTypes.java \ +Expressions.java \ +Flow.java \ +For.java \ +HintTypeTest.java \ +IfCombine.java \ +LocalTypes.java \ +ResolveConflicts.java \ +TriadicExpr.java \ +TryCatch.java \ +Unreach.java \ +AnonymousClass.java \ +InnerClass.java \ +InnerCompat.java \ +NestedAnon.java +do + cp $srcdir/$testclass $TEMP + $top_srcdir/jcpp -D$compiler $TEMP/$testclass + $JAVAC $JFLAGS -d $TEMP $TEMP/$testclass + CLASSPATH=$top_builddir:$CLASSPATH $JAVA jode.Decompiler \ + --classpath=$TEMP --dest=$TEMP ${testclass%.java} &> $testclass.log + if ! CLASSPATH=$TEMP:$CLASSPATH $JAVAC $JFLAGS -d $TEMP $TEMP/$testclass >> $testclass.log 2>&1 ; then + cat $TEMP/$testclass >> $testclass.log + CLASSPATH=$TEMP:$CLASSPATH javap -c ${testclass%.java} >> $testclass.log + if ! echo $EXPECT_FAIL | grep $testclass >/dev/null ; then + error="$error $testclass"; + echo "FAIL: $testclass" + else + echo "EXPECTED FAIL: $testclass" + fi + else + echo "PASS: $testclass" + rm $testclass.log + fi + #rm -rf $TEMP/* +done + +rm -rf $TEMP; + +if [ -n "$error" ]; then + exit 1; +fi