Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Java 22 #286

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ The default runtime will be used when you open standalone Java files.

## Features

- Supports code from Java 1.5 to Java 21
- Supports code from Java 1.5 to Java 22
- Maven pom.xml project support
- Gradle project support (with experimental Android project import support)
- Standalone Java files support
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,8 @@
"JavaSE-18",
"JavaSE-19",
"JavaSE-20",
"JavaSE-21"
"JavaSE-21",
"JavaSE-22"
],
"description": "Java Execution Environment name. Must be unique."
},
Expand Down
3 changes: 3 additions & 0 deletions server/bin/jdtls.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@echo off
python %~dp0/jdtls %*
pause
63 changes: 37 additions & 26 deletions server/bin/jdtls.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,19 @@
from pathlib import Path
import tempfile

def get_java_executable(validate_java_version):
java_executable = 'java'
def get_java_executable(known_args):
if known_args.java_executable is not None:
java_executable = known_args.java_executable
else:
java_executable = 'java'

if 'JAVA_HOME' in os.environ:
java_exec_to_test = Path(os.environ['JAVA_HOME']) / 'bin' / 'java'
if java_exec_to_test.is_file():
java_executable = java_exec_to_test.resolve()
if 'JAVA_HOME' in os.environ:
ext = '.exe' if platform.system() == 'Windows' else ''
java_exec_to_test = Path(os.environ['JAVA_HOME']) / 'bin' / f'java{ext}'
if java_exec_to_test.is_file():
java_executable = java_exec_to_test.resolve()

if not validate_java_version:
if not known_args.validate_java_version:
return java_executable

out = subprocess.check_output([java_executable, '-version'], stderr = subprocess.STDOUT, universal_newlines=True)
Expand Down Expand Up @@ -70,33 +74,40 @@ def main(args):
jdtls_data_path = os.path.join(tempfile.gettempdir(), "jdtls-" + sha1(cwd_name.encode()).hexdigest())

parser = argparse.ArgumentParser()
parser.add_argument("--validate-java-version", default=True, action=argparse.BooleanOptionalAction)
parser.add_argument('--validate-java-version', action='store_true', default=True)
parser.add_argument('--no-validate-java-version', dest='validate_java_version', action='store_false')
parser.add_argument("--java-executable", help="Path to java executable used to start runtime.")
parser.add_argument("--jvm-arg",
default=[],
action="append",
help="An additional JVM option (can be used multiple times. Note, use with equal sign. For example: --jvm-arg=-Dlog.level=ALL")
parser.add_argument("-data", default=jdtls_data_path)

known_args, args = parser.parse_known_args(args)
java_executable = get_java_executable(known_args.validate_java_version)
java_executable = get_java_executable(known_args)

jdtls_base_path = Path(__file__).parent.parent
shared_config_path = get_shared_config_path(jdtls_base_path)
jar_path = find_equinox_launcher(jdtls_base_path)

os.execvp(java_executable,
["-Declipse.application=org.eclipse.jdt.ls.core.id1",
"-Dosgi.bundles.defaultStartLevel=4",
"-Declipse.product=org.eclipse.jdt.ls.core.product",
"-Dosgi.checkConfiguration=true",
"-Dosgi.sharedConfiguration.area=" + str(shared_config_path),
"-Dosgi.sharedConfiguration.area.readOnly=true",
"-Dosgi.configuration.cascaded=true",
"-Xms1G",
"--add-modules=ALL-SYSTEM",
"--add-opens", "java.base/java.util=ALL-UNNAMED",
"--add-opens", "java.base/java.lang=ALL-UNNAMED"]
+ known_args.jvm_arg
+ ["-jar", jar_path,
"-data", known_args.data]
+ args)
system = platform.system()
exec_args = ["-Declipse.application=org.eclipse.jdt.ls.core.id1",
"-Dosgi.bundles.defaultStartLevel=4",
"-Declipse.product=org.eclipse.jdt.ls.core.product",
"-Dosgi.checkConfiguration=true",
"-Dosgi.sharedConfiguration.area=" + str(shared_config_path),
"-Dosgi.sharedConfiguration.area.readOnly=true",
"-Dosgi.configuration.cascaded=true",
"-Xms1G",
"--add-modules=ALL-SYSTEM",
"--add-opens", "java.base/java.util=ALL-UNNAMED",
"--add-opens", "java.base/java.lang=ALL-UNNAMED"] \
+ known_args.jvm_arg \
+ ["-jar", jar_path,
"-data", known_args.data] \
+ args

