Skip to content

Commit

Permalink
Enable Java Vector module for Java 22 in launcher.py
Browse files Browse the repository at this point in the history
  • Loading branch information
raunaqmorarka authored and electrum committed May 21, 2024
1 parent 1996e04 commit 46bf4ac
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions launcher/src/main/scripts/bin/launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import errno
import os
import platform
import re
import subprocess
import sys
import traceback
Expand Down Expand Up @@ -195,11 +196,7 @@ def build_java_execution(options, daemon):
if options.log_levels_set and not exists(options.log_levels):
raise Exception('Log levels file is missing: %s' % options.log_levels)

with open(os.devnull, 'w') as devnull:
try:
subprocess.check_call(['java', '-version'], stdout=devnull, stderr=devnull)
except (OSError, subprocess.CalledProcessError):
raise Exception('Java is not installed')
java_version = parse_java_version()

properties = options.properties.copy()

Expand All @@ -225,6 +222,8 @@ def build_java_execution(options, daemon):

command = ['java', '-cp', classpath]
command += jvm_properties + options.jvm_options + system_properties
if java_version == '22':
command += ['--add-modules=jdk.incubator.vector']
command += [main_class]

if options.verbose:
Expand All @@ -244,6 +243,19 @@ def build_java_execution(options, daemon):

return command, env

def parse_java_version():
try:
output = subprocess.check_output(['java', '-version'], stderr=subprocess.STDOUT).decode()
except (OSError, subprocess.CalledProcessError):
raise Exception('Java is not installed')

version_pattern = re.compile(r'version "(.*)"')
match = version_pattern.search(output)
if match:
java_version = match.group(1)
return java_version.split('.')[0]
else:
return None

def run(process, options):
if process.alive():
Expand Down

0 comments on commit 46bf4ac

Please sign in to comment.