-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathjperl.bat
More file actions
executable file
·78 lines (69 loc) · 3.52 KB
/
Copy pathjperl.bat
File metadata and controls
executable file
·78 lines (69 loc) · 3.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
@echo off
rem PerlOnJava Launcher Script for Windows
rem This script launches the PerlOnJava runtime environment, which provides
rem a Java-based implementation of the Perl programming language.
rem Repository: github.com/fglock/PerlOnJava
rem Get the directory where this script is located
set SCRIPT_DIR=%~dp0
rem Get the full path to this script to set $^X correctly
set JPERL_PATH=%~f0
rem Set environment variable for PerlOnJava to use as $^X
set PERLONJAVA_EXECUTABLE=%JPERL_PATH%
rem Java 24 virtual threads are the default Perl ithread carrier. Preserve an
rem explicit caller selection (JPERL_THREAD_MODE=platform remains supported).
if not defined JPERL_THREAD_MODE set JPERL_THREAD_MODE=virtual
rem Determine JVM options based on Java version
rem --enable-native-access=ALL-UNNAMED: Required by FFM (Foreign Function & Memory) API
rem for native system calls (file operations, process management).
rem Perl call frames currently use the Java stack. Keep enough stack for
rem ecosystem recursion guards such as Catalyst's default 1000-call limit.
rem A later -Xss value in JPERL_OPTS overrides this default.
set JVM_OPTS=-Xss16m --enable-native-access=ALL-UNNAMED
rem Note on JVM heap settings: do NOT set -XX:SoftMaxHeapSize below -Xmx.
rem That combination triggers an aggressive G1 GC cadence that interacts
rem pathologically with PerlOnJava's weak-ref / selective-refcount
rem machinery (DBIx-Class t/96_is_deteministic_value.t hangs at 100% CPU
rem under SoftMaxHeapSize=2g + Xmx=4g). The JVM auto-default
rem (MaxHeapSize = 1/4 of system RAM) is honored when nothing is set.
rem Override via `JPERL_OPTS=-Xmx<size>` in the environment if needed.
rem Java 23+ warns about sun.misc.Unsafe usage (JEP 471). Add flag to suppress
rem warnings from transitive libraries (ASM, ICU4J, etc.) that still use it.
if not defined PERLONJAVA_JAVA_BIN (
for /f "delims=" %%j in ('where java 2^>nul') do if not defined PERLONJAVA_JAVA_BIN set "PERLONJAVA_JAVA_BIN=%%j"
)
if not defined PERLONJAVA_JAVA_BIN (
echo ERROR: PerlOnJava requires Java 24 or later; java was not found in PATH. 1>&2
exit /b 1
)
set JAVA_VERSION=
rem CALL is required when a quoted absolute executable starts the command
rem parsed by FOR /F; without it cmd.exe treats the nested quote as syntax.
for /f "tokens=3" %%v in ('call "%PERLONJAVA_JAVA_BIN%" -version 2^>^&1') do if not defined JAVA_VERSION (
for /f "tokens=1 delims=." %%m in ("%%~v") do (
set JAVA_VERSION=%%m
if %%m GEQ 23 set JVM_OPTS=%JVM_OPTS% --sun-misc-unsafe-memory-access=allow
)
)
if not defined JAVA_VERSION (
echo ERROR: PerlOnJava requires Java 24 or later; Java version could not be determined. 1>&2
exit /b 1
)
if %JAVA_VERSION% LSS 24 (
echo ERROR: PerlOnJava requires Java 24 or later ^(found: %JAVA_VERSION%^). 1>&2
exit /b 1
)
rem During Maven tests the packaged JAR does not exist yet. Use compiled
rem classes plus the runtime classpath generated by maven-dependency-plugin.
set "PERLONJAVA_CP=%SCRIPT_DIR%..\lib\perlonjava-5.44.1.jar"
if exist "%SCRIPT_DIR%target\perlonjava-5.44.1.jar" (
set "PERLONJAVA_CP=%SCRIPT_DIR%target\perlonjava-5.44.1.jar"
) else (
if exist "%SCRIPT_DIR%target\classes" (
if exist "%SCRIPT_DIR%target\jperl-test-classpath.txt" (
set /p MAVEN_RUNTIME_CP=<"%SCRIPT_DIR%target\jperl-test-classpath.txt"
set "PERLONJAVA_CP=%SCRIPT_DIR%target\classes;%MAVEN_RUNTIME_CP%"
)
)
)
rem Launch Java
"%PERLONJAVA_JAVA_BIN%" %JVM_OPTS% %JPERL_OPTS% -cp "%CLASSPATH%;%PERLONJAVA_CP%" org.perlonjava.app.cli.Main %*