if os.name == 'posix':
os.execvp(java_executable, exec_args)
else:
subprocess.run([java_executable] + exec_args)
8 changes: 4 additions & 4 deletions server/config_linux/config.ini
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#This configuration file was written by: org.eclipse.equinox.internal.frameworkadmin.equinox.EquinoxFwConfigFileParser
#Mon Feb 20 09:41:33 EST 2023
#Thu Apr 25 04:11:37 UTC 2024
eclipse.product=org.eclipse.jdt.ls.core.product
osgi.bundles=reference\:file\:ch.qos.logback.classic_1.2.11.jar@4,reference\:file\:ch.qos.logback.core_1.2.11.jar@4,reference\:file\:com.google.gson_2.8.9.v20220111-1409.jar@4,reference\:file\:com.google.gson_2.10.1.jar@4,reference\:file\:com.google.guava_30.1.0.v20210127-2300.jar@4,reference\:file\:com.sun.jna_5.13.0.jar@4,reference\:file\:javax.annotation_1.3.5.v20221203-1659.jar@4,reference\:file\:javax.inject_1.0.0.v20220405-0441.jar@4,reference\:file\:org.apache.ant_1.10.12.v20211102-1452/@4,reference\:file\:org.apache.commons.cli_1.4.0.v20200417-1444.jar@4,reference\:file\:org.apache.commons.codec_1.14.0.v20221112-0806.jar@4,reference\:file\:org.apache.commons.lang3_3.1.0.v201403281430.jar@4,reference\:file\:org.apache.felix.scr_2.2.6.jar@2\:start,reference\:file\:org.eclipse.ant.core_3.6.500.v20220718-1722.jar@4,reference\:file\:org.eclipse.buildship.compat_3.1.7.v20221108-1729-s.jar@4,reference\:file\:org.eclipse.buildship.core_3.1.7.v20221108-1729-s.jar@4,reference\:file\:org.eclipse.compare.core_3.7.100.v20220812-1406.jar@4,reference\:file\:org.eclipse.core.commands_3.10.300.v20221024-2137.jar@4,reference\:file\:org.eclipse.core.contenttype_3.8.200.v20220817-1539.jar@4,reference\:file\:org.eclipse.core.expressions_3.8.200.v20220613-1047.jar@4,reference\:file\:org.eclipse.core.filebuffers_3.7.200.v20220202-1008.jar@4,reference\:file\:org.eclipse.core.filesystem_1.9.500.v20220817-1539.jar@4,reference\:file\:org.eclipse.core.jobs_3.13.300.v20230111-0823.jar@4,reference\:file\:org.eclipse.core.net_1.4.0.v20220813-1037.jar@4,reference\:file\:org.eclipse.core.net.linux_1.0.200.v20220812-1406.jar@4,reference\:file\:org.eclipse.core.resources_3.18.200.v20230209-0754.jar@4,reference\:file\:org.eclipse.core.runtime_3.26.100.v20221021-0005.jar@4\:start,reference\:file\:org.eclipse.core.variables_3.5.100.v20210721-1355.jar@4,reference\:file\:org.eclipse.debug.core_3.20.100.v20230124-1239.jar@4,reference\:file\:org.eclipse.equinox.app_1.6.200.v20220720-2012.jar@4,reference\:file\:org.eclipse.equinox.common_3.17.100.v20230202-1341.jar@2\:start,reference\:file\:org.eclipse.equinox.frameworkadmin_2.2.100.v20220817-1208.jar@4,reference\:file\:org.eclipse.equinox.frameworkadmin.equinox_1.2.200.v20220315-2155.jar@4,reference\:file\:org.eclipse.equinox.launcher_1.6.400.v20210924-0641.jar@4,reference\:file\:org.eclipse.equinox.launcher.gtk.linux.x86_64_1.2.700.v20221108-1024/@4,reference\:file\:org.eclipse.equinox.preferences_3.10.200.v20230120-0604.jar@4,reference\:file\:org.eclipse.equinox.registry_3.11.200.v20220817-1601.jar@4,reference\:file\:org.eclipse.equinox.security_1.3.1000.v20220801-1135.jar@4,reference\:file\:org.eclipse.equinox.security.linux_1.0.300.v20220904-1118/@4,reference\:file\:org.eclipse.equinox.simpleconfigurator_1.4.200.v20221111-1340.jar@4,reference\:file\:org.eclipse.equinox.simpleconfigurator.manipulator_2.2.100.v20221117-1044.jar@4,reference\:file\:org.eclipse.jdt.apt.core_3.7.100.v20221202-1820.jar@4,reference\:file\:org.eclipse.jdt.apt.pluggable.core_1.3.100.v20221201-1549.jar@4,reference\:file\:org.eclipse.jdt.core_3.33.0.v20230215-1114.jar@4,reference\:file\:org.eclipse.jdt.core.compiler.batch_3.33.0.v20230213-1046.jar@4,reference\:file\:org.eclipse.jdt.core.manipulation_1.18.0.v20230209-2203.jar@4,reference\:file\:org.eclipse.jdt.debug_3.20.100.v20230119-1127/@4,reference\:file\:org.eclipse.jdt.junit.core_3.11.600.v20230209-1546.jar@4,reference\:file\:org.eclipse.jdt.junit.runtime_3.7.100.v20230115-0919.jar@4,reference\:file\:org.eclipse.jdt.launching_3.19.900.v20230209-1222.jar@4,reference\:file\:org.eclipse.jdt.ls.core_1.20.0.202302201439.jar@4\:start,reference\:file\:org.eclipse.jdt.ls.filesystem_1.20.0.202302201439.jar@4,reference\:file\:org.eclipse.jdt.ls.logback.appender_1.20.0.202302201439.jar@4,reference\:file\:org.eclipse.lsp4j_0.12.0.v20210402-1305.jar@4,reference\:file\:org.eclipse.lsp4j.jsonrpc_0.12.0.v20210402-1305.jar@4,reference\:file\:org.eclipse.ltk.core.refactoring_3.13.100.v20230117-1625.jar@4,reference\:file\:org.eclipse.m2e.apt.core_2.2.0.20230207-1039.jar@4,reference\:file\:org.eclipse.m2e.core_2.0.6.20230217-0946.jar@4,reference\:file\:org.eclipse.m2e.jdt_2.0.5.20230114-1140.jar@4,reference\:file\:org.eclipse.m2e.maven.runtime_3.8.701.20230209-1606/@4,reference\:file\:org.eclipse.m2e.workspace.cli_0.3.1.jar@4,reference\:file\:org.eclipse.osgi.services_3.11.100.v20221006-1531.jar@4,reference\:file\:org.eclipse.text_3.12.300.v20220921-1010.jar@4,reference\:file\:org.eclipse.xtext.xbase.lib_2.25.0.v20210301-0821.jar@4,reference\:file\:org.gradle.toolingapi_7.4.2.v20220712-0930-s.jar@4,reference\:file\:org.hamcrest.core_1.3.0.v20180420-1519.jar@4,reference\:file\:org.junit_4.13.2.v20211018-1956.jar@4,reference\:file\:org.osgi.service.cm_1.6.1.202109301733.jar@4,reference\:file\:org.osgi.service.component_1.5.1.202212101352.jar@4,reference\:file\:org.osgi.service.device_1.1.1.202109301733.jar@4,reference\:file\:org.osgi.service.event_1.4.1.202109301733.jar@4,reference\:file\:org.osgi.service.metatype_1.4.1.202109301733.jar@4,reference\:file\:org.osgi.service.prefs_1.1.2.202109301733.jar@4,reference\:file\:org.osgi.service.provisioning_1.2.0.201505202024.jar@4,reference\:file\:org.osgi.service.upnp_1.2.1.202109301733.jar@4,reference\:file\:org.osgi.service.useradmin_1.1.1.202109301733.jar@4,reference\:file\:org.osgi.service.wireadmin_1.0.2.202109301733.jar@4,reference\:file\:org.osgi.util.function_1.2.0.202109301733.jar@4,reference\:file\:org.osgi.util.promise_1.3.0.202212101352.jar@4,reference\:file\:slf4j.api_1.7.36.jar@4
osgi.bundles=reference\:file\:ch.qos.logback.classic_1.5.0.jar@2\:start,reference\:file\:ch.qos.logback.core_1.5.0.jar@4,reference\:file\:com.google.gson_2.10.1.v20230109-0753.jar@4,reference\:file\:com.google.guava_33.0.0.jre.jar@4,reference\:file\:com.google.guava.failureaccess_1.0.2.jar@4,reference\:file\:com.sun.jna_5.14.0.v20231211-1200/@4,reference\:file\:jakarta.annotation-api_1.3.5.jar@4,reference\:file\:jakarta.inject.jakarta.inject-api_1.0.5.jar@4,reference\:file\:jakarta.servlet-api_5.0.0.jar@4,reference\:file\:org.apache.ant_1.10.14.v20230922-1200/@4,reference\:file\:org.apache.aries.spifly.dynamic.bundle_1.3.7.jar@2\:start,reference\:file\:org.apache.commons.cli_1.6.0.jar@4,reference\:file\:org.apache.commons.commons-codec_1.16.0.jar@4,reference\:file\:org.apache.commons.lang3_3.14.0.jar@4,reference\:file\:org.apache.felix.scr_2.2.10.jar@2\:start,reference\:file\:org.eclipse.ant.core_3.7.400.v20240413-1529.jar@4,reference\:file\:org.eclipse.buildship.compat_3.1.10.v20240304-0555-s.jar@4,reference\:file\:org.eclipse.buildship.core_3.1.10.v20240304-0555-s.jar@4,reference\:file\:org.eclipse.compare.core_3.8.500.v20240415-1311.jar@4,reference\:file\:org.eclipse.core.commands_3.12.100.v20240322-0723.jar@4,reference\:file\:org.eclipse.core.contenttype_3.9.400.v20240413-1529.jar@4,reference\:file\:org.eclipse.core.expressions_3.9.400.v20240413-1529.jar@4,reference\:file\:org.eclipse.core.filebuffers_3.8.300.v20240207-1054.jar@4,reference\:file\:org.eclipse.core.filesystem_1.10.400.v20240416-0842.jar@4,reference\:file\:org.eclipse.core.jobs_3.15.300.v20240413-1529.jar@4,reference\:file\:org.eclipse.core.net_1.5.400.v20240413-1529.jar@4,reference\:file\:org.eclipse.core.net.linux_1.1.200.v20240413-1529.jar@4,reference\:file\:org.eclipse.core.resources_3.20.200.v20240413-1529.jar@4,reference\:file\:org.eclipse.core.runtime_3.31.100.v20240415-0528.jar@4\:start,reference\:file\:org.eclipse.core.variables_3.6.400.v20240413-1529.jar@4,reference\:file\:org.eclipse.debug.core_3.21.400.v20240415-0528.jar@4,reference\:file\:org.eclipse.equinox.app_1.7.100.v20240321-1445.jar@4,reference\:file\:org.eclipse.equinox.common_3.19.100.v20240321-1445.jar@2\:start,reference\:file\:org.eclipse.equinox.frameworkadmin_2.3.200.v20240321-1450.jar@4,reference\:file\:org.eclipse.equinox.frameworkadmin.equinox_1.3.200.v20240321-1450.jar@4,reference\:file\:org.eclipse.equinox.http.service.api_1.2.2.v20231218-2126.jar@4,reference\:file\:org.eclipse.equinox.launcher_1.6.800.v20240330-1250.jar@4,reference\:file\:org.eclipse.equinox.launcher.gtk.linux.x86_64_1.2.900.v20240129-1338/@4,reference\:file\:org.eclipse.equinox.preferences_3.11.100.v20240327-0645.jar@4,reference\:file\:org.eclipse.equinox.registry_3.12.100.v20240321-1445.jar@4,reference\:file\:org.eclipse.equinox.security_1.4.300.v20240326-2051.jar@4,reference\:file\:org.eclipse.equinox.security.linux_1.1.300.v20240324-1645.jar@4,reference\:file\:org.eclipse.equinox.simpleconfigurator_1.5.300.v20240329-0848.jar@4,reference\:file\:org.eclipse.equinox.simpleconfigurator.manipulator_2.3.200.v20240321-1450.jar@4,reference\:file\:org.eclipse.jdt.apt.core_3.8.400.v20240326-0804.jar@4,reference\:file\:org.eclipse.jdt.apt.pluggable.core_1.4.400.v20240321-1252.jar@4,reference\:file\:org.eclipse.jdt.core_3.38.0.v20240415-2034.jar@4,reference\:file\:org.eclipse.jdt.core.compiler.batch_3.38.0.v20240417-1011.jar@4,reference\:file\:org.eclipse.jdt.core.manipulation_1.21.100.v20240416-2323.jar@4,reference\:file\:org.eclipse.jdt.debug_3.21.400.v20240414-1129/@4,reference\:file\:org.eclipse.jdt.junit.core_3.13.200.v20240329-0922.jar@4,reference\:file\:org.eclipse.jdt.junit.runtime_3.7.400.v20231214-1952.jar@4,reference\:file\:org.eclipse.jdt.launching_3.21.200.v20240416-1159.jar@4,reference\:file\:org.eclipse.jdt.ls.core_1.35.0.202404250410.jar@4\:start,reference\:file\:org.eclipse.jdt.ls.filesystem_1.35.0.202404250410.jar@4,reference\:file\:org.eclipse.jdt.ls.logback.appender_1.35.0.202404250410.jar@4,reference\:file\:org.eclipse.jetty.servlet-api_4.0.6.jar@4,reference\:file\:org.eclipse.lsp4j_0.22.0.v20240213-2011.jar@4,reference\:file\:org.eclipse.lsp4j.jsonrpc_0.22.0.v20240213-2011.jar@4,reference\:file\:org.eclipse.ltk.core.refactoring_3.14.400.v20240321-1245.jar@4,reference\:file\:org.eclipse.m2e.apt.core_2.2.201.20240125-1714.jar@4,reference\:file\:org.eclipse.m2e.core_2.6.0.20240220-1109.jar@4,reference\:file\:org.eclipse.m2e.jdt_2.3.400.20240219-2341.jar@4,reference\:file\:org.eclipse.m2e.maven.runtime_3.9.600.20231203-1234/@4,reference\:file\:org.eclipse.m2e.workspace.cli_0.3.1.jar@4,reference\:file\:org.eclipse.osgi.services_3.12.100.v20240327-0645.jar@4,reference\:file\:org.eclipse.search.core_3.16.200.v20240415-0954.jar@4,reference\:file\:org.eclipse.text_3.14.100.v20240321-1245.jar@4,reference\:file\:org.eclipse.xtext.xbase.lib_2.34.0.v20240227-0940.jar@4,reference\:file\:org.gradle.toolingapi_8.1.1.v20240304-0555-s.jar@4,reference\:file\:org.hamcrest_2.2.0.jar@4,reference\:file\:org.hamcrest.core_2.2.0.v20230809-1000.jar@4,reference\:file\:org.junit_4.13.2.v20230809-1000.jar@4,reference\:file\:org.objectweb.asm_9.7.0.jar@4,reference\:file\:org.objectweb.asm.commons_9.7.0.jar@4,reference\:file\:org.objectweb.asm.tree_9.7.0.jar@4,reference\:file\:org.objectweb.asm.tree.analysis_9.7.0.jar@4,reference\:file\:org.objectweb.asm.util_9.7.0.jar@4,reference\:file\:org.osgi.service.cm_1.6.1.202109301733.jar@4,reference\:file\:org.osgi.service.component_1.5.1.202212101352.jar@4,reference\:file\:org.osgi.service.device_1.1.1.202109301733.jar@4,reference\:file\:org.osgi.service.event_1.4.1.202109301733.jar@4,reference\:file\:org.osgi.service.http.whiteboard_1.1.1.202109301733.jar@4,reference\:file\:org.osgi.service.metatype_1.4.1.202109301733.jar@4,reference\:file\:org.osgi.service.prefs_1.1.2.202109301733.jar@4,reference\:file\:org.osgi.service.provisioning_1.2.0.201505202024.jar@4,reference\:file\:org.osgi.service.upnp_1.2.1.202109301733.jar@4,reference\:file\:org.osgi.service.useradmin_1.1.1.202109301733.jar@4,reference\:file\:org.osgi.service.wireadmin_1.0.2.202109301733.jar@4,reference\:file\:org.osgi.util.function_1.2.0.202109301733.jar@4,reference\:file\:org.osgi.util.promise_1.3.0.202212101352.jar@4,reference\:file\:slf4j.api_2.0.13.jar@4
[email protected]/../p2
eclipse.p2.profile=DefaultProfile
osgi.bundles.defaultStartLevel=4
eclipse.application=org.eclipse.jdt.ls.core.id1
osgi.framework=file\:plugins/org.eclipse.osgi_3.18.300.v20230211-2021.jar
osgi.framework.extensions=reference\:file\:org.eclipse.osgi.compatibility.state_1.2.800.v20221116-1440.jar
osgi.framework=file\:plugins/org.eclipse.osgi_3.19.100.v20240416-1547.jar
osgi.framework.extensions=reference\:file\:org.eclipse.osgi.compatibility.state_1.2.1000.v20240213-1057.jar
Loading