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
Action Steps
- Download the standalone JDK.compiler
- Use the Java Compiler Framework to compile code targeting Java 1.7
- Apply the Compiler Tree API without using --add-opens
- Build a custom compiler with additional features or tweaks
- 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.
Related Videos
⚡
You're 1 lesson closer to your goal
Sign in free and we'll turn this lesson into a structured roadmap — starting with ⚡30 free Sparks for your first AI explanation or skill path.
Create free account →No credit card required.
DeepCamp AI