Line 9 of method f below is decompiled incorrectly (no
error message). Test program (concat of 4 .java files):
public class Circle implements Drawable {
public int radius;
public Circle(int r) {radius = r;}
public boolean isFat() {return false;}
public void draw() {
// Code to draw...
}
}
public class Rectangle implements Drawable {
public short height, width;
public Rectangle(short h, short w) {
height = h; width = w; }
public boolean isFat() {return (width > height);}
public void draw() {
// Code to draw ...
}
}
public interface Drawable {
public void draw();
}
public class Main {
public static void f(short i) {
Circle c; Rectangle r; Drawable d;
boolean is_fat;
if (i > 10) { // 6
r = new Rectangle(i, i); // 7
is_fat = r.isFat(); // 8
d = r; // 9
}
else {
c = new Circle(i); // 12
is_fat = c.isFat(); // 13
d = c; // 14
}
if (!is_fat) d.draw(); // 16
} // 17
public static void main(String args[])
{ f((short) 11); }
}
Version 1.4.1 produces the following incorrect code for f:
public static void f(short i)
{
boolean j;
Drawable drawable;
Circle circle;
if (i > 10) {
Rectangle rectangle = new Rectangle(i , i);
j = rectangle.isFat();
Rectangle rectangle3 = rectangle; // Error!
}
else {
circle = new Circle(i);
j = circle.isFat();
drawable = circle;
}
if (!j)
drawable.draw();
return;
}
This may be a design problem; I'd be very interested to
see if you can fix this. For more details, see
http://www.stratego-language.org/twiki/bin/view/Transform/DeCompilationJrpTest#Sable_Test_Program