RFR: JDK-8278795: Create test library and tests for langtools snippets

Jonathan Gibbons jjg at openjdk.java.net
Thu Dec 23 21:16:15 UTC 2021


On Thu, 16 Dec 2021 16:07:07 GMT, Hannes Wallnöfer <hannesw at openjdk.org> wrote:

> Very impressive how much functionality you managed to pack into this first version of SnippetUtils!

Thanks; yeah, it helped to have some interesting snippets that I wanted to test.

> 
> The snippet kind inferral code is (as is usual with regex-based solutions) not especially nice to look at but seems to solve the problem with very few lines.

The regex code is not entirely new, since there is similar code in `ToolBox.writeJavaFiles`.  That being said, it would be an interesting (separate) exercise to try and use the javac lever to infer the kind. But, there is currently no public API for anything like that, so for now, regex will have to do. And, the philosophy is somewhat "if it works for you, use it; if it doesn't: you can explicitly specify the snippet kind in other overloads of the `parse` method.

-------------

PR: https://git.openjdk.java.net/jdk/pull/6839


More information about the compiler-dev mailing list