usethesource / flybytes

Flybytes is an intermediate language between JVM bytecode and software languages (DSLs, PLs), for compilation and decompilation.
BSD 2-Clause "Simplified" License
16 stars 6 forks source link

decompilation of null tests fails #8

Closed jurgenvinju closed 4 years ago

jurgenvinju commented 4 years ago

an issue reported by Fransisco Handrick; this includes his examples files.

Lines 25, 26 and 27 in Bank.java trigger a problem, while the other code works fine.

Count.java:

package business;

public class Count {

    protected String     number;
    protected double    balance;
    protected String    name;

    void credit (double value) {
        balance = balance + value;
    }

    void debit (double value){
        balance = balance - value;
    }

    public String getNumber() {return number;}
    public double getBalance() {return balance;}
    public String getName() {return  name;}

    public Count (String n, String na) {number = n; name = na; balance = 0;}
}

Bank.java:

package business;

public class Bank {
    public Count[] counts;
    public int index = 0;

    public void register(Count c) {
        counts[index] = c;
        index = index + 1;
    }

    public Count find(String n) {
        int i = 0;
        boolean find = false;
        while ((! find) && (i < index)) {
            if (counts[i].getNumber().equals(n)) find = true;
            else i = i + 1;
        }
        if (find == true) return counts[i];
        else return null;
    }
    public double balance(String num){
        Count c;
        c = this.find(num);
        //if (c != null)
            return c.getBalance();
        //else
        //    return 0;
    }
    public void debit(String num, double val) {
        Count c;
        c = this.find(num);
        //if (c != null)
            c.debit(val);
        //else
           // System.out.println("ERROR");
    }
    public void credit(String num, double val) {
        Count c;
        c = this.find(num);
        //if (c != null)
            c.credit(val);
        //else
        //    System.out.println("ERROR");
    }
    public Bank() {
        counts=new Count[50];
    }
}