Show HN: Standalone Jdk.compiler, Java Compiler Framework and Tree API

📰 Hacker News · kohlschuetter

Use a standalone Java compiler to access Java 11 features on newer Java versions and target older Java versions without restrictions

intermediate Published 10 Oct 2023
Action Steps
  1. Download the standalone JDK.compiler
  2. Use the Java Compiler Framework to compile code targeting Java 1.7
  3. Apply the Compiler Tree API without using --add-opens
  4. Build a custom compiler with additional features or tweaks
  5. Test the modified compiler with different Java versions and environments
Who Needs to Know This

Developers and engineers working with Java can benefit from this standalone compiler to ensure compatibility and flexibility across different Java environments and versions

Key Insight

💡 Access Java 11 features on newer Java versions without restrictions

Share This
🚀 Standalone Java compiler for compatibility and flexibility across Java versions 🚀

Key Takeaways

Use a standalone Java compiler to access Java 11 features on newer Java versions and target older Java versions without restrictions

Full Article

With this standalone compiler, you can rely on all Java 11 javac features to be available, even when using newer Java versions. Specifically, this allows you to: - compile code even if your Java environment isn't a full JDK (Java JRE, for example!) - target Java 1.7 for compilation without any warnings or restrictions. - use the Compiler Tree API without resorting to --add-opens trickery that may eventually fail in newer Java releases - build a modified compiler with additional features or custom tweaks I made this after finding that the otherwise superb "jsweet" Java-to-JavaScript transpiler failed to build and run with Java 16 or newer. Surprisingly, I couldn't find any prior work other than "proper" standalone compilers like Eclipse's ecj that would properly work with modern Java runtimes. I'm excited to see what can be done now that we have this scaffolding.
Read full article → ☆ Save to playlist ← Back to Reads

Related Videos

95% of Students Learn DSA the Wrong Way! | How to Learn DSA the Right Way | #Shorts | #Simplilearn
95% of Students Learn DSA the Wrong Way! | How to Learn DSA the Right Way | #Shorts | #Simplilearn
Simplilearn
Programming Languages Feel Similar
Programming Languages Feel Similar
Stephen Blum
Quant Interview Question #quant
Quant Interview Question #quant
quantprof
Quant Interview Question #quant
Quant Interview Question #quant
quantprof
Webhooks & Callbacks For Beginners in Python
Webhooks & Callbacks For Beginners in Python
NeuralNine
Professional PDF Reports with Matplotlib in Python
Professional PDF Reports with Matplotlib in Python
NeuralNine