// This software is subject to the terms of the IBM Jikes Test Suite
// License Agreement available at the following URL:
// http://www.ibm.com/research/jikes.
// Copyright (C) 1996, 1999, International Business Machines Corporation
// and others. All Rights Reserved.
// You must accept the terms of that agreement to use this software.
interface order extends cost {
int quantity();
}
interface cost {
int price();
}
class Food implements cost {
int costofitem;
Food(int i) {
costofitem = i + 2;
}
public int price() {
return costofitem;
}
}
class Cans implements order {
int costofitem;
int stock;
Cans(int i, int j) {
costofitem = i;
stock = j;
}
public int price() {
return costofitem;
}
public int quantity() {
return stock;
}
}
class megadeth {
public static void main (String aa[]) {
cost costarray[], costcans[];
int result, ok;
costarray = new cost[5];
costcans = new cost[5];
for (int i=0; i< 5; i++) {
costarray[i] = new Food(i);
costcans[i] = new Cans(i, i+2);
}
costarray[0] = new Cans(15, 3);
result = 3; ok = 0;
Cans canarray[];
try {
canarray = (Cans[])costcans;
result = result + canarray[1].price();
}
catch (ClassCastException e) {
ok = ok + 1;
}
canarray = new Cans[5];
System.arraycopy(costcans, 0, canarray, 0, 5);
if (canarray[2].price() == 2) ok = ok + 1;
try {
canarray = (Cans[])costarray;
result = result + canarray[1].price();
}
catch (ClassCastException e) {
ok = ok + 1;
}
try {
System.arraycopy(costarray, 0, canarray, 0, 5);
result = result + canarray[1].price();
}
catch (ArrayStoreException e) {
if (canarray[0].price() == 15)
ok = ok + 1;
}
if (ok != 4) result = result + 5;
System.out.println(result);
System.exit(result);
}
}
Produces following exception upon decompilation:
Loading megadeth
Decompiling method <init> ()V
Decompiling method main ([Ljava/lang/String;)V
Traceback (most recent call last):
File "/var/www/temp/Krakatau/decompile.py", line 126, in <module>
decompileClass(path, targets, args.out)
File "/var/www/temp/Krakatau/decompile.py", line 82, in decompileClass
source = deco.generateSource()
File "/var/www/temp/Krakatau/Krakatau/java/javaclass.py", line 76, in generateSource
method_defs = map(self._getMethod, self.methods)
File "/var/www/temp/Krakatau/Krakatau/java/javaclass.py", line 54, in _getMethod
code_ast = MethodDecompiler(method, graph, self.forbidden_identifiers).generateAST()
File "/var/www/temp/Krakatau/Krakatau/java/javamethod.py", line 505, in generateAST
ast_root, varinfo = astgen.createAST(method, self.graph, setree, self.namegen)
File "/var/www/temp/Krakatau/Krakatau/java/astgen.py", line 345, in createAST
astroot = _createASTSub(info, seroot)
File "/var/www/temp/Krakatau/Krakatau/java/astgen.py", line 295, in _createASTSub
new = _createASTBlock(info, current.node, gotoMap)
File "/var/www/temp/Krakatau/Krakatau/java/astgen.py", line 189, in _createASTBlock
expr = ast.Assignment(info.var(n2, inv), info.var(node, outv))
File "/var/www/temp/Krakatau/Krakatau/java/astgen.py", line 64, in var
self._vars[var, node.num] = new = self._newVar(var, node.num)
File "/var/www/temp/Krakatau/Krakatau/java/astgen.py", line 46, in _newVar
tt = self._tts[var]
KeyError: Var UNREACHABLE
This code, compiled with javac 1.7.0_21:
Produces following exception upon decompilation: