@Override
protected void process(StringBuilder sb, Context source, Context target, String template) {
Path currentSourceFile = Generator.currentSourceFile();
boolean packageInfo = currentSourceFile.endsWith("package-info.java") ||
currentSourceFile.endsWith("html");
if (JDK8.equals(target.getOption("jdk")) &&
// Heuristic that we are at the end of the template class
(template.trim().endsWith("}") || packageInfo)) {
template = sb.toString() + template;
// in ordinary Java source files, we replace only imports, to let fully-qualified refs