Originally published at: https://javacc.com/2020/03/22/milestone-javacc-21-now-supports-the-java-language-up-to-jdk-13/
Today, I put in a little incremental effort on the included Java grammar and nailed the last couple of remaining cases that prevented it from parsing all of the java source files in the src.zip included in the JDK 13. There were a few remaining constructs that were still tripping it up and I finally decided to put in the extra effort to nail them.
This Java grammar, though used internally inside JavaCC, is also separately usable on its own and you are quite free to use it in any of your own projects, commercial or open source, that require an up-to-date Java parser.
If you want to try it out, here is the magic incantation to run the test harness:
git clone https://github.com/javacc21/javacc21.git cd javacc21 ant test cd examples/java java JParse <directory or file(s)>
Now, since this is the Java grammar that is INCLUDEd in JavaCC internally (see here) , this means that you now have the full up-to-date Java language available when using JavaCC — well, when using the most advanced version of the tool, that is, i.e. JavaCC 21. You should be able to use all of the most recent constructs within your JavaCC grammars, both in code actions and in injections.
I guess I should also make clear that that JavaCC 21 does not actually require a JDK any later than Java 8. If you do not use any Java language constructs or API’s any later than Java 8, the code you generate will compile and run with Java >=8. However, quite obviously really, if you use java language constructs or API’s that were only introduced in a later JDK, say in Java 11 for example, then your generated code will need Java >=11. It’s up to you.
N.B. JavaCC 21 does not support any JDK version prior to 1.8.
This seems quite reasonable, since Java 8 has been available for six years, at this point.