Some of the code in the OpenJDK seams to be using a templating system. E.g.:
- https://github.com/openjdk/jdk/blob/master/src/java.base/share/classes/java/nio/X-Buffer.java.template
- https://github.com/openjdk/jdk/blob/master/src/java.base/share/classes/java/nio/ByteBufferAs-X-Buffer.java.template
Can this templating system be used by normal Java developers in one's own code to generate repetitive code? How is the code template set up? What is the syntax?
In Java 11, it appears that the template files are translated to Java using a build in tool called "spp". The comment in the (Java) source code says:
The comments continue to summarize the preprocessor syntax. You can find it all in the source tree in the "make/jdk/src/classes/build/tools/spp" directory.
There is nothing to stop you doing that. However, the tool is not part of the official Java tool chain, and it is not included in the distros generated by an OpenJDK build.
Erm ... you write it using a text editor, I guess. You can find the command syntax in the source code, and examples in the generated build Makefiles.
See above. It's documented in the source code.
Note: nothing in the above should be construed as advice on whether or not to use "Spp".