Skip to content

Commit

Permalink
fix: revert the need for extra flags for 17
Browse files Browse the repository at this point in the history
This is no longer needed as of scalameta/metals#5375. You can see more context for this in scalameta/metals#5453 (comment).
  • Loading branch information
ckipp01 committed Jul 18, 2023
1 parent cd50bfe commit 56b6ebb
Showing 1 changed file with 1 addition and 35 deletions.
36 changes: 1 addition & 35 deletions lua/metals/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -355,41 +355,7 @@ local function validate_config(config, bufnr)

local passed_in_options = config.settings.metals.serverProperties or {}

local get_java_version = function(java_home)
java_home = java_home or os.getenv("JAVA_HOME")
if java_home == nil then
return nil
else
local release = Path:new(java_home, "release")
if release:exists() then
local version_line
for line in io.lines(release.filename) do
if util.starts_with(line, "JAVA_VERSION") then
version_line = line
break
end
end

local version = vim.version.parse(version_line:sub(14, version_line:len()))
return version
else
return nil
end
end
end

local java_version = get_java_version(config.settings.metals.javaHome)

local extra_java_opts = {}
if java_version and vim.version.gt(java_version, { 17, 0, 0 }) then
extra_java_opts = {
"--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED",
"--add-opens=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
"--add-opens=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
}
end

local all_opts = util.merge_lists(util.merge_lists(passed_in_options, valid_java_opts), extra_java_opts)
local all_opts = util.merge_lists(passed_in_options, valid_java_opts)

for i, opt in ipairs(all_opts) do
-- In order to pass these options to coursier they need to be prefaced with `-J`
Expand Down

0 comments on commit 56b6ebb

Please sign in to comment.