Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/no_agent' into no_a…
Browse files Browse the repository at this point in the history
…gent
  • Loading branch information
Thrameos committed Nov 28, 2024
2 parents 70cc3c1 + 1265979 commit a0b2b3e
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions jpype/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,30 +275,28 @@ def startJVM(
raise RuntimeError("Unable to find org.jpype.jar support library at " + support_lib)

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

java_class_path = _expandClassPath(classpath)
java_class_path.append(support_lib)
java_class_path = _classpath._SEP.join(java_class_path)

remove = None
# Make sure our module is always on the classpath
if java_class_path.isascii():
# no problems
extra_jvm_args += ['-Djava.class.path=%s'%java_class_path ]
late_load = False
elif system_class_loader:
# https://bugs.openjdk.org/browse/JDK-8079633?jql=text%20~%20%22ParseUtil%22
raise ValueError("system classloader cannot be specified with non ascii characters in the classpath")
else:
if not java_class_path.isascii():
if system_class_loader:
# https://bugs.openjdk.org/browse/JDK-8079633?jql=text%20~%20%22ParseUtil%22
raise ValueError("system classloader cannot be specified with non ascii characters in the classpath")

# If we are not installed on an ascii path then we will need to copy the jar to a new location
if not support_lib.isascii():
import tempfile
import shutil
tmp = tempfile.gettempdir()
if not tmp.isascii():
raise ValueError("Unable to create ascii temp directory. Clear TEMPDIR, TEMP, and TMP environment variables")
support_lib2 = os.path.join(tmp, "org.jpype.jar")
shutil.copyfile(support_lib, support_lib2)
support_lib = support_lib2
remove = os.path.join(tmp, "org.jpype.jar")
shutil.copyfile(support_lib, remove)
support_lib = remove

# ok, setup the jpype system classloader and add to the path after startup
# this guarentees all classes have the same permissions as they did in the past
Expand All @@ -307,6 +305,11 @@ def startJVM(
'-Djava.class.path=%s'%support_lib,
'-Xshare:off'
]
late_load = True
else:
# no problems
extra_jvm_args += ['-Djava.class.path=%s'%java_class_path ]
late_load = False

if agent:
extra_jvm_args += ['-javaagent:' + support_lib]
Expand Down Expand Up @@ -356,6 +359,8 @@ def startJVM(
for cp in _expandClassPath(classpath):
print("Late load", cp)
cl.addFile(Path(cp))
if remove is not None:
os.remove(remove)


def initializeResources():
Expand Down

0 comments on commit a0b2b3e

Please sign in to comment.