Update to Java 18 once it reaches public availability for snippets
Java 18 introduces Snippets. Official Programmer's Guide
Snippets are quite helpful:
- Inline snippets are cleaner than
<pre><blockquote></blockquote></pre>blocks - We can move code segments out into separate java files that can be validated by compilation
- The snippets also can support syntax highlighting through some small tricks
- They also natively include copy buttons
But there is a few concerns as well:
- File-based snippets are presented like
{@snippet file="ShowOptional.java" region="example"}in source files; this may be inconvenient for modders in dev env (IDEs might help) - We can choose to inline snippets to mitigate the last problem, but those are harder to check with compilers and would increase mapping file size significantly compared to shipping in separate java files in the extras folder
- As Minecraft itself is most likely stuck on Java 17 for a long while, Java 18's javadoc features may become errors in IDE and an annoyance than being helpful
In addition, in Java 18, there will be an --add-script option, which is required for the trick above and can more easily enable the mapping copy-on-click functionality (we can remodel it after snippet copy functionality as well)
Feel free to debate the pros and cons of bumping to Java 18 using snippets, and about how we should use snippets if we do use it.
I’m totally happy to bump Javadoc generation to require the latest Java, we have done it in the past. It can be done in a way where all other features of yarn can still work on J17 just javadoc gen will require 18. If the feature is in the current early access builds and it’s something we really want to use, it may be possible to start using it now.
I think has you pointed out the biggest blocker might be if IDEs show using the new features as an error, if that is the case then we might just have to wait on Mojang updating. I’m quite hopeful they will track new Java versions as they come out.