leibnitz27 / cfr

This is the public repository for the CFR Java decompiler
https://www.benf.org/other/cfr
MIT License
1.94k stars 249 forks source link

CFR decompiles generics declarations + assignments suboptimally #254

Open KOLANICH opened 3 years ago

KOLANICH commented 3 years ago

Problem solved by this feature

CFR decompiles generics declarations + assignments suboptimally:

-   private Map<String, CompiledCode> customCompiledCode = new HashMap<>();
+   private Map<String, CompiledCode> customCompiledCode = new HashMap<String, CompiledCode>();

-       DiagnosticCollector<JavaFileObject> collector = new DiagnosticCollector<>();
+       DiagnosticCollector<JavaFileObject> collector = new DiagnosticCollector<JavaFileObject>();

(excerpts from https://github.com/trung/InMemoryJavaCompiler )

Feature description

Should decompile as in - lines.

x4e commented 3 years ago

One thing to note is that the <> syntax was only added in java 7: https://docs.oracle.com/javase/tutorial/java/generics/types.html#diamond Java <= 6 classfiles would have to be decompiled with the explicit syntax.

KOLANICH commented 3 years ago

Thanks for the info. I didn't know how it is called, so just compiled setting source version to 6, and it has been compiled. I guess since it is a 7 feature, it is out of scope here, as it is written in contributing.md:

Not great things to contribute

...

  • Java above 6. See above. I know. But it's all syntactic sugar anyway. cough. Anyway, you get to work with $$FUNKY_NEW_LANGUAGE$$ in your day job.
x4e commented 3 years ago

Sorry, I think you misunderstood. I meant if the classfile you are decompiling is not Java 7, then the <> expression can not be used. It is not related to the version of Java CFR is compiled with. You should reopen the issue, it is still valid.

KOLANICH commented 3 years ago

OK, if @leibnitz27 decided it is out of scope, he would have closed this issue himself anyway.