Initial revision

git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@383 379699f6-c40d-0410-875b-85095c16579e
stable
jochen 26 years ago
parent c53ad623d4
commit e7307604ae
  1. 81
      jode/test/EvilTypes.j
  2. 73
      jode/test/Expressions.java
  3. 41
      jode/test/StackOps.j

@ -0,0 +1,81 @@
; 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
.super java/lang/Object
.method public static boolToInt(Z)I
.limit locals 1
.limit stack 1
iload_0
ireturn
.end method
.method public static intToBool(I)Z
.limit locals 1
.limit stack 1
iload_0
ireturn
.end method
.method public static test()V
.limit locals 2
.limit stack 2
iconst_1
invokestatic jode/test/EvilTypes/intToBool(I)Z
istore 0
iconst_2
istore 1
iload 0
iload 1
ixor
pop
return
.end method
.method private static useSerial(Ljava/io/Serializable;)V
.limit locals 1
.limit stack 0
return
.end method
; This is a test where a type error occurs, because there is no Type
; that implements Cloneable, Serializable and is assignable form int
; array and java/lang/Date (though both objects are Cloneable and
; Serializable). We can't find any correct type for local 2.
.method public static referenceCast(Ljava/util/Date;[I)Ljava/lang/Cloneable;
.limit locals 3
.limit stack 2
aload_0
ifnonnull second
aload_0
goto done
second:
aload_1
done:
dup
astore_2
invokestatic jode/test/EvilTypes/useSerial(Ljava/io/Serializable;)V
aload_2
areturn
.end method
; This shows that the bytecode verifier doesn't catch every type error.
.method public static test(Ljava/lang/String;)Ljava/lang/Runnable;
.limit locals 1
.limit stack 1
aload_0
areturn
.end method
.method public static main([Ljava/lang/String;)V
.limit locals 1
.limit stack 2
aload_0
iconst_0
aaload
invokestatic jode/test/EvilTypes/test(Ljava/lang/String;)Ljava/lang/Runnable;
invokeinterface java/lang/Runnable/run()V 1
return
.end method

@ -0,0 +1,73 @@
package jode.test;
public class Expressions {
double cd;
float cf;
long cl;
int ci;
char cc;
short cs;
byte cb;
boolean cz;
void postIncDecExpressions() {
cd++;
cf++;
cl++;
ci++;
cs++;
cb++;
cc++;
cd--;
cf--;
cl--;
ci--;
cs--;
cb--;
cc--;
float f = 0.0F;
double d = 0.0;
long l = 0L;
f++;
f--;
d++;
d--;
l++;
l--;
}
void unary() {
short s = 25;
s = (short) ~s;
boolean b = !true;
s = b? s: cs;
char c= 25;
c = b ? c: cc;
}
void shift() {
int i = 0;
long l =0;
l >>= i;
l >>= i;
i >>= i;
l = l << l;
l = l << i;
l = i << l;
l = i << i;
i = (int) (l << l);
i = (int) (l << i);
i = i << l;
i = i << i;
cl >>= ci;
ci <<= ci;
cl = cl << cl;
cl = cl << ci;
cl = ci << cl;
cl = ci << ci;
ci = (int) (cl << cl);
ci = (int) (cl << ci);
ci = ci << cl;
ci = ci << ci;
}
}

@ -0,0 +1,41 @@
; This class contains evil stack operations, that make it very hard to
; produce correct code.
.class public jode/test/StackOps
.super java/lang/Object
.method public static concatSwaped(ZLjava/lang/String;Ljava/lang/String;)Ljava/lang/String;
.limit locals 3
.limit stack 3
aload_1
aload_2
iload 0
ifeq dontswap
swap
dontswap:
invokevirtual java/lang/String/concat(Ljava/lang/String;)Ljava/lang/String;
areturn
.end method
.method public static dupTest(Ljava/lang/String;)Ljava/lang/String;
.limit locals 1
.limit stack 2
; first a simple test that we can resolve
aload_0
dup
invokevirtual java/lang/String/concat(Ljava/lang/String;)Ljava/lang/String;
; now concat again.
dup
invokevirtual java/lang/String/concat(Ljava/lang/String;)Ljava/lang/String;
; Now a more evil test.
aload_0
swap
ifnull pushagain
dup
goto concat
pushagain:
aload_0
concat:
invokevirtual java/lang/String/concat(Ljava/lang/String;)Ljava/lang/String;
areturn
.end method
Loading…
Cancel
Save