Source:
public static CompilationUnitTree parse( String version, String unitName, String source, boolean resolveBindings, List<File> classpath ) { ASTParser astParser = ASTParser.newParser(AST.JLS12); Map<String, String> options = new HashMap<>(); options.put(JavaCore.COMPILER_SOURCE, version); options.put(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, "enabled"); astParser.setCompilerOptions(options); astParser.setEnvironment( classpath.stream().map(File::getAbsolutePath).toArray(String[]::new), new String[]{}, new String[]{}, true ); astParser.setUnitName(unitName); astParser.setResolveBindings(resolveBindings); astParser.setBindingsRecovery(true); char[] sourceChars = source.toCharArray(); astParser.setSource(sourceChars); CompilationUnit astNode = (CompilationUnit) astParser.createAST(null); for (IProblem problem : astNode.getProblems()) { if (!problem.isError()) { continue; } if ((problem.getID() & IProblem.Syntax) == 0) { continue; } final int line = problem.getSourceLineNumber(); final int column = astNode.getColumnNumber(problem.getSourceStart()); throw new RecognitionException(line, "Parse error at line " + line + " column " + column + ": " + problem.getMessage()); } JParser converter = new JParser(); converter.sema = new JSema(astNode.getAST()); converter.compilationUnit = astNode; converter.tokenManager = new TokenManager(lex(version, unitName, sourceChars), source, new DefaultCodeFormatterOptions(new HashMap<>())); converter.labels = new LinkedList<>(); JavaTree.CompilationUnitTreeImpl tree = converter.convertCompilationUnit(astNode); tree.sema = converter.sema; setParents(tree); return tree; }

Target:
public static CompilationUnitTree parse( String version, String unitName, String source, boolean resolveBindings, List<File> classpath ) { ASTParser astParser = ASTParser.newParser(AST.JLS12); Map<String, String> options = new HashMap<>(); options.put(JavaCore.COMPILER_SOURCE, version); options.put(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, "enabled"); astParser.setCompilerOptions(options); astParser.setEnvironment( classpath.stream().map(File::getAbsolutePath).toArray(String[]::new), new String[]{}, new String[]{}, true ); astParser.setUnitName(unitName); astParser.setResolveBindings(resolveBindings); astParser.setBindingsRecovery(true); char[] sourceChars = source.toCharArray(); astParser.setSource(sourceChars); CompilationUnit astNode = (CompilationUnit) astParser.createAST(null); for (IProblem problem : astNode.getProblems()) { if (!problem.isError()) { continue; } if ((problem.getID() & IProblem.Syntax) == 0) { continue; } final int line = problem.getSourceLineNumber(); final int column = astNode.getColumnNumber(problem.getSourceStart()); throw new RecognitionException(line, "Parse error at line " + line + " column " + column + ": " + problem.getMessage()); } JParser converter = new JParser(); converter.sema = new JSema(astNode.getAST()); converter.compilationUnit = astNode; converter.tokenManager = new TokenManager(lex(version, unitName, sourceChars), source, new DefaultCodeFormatterOptions(new HashMap<>())); JavaTree.CompilationUnitTreeImpl tree = converter.convertCompilationUnit(astNode); tree.sema = converter.sema; setParents(tree); return tree; }