-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathjperl
More file actions
executable file
·58 lines (49 loc) · 2.48 KB
/
jperl
File metadata and controls
executable file
·58 lines (49 loc) · 2.48 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
#!/bin/bash
#
# PerlOnJava Launcher Script
# This script launches the PerlOnJava runtime environment, which provides
# a Java-based implementation of the Perl programming language.
# Repository: github.com/fglock/PerlOnJava
#
# Get the directory where this script is located, resolving symlinks
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# Get the full path to this script to set $^X correctly
JPERL_PATH="$(readlink -f "${BASH_SOURCE[0]}" 2>/dev/null || echo "$SCRIPT_DIR/jperl")"
# Export environment variable for PerlOnJava to use as $^X
export PERLONJAVA_EXECUTABLE="$JPERL_PATH"
# Check development environment first (target directory)
if [ -f "$SCRIPT_DIR/target/perlonjava-5.42.0.jar" ]; then
JAR_PATH="$SCRIPT_DIR/target/perlonjava-5.42.0.jar"
elif [ -f "$SCRIPT_DIR/perlonjava-5.42.0.jar" ]; then
# Docker or local installation with jar in same directory
JAR_PATH="$SCRIPT_DIR/perlonjava-5.42.0.jar"
else
# Use installed package path (when installed via deb package)
JAR_PATH="$SCRIPT_DIR/../lib/perlonjava-5.42.0.jar"
fi
# Determine JVM options based on Java version
# --enable-native-access=ALL-UNNAMED: Required by FFM (Foreign Function & Memory) API
# for native system calls (file operations, process management).
JVM_OPTS="--enable-native-access=ALL-UNNAMED"
# Note on JVM heap settings: do NOT set -XX:SoftMaxHeapSize below -Xmx.
# That combination triggers an aggressive G1 GC cadence that interacts
# pathologically with PerlOnJava's weak-ref / selective-refcount
# machinery — DBIx-Class t/96_is_deteministic_value.t hangs at 100% CPU
# under -XX:SoftMaxHeapSize=2g -Xmx4g while passing in seconds without
# the soft cap (or with SoftMax >= Xmx). The JVM's auto-default
# (MaxHeapSize = 1/4 of system RAM) is honored when nothing is set.
# Override via `JPERL_OPTS="-Xmx<size>"` in the environment if needed
# (e.g. memory-intensive tests like re/pat.t).
# Java 23+ warns about sun.misc.Unsafe usage (JEP 471). Add flag to suppress
# warnings from transitive libraries (ASM, ICU4J, etc.) that still use it.
JAVA_VERSION=$(java -version 2>&1 | head -1 | sed 's/.*version "\([0-9]*\).*/\1/')
if [ "$JAVA_VERSION" -ge 23 ] 2>/dev/null; then
JVM_OPTS="$JVM_OPTS --sun-misc-unsafe-memory-access=allow"
fi
# Note: Only include CLASSPATH if set, to avoid empty prefix that would add current dir to path
if [ -n "$CLASSPATH" ]; then
CP="$CLASSPATH:$JAR_PATH"
else
CP="$JAR_PATH"
fi
exec java $JVM_OPTS ${JPERL_OPTS} -cp "$CP" org.perlonjava.app.cli.Main "$@"