Closed pashanhenlei closed 7 years ago
Thanks for your interest! It's great to know that people are using Krakatau.
For the first issue, I've thought about adding operator precedence knowledge, but that would require more complicated changes first. I'll definitely look into it though.
As for the second change, the problem is that classfile identifiers have much more freedom than Java identifiers, and there's not much that can be done in the matter. Replacing $ with . will fix some examples, but it is a poor general solution and may make other examples more confusing.
Operator precedence has been implemented. It should add parenthesis if the cast thing ever comes up now.
awesome!
Yep, can I have the option of in-lining anonymous classes rather than output separate files for them? Be it MyClass$1 or MyClass.1
I've considered it, but inner classes are extremely complex so it's never been a priority. And unfortunately I don't have much time to work on Krakatau at all nowadays.
Apart from the fact that the decompiler is in maintenance mode, inlining nested classes goes against the spirit of Krakatau, because it relies on metadata that can be faked. In fact, some obfuscators deliberately add fake nested class information, which would result in garbage code with any decompiler that tries to inline nested classes.
hi, I should say you have created a masterpiece! I learned a lot from your wonderful open source code. this is the most powerful decompiler I ever met. the outputted code is logically correct in most cases and is compilable after doing some manual modification(major issues are caused by embedded classes).
I made following minor modifications in ast.py to improve the compilability of decompiled java source. the first one will make the code ugly, but it works. and the second one related to embedded class.
class Cast(JavaExpression): def init(self, *params): self.dtype = params[0].tt self.params = params self.fmt = '(({}){})' <<---------this one
class TypeName(JavaExpression): def init(self, tt): self.dtype = None self.tt = tt name, dim = tt if name[0] == '.': #primative type: name = name[1:] else: name = name.replace('/','.') name = name.replace('$','.') <<----------this one s = name + '[]'*dim