     b.push t
   }
 
-  athrow: { compile: (b) -> b.add_stmt new Expr "throw new util.JavaException($0)", b.pop() }
+  athrow: { compile: (b) -> b.add_stmt new Expr "throw new exceptions.JavaException($0)", b.pop() }
 
   checkcast: { compile: (b) ->
     target_class = c2t(@class).toExternalString()
     obj = b.pop()
     b.add_stmt new Expr """
         if (($0 != null) && !types.check_cast(rs, $0, #{JSON.stringify @class})) {
-          util.java_throw(rs, 'java/lang/ClassCastException', $0.type.toExternalString()+" cannot be cast to #{target_class}");
+          exceptions.java_throw(rs, 'java/lang/ClassCastException', $0.type.toExternalString()+" cannot be cast to #{target_class}");
         }""", obj
     b.push obj
   }

    var obj = rs.check_null($1);
    var array = obj.array;
    if (!(0 <= idx && idx < array.length))
      util.java_throw(rs, 'java/lang/ArrayIndexOutOfBoundsException',
        idx + " not in length " + array.length + " array of type " + obj.type.toClassString());
    $2 = array[idx]
    """, b.pop(), b.pop(), temp

# TODO: move to a separate file
if require.main == module
  fs = require 'fs'
  ClassFile = require './ClassFile'
  fname = if process.argv.length > 2 then process.argv[2] else '/dev/stdin'
  bytes_array = util.bytestr_to_array fs.readFileSync(fname, 'binary')
  class_data = new ClassFile bytes_array
