Live data from Hacker News

Fernflower Java Decompiler

github.com

41–45 of 45 posts

Re: Fernflower Java Decompiler

#41
post #32

Earlier quoted context omitted.

That's not java compiler. That's intellij compiler. I'd say that's very weird anti-feature, because your build in IDE and maven will work differently.

When using Lombok it will use a compiler plugin for this so maven builds have @nonnull generated as if-statements. I dont know if intellij uses their own plugin but they do support Lombok in maven projects, so maybe thats where this is coming from. Afaik intellij has no built in compiler but relies on java .

Lombok hijacks the compiler to do it's own thing, and violates the contract Java compiler plugins are supposed to follow.

See this comment by an OpenJDK tech lead: https://news.ycombinator.com/item?id=37666793

Re: Fernflower Java Decompiler

#43
post #41
post #32

Earlier quoted context omitted.

When using Lombok it will use a compiler plugin for this so maven builds have @nonnull generated as if-statements. I dont know if intellij uses their own plugin but they do support Lombok in maven projects, so maybe thats where this is coming from. Afaik intellij has no built in compiler but relies on java .

Lombok hijacks the compiler to do it's own thing, and violates the contract Java compiler plugins are supposed to follow. See this comment by an OpenJDK tech lead: https://news.ycombinator.com/item?id=37666793

I was initially impressed with Lombok and then ran into all the downsides of it and it was institutionally abandoned at one particular firm I was with (100s of devs).

Re: Fernflower Java Decompiler

#44
post #9

> Fernflower is the first actually working analytical decompiler for Java and probably for a high-level programming language in general. That really deserves a link. What is an “analytical” decompiler?

As far as I can tell (although I"m a novice at RE), in the native world all non-trivial decompilers are "analytical", doing things like control-flow recovery and such. I guess the only reason why the first java decompiler was "non-analytical" is that the bytecode (at least in early days) was simple enough that you could basically pattern-match it back to instructions.

So if I'd have to give a definition I pulled out of my ass:

* non-analytical compiler: "local", works only at the instruction or basic-block level, probably done by just pattern matching templates

* analytical: anything that does non-local transformations, working across basic-blocks to recover logic and control flow

Re: Fernflower Java Decompiler

#45
post #21

Earlier quoted context omitted.

Yes, that's what it is doing. If you have a block of code a compiler will compile a language expression or statement into a particular set of assembly/bytecode instructions. For example converting `a + b` to `ADD a b`. A reversing decompiler will look at the `ADD a b` and produce `a + b` as the output. This is the simplest approach as it is effectively just a collection of these types of mapping. While this works, it…

I'm not sure that @NotNull example is appropriate. Java compiler does not add any checks for @NotNull annotations. Those annotations exist for IDE and linting tools, compiler doesn't care. May be there are Java-like languages like Lombok or non-standard compilers which do add those checks, but I think that Java decompiler shouldn't do assumptions of these additional tools.

I was trying to think of examples.

A better example for Java would be something like lambda expressions on functional interfaces. There, the compiler is creating an anonymous object that implements the interface. A reversable decompiler will just see the anonymous class instance whereas an analytical decompiler can detect that it is likely a lambda expression due to it being an anonymous class object implementing a single method interface and is being passed to a function argument that takes that interface as a parameter.

In C# yield is implemented as a state machine, so an analytical decompiler could recognise that construct.

And yes, for JVM decompilers it could have language heuristics to detect (or be specifically for) Lombok, Scala, Groovy, Kotlin, etc.

[1] https://docs.oracle.com/javase/tutorial/java/javaOO/lambdaex...

Post reply on HN