Skip to content

Commit

Permalink
Why must we specify stuff on our private methods?
Browse files Browse the repository at this point in the history
  • Loading branch information
Thrameos committed Nov 28, 2024
1 parent 4344295 commit 3cefadd
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions jpype/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def isJVMStarted():
return _jpype.isStarted()


def _getOption(args, var, sep=None, keep=False) -> list[str]:
def _getOption(args, var, sep=None, keep=False):
""" Get an option and remove it from the current jvm arguments list """
for i,v in enumerate(args):
if not isinstance(v, str):
Expand Down Expand Up @@ -224,28 +224,28 @@ def startJVM(
raise OSError('JVM cannot be restarted')

# Convert to list
jvmargs = list(jvmargs)
jvm_args: list[str] = list(jvmargs)

# JVM path
if jvmargs:
if jvm_args:
# jvm is the first argument the first argument is a path or None
if jvmargs[0] is None or (isinstance(jvmargs[0], str) and not jvmargs[0].startswith('-')):
if jvmpath:
if jvm_args[0] is None or (isinstance(jvm_args[0], str) and not jvm_args[0].startswith('-')):
if jvm_path:
raise TypeError('jvmpath specified twice')
jvmpath = jvmargs[0]
jvmargs = jvmargs[1:]
jvm_path = jvm_args[0]
jvm_args = jvm_args[1:]

if not jvmpath:
jvmpath = getDefaultJVMPath()
else:
# Allow the path to be a PathLike.
jvmpath = os.fspath(jvmpath)
jvmpath = os.fspath(jvm_path)

# Handle strings and list of strings.
extra_jvm_args: list[str] = []

# Classpath handling
old_classpath = _getOption(jvmargs, "-Djava.class.path", _classpath._SEP)
old_classpath = _getOption(jvm_args, "-Djava.class.path", _classpath._SEP)
if old_classpath:
# Old style, specified in the arguments
if classpath is not None:
Expand All @@ -258,7 +258,7 @@ def startJVM(

# Code for 1.6 release when we add module support
# # Modulepath handling
# old_modulepath = _getOption(jvmargs, "--module-path", _classpath._SEP)
# old_modulepath = _getOption(jvm_args, "--module-path", _classpath._SEP)
# if old_modulepath:
# # Old style, specified in the arguments
# if modulepath is not None:
Expand All @@ -274,7 +274,7 @@ def startJVM(
if not os.path.exists(support_lib):
raise RuntimeError("Unable to find org.jpype.jar support library at " + support_lib)

system_class_loader = _getOption(jvmargs, "-Djava.system.class.loader", keep=True)
system_class_loader = _getOption(jvm_args, "-Djava.system.class.loader", keep=True)

java_class_path = _expandClassPath(classpath)
java_class_path.append(support_lib)
Expand Down Expand Up @@ -324,7 +324,7 @@ def startJVM(
# Keep the current locale settings, else Java will replace them.
prior = [locale.getlocale(i) for i in categories]
# Start the JVM
_jpype.startup(jvmpath, tuple(jvmargs + extra_jvm_args),
_jpype.startup(jvmpath, tuple(jvm_args + extra_jvm_args),
ignoreUnrecognized, convertStrings, interrupt)
# Collect required resources for operation
initializeResources()
Expand Down

0 comments on commit 3cefadd

Please sign in to comment.