Skip to content

Commit

Permalink
Avoid NumberFormatException when trying to get latest JRE.
Browse files Browse the repository at this point in the history
  • Loading branch information
mickaelistria committed Oct 23, 2024
1 parent b379bd3 commit fbcc030
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -502,8 +502,9 @@ public org.eclipse.jdt.core.dom.CompilationUnit getOrBuildAST(WorkingCopyOwner w
return this.ast;
}
Map<String, String> options = getOptions(true);
int jlsLevel = Integer.parseInt(options.getOrDefault(JavaCore.COMPILER_SOURCE, Integer.toString(AST.getJLSLatest())));
ASTParser parser = ASTParser.newParser(jlsLevel);
ASTParser parser = ASTParser.newParser(new AST(options).apiLevel()); // go through AST constructor to convert options to apiLevel
// but we should probably instead just use the latest Java version
// supported by the compiler
parser.setWorkingCopyOwner(workingCopyOwner);
parser.setSource(this);
// greedily enable everything assuming the AST will be used extensively for edition
Expand Down

0 comments on commit fbcc030

Please sign in to comment.