Storyyeller / Krakatau

Java decompiler, assembler, and disassembler
GNU General Public License v3.0
1.95k stars 220 forks source link

decompiler: unconditional dependency on IllegalMonitorStateException #55

Closed skochinsky closed 8 years ago

skochinsky commented 8 years ago

I'm trying to decompile the Management Engine's internal Java classes, and it does not implement (nor uses) the IllegalMonitorStateException class. The following stack trace appears when decompiling almost any class:

Traceback (most recent call last):
  File "Krakatau\decompile.py", line 153, in <module>
    decompileClass(path, targets, args.out, args.skip)
  File "Krakatau\decompile.py", line 99, in decompileClass
    source = printer.visit(javaclass.generateAST(c, makeGraph, skip_errors, add_throws=add_throws))
  File "Krakatau\Krakatau\java\javaclass.py", line 67, in generateAST
    method_defs = [_getMethod(m, cb, forbidden_identifiers, skip_errors) for m in methods]
  File "Krakatau\Krakatau\java\javaclass.py", line 37, in _getMethod
    graph = cb(method) if method.code is not None else None
  File "Krakatau\decompile.py", line 60, in makeGraph
    s.abstractInterpert()
  File "Krakatau\Krakatau\ssa\graph.py", line 296, in abstractInterpert
    out = constraints.meet(*inputs)
  File "Krakatau\Krakatau\ssa\constraints\__init__.py", line 22, in meet
    return cons[0].meet(*cons[1:])
  File "Krakatau\Krakatau\ssa\constraints\obj_c.py", line 116, in meet
    types = TypeConstraint.meet(*(c.types for c in cons))
  File "Krakatau\Krakatau\ssa\constraints\obj_c.py", line 79, in meet
    return TypeConstraint.reduce(cons[0].env, supers, exact)
  File "Krakatau\Krakatau\ssa\constraints\obj_c.py", line 45, in reduce
    newexact = [x for x in exact if not isAnySubtype(env, x, newsupers)]
  File "Krakatau\Krakatau\ssa\constraints\obj_c.py", line 10, in isAnySubtype
    return any(objtypes.isSubtype(env,x,y) for y in seq)
  File "Krakatau\Krakatau\ssa\constraints\obj_c.py", line 10, in <genexpr>
    return any(objtypes.isSubtype(env,x,y) for y in seq)
  File "Krakatau\Krakatau\ssa\objtypes.py", line 55, in isSubtype
    return isBaseTClass(x) and isBaseTClass(y) and env.isSubclass(xname, yname)
  File "Krakatau\Krakatau\environment.py", line 29, in isSubclass
    return name1 == name2 or (name2 in self.getClass(name1).getSuperclassHierarchy())
  File "Krakatau\Krakatau\environment.py", line 23, in getClass
    result = self._loadClass(name, subclasses)
  File "Krakatau\Krakatau\environment.py", line 67, in _loadClass
    raise ClassLoaderError('ClassNotFoundException', name)
Krakatau.error.ClassLoaderError: 
ClassNotFoundException: java/lang/IllegalMonitorStateException

For now I've resorted to putting IllegalMonitorStateException.class from Java into the jar but it would be nice to have the decompiler handle its absence gracefully.

Storyyeller commented 8 years ago

Krakatau requires access to the referenced classes so it can determine sub/super classes and which classes are interfaces. java/lang/IllegalMonitorStateException is a core class in the Java language, so it should be in your rt.jar. If Krakatau doesn't find it automatically, you'll need to pass its location via the -path argument.

On Mon, Nov 30, 2015 at 12:20 PM, Igor Skochinsky notifications@github.com wrote:

I'm trying to decompile the Management Engine's internal Java classes, and it does not implement (nor uses) the IllegalMonitorStateException class. The following stack trace appears when decompiling almost any class:

Traceback (most recent call last): File "Krakatau\decompile.py", line 153, in decompileClass(path, targets, args.out, args.skip) File "Krakatau\decompile.py", line 99, in decompileClass source = printer.visit(javaclass.generateAST(c, makeGraph, skip_errors, add_throws=add_throws)) File "Krakatau\Krakatau\java\javaclass.py", line 67, in generateAST method_defs = [_getMethod(m, cb, forbidden_identifiers, skip_errors) for m in methods] File "Krakatau\Krakatau\java\javaclass.py", line 37, in _getMethod graph = cb(method) if method.code is not None else None File "Krakatau\decompile.py", line 60, in makeGraph s.abstractInterpert() File "Krakatau\Krakatau\ssa\graph.py", line 296, in abstractInterpert out = constraints.meet(*inputs) File "Krakatau\Krakatau\ssa\constraintsinit.py", line 22, in meet return cons[0].meet(_cons[1:]) File "Krakatau\Krakatau\ssa\constraints\objc.py", line 116, in meet types = TypeConstraint.meet((c.types for c in cons)) File "Krakatau\Krakatau\ssa\constraints\obj_c.py", line 79, in meet return TypeConstraint.reduce(cons[0].env, supers, exact) File "Krakatau\Krakatau\ssa\constraints\obj_c.py", line 45, in reduce newexact = [x for x in exact if not isAnySubtype(env, x, newsupers)] File "Krakatau\Krakatau\ssa\constraints\obj_c.py", line 10, in isAnySubtype return any(objtypes.isSubtype(env,x,y) for y in seq) File "Krakatau\Krakatau\ssa\constraints\obj_c.py", line 10, in return any(objtypes.isSubtype(env,x,y) for y in seq) File "Krakatau\Krakatau\ssa\objtypes.py", line 55, in isSubtype return isBaseTClass(x) and isBaseTClass(y) and env.isSubclass(xname, yname) File "Krakatau\Krakatau\environment.py", line 29, in isSubclass return name1 == name2 or (name2 in self.getClass(name1).getSuperclassHierarchy()) File "Krakatau\Krakatau\environment.py", line 23, in getClass result = self._loadClass(name, subclasses) File "Krakatau\Krakatau\environment.py", line 67, in _loadClass raise ClassLoaderError('ClassNotFoundException', name) Krakatau.error.ClassLoaderError: ClassNotFoundException: java/lang/IllegalMonitorStateException

For now I've resorted to putting IllegalMonitorStateException.class from Java into the jar but it would be nice to have the decompiler handle its absence gracefully.

— Reply to this email directly or view it on GitHub https://github.com/Storyyeller/Krakatau/issues/55.