From fbcc0308f90e4e970b44df47c171f48e52f47bf1 Mon Sep 17 00:00:00 2001 From: Mickael Istria Date: Wed, 23 Oct 2024 21:53:19 +0200 Subject: [PATCH] Avoid NumberFormatException when trying to get latest JRE. --- .../model/org/eclipse/jdt/internal/core/CompilationUnit.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnit.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnit.java index cee22e767f4..a7ab47a2525 100644 --- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnit.java +++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnit.java @@ -502,8 +502,9 @@ public org.eclipse.jdt.core.dom.CompilationUnit getOrBuildAST(WorkingCopyOwner w return this.ast; } Map 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