jruby-launcher 2.0.0.pr1-java → 2.0.0.pre3-java

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 50562b25fc7dd7b82d467334c1251f8364e6f41d8c92a0ffa8473a0039a1efe6
4
- data.tar.gz: b02e2cc0bd6fcdcf51c7d466a4d1d3c3de74f3e1e8a86760f603c8a4305fc288
3
+ metadata.gz: 66622259dbdee0e98846fb968d3a563a76b6e5e2c2f7b5a582c1d7deea490f30
4
+ data.tar.gz: 54d1ea1244e8a127b27b6b691da3bbe55e64709c9e04da10f8d68ebbe3a23c7f
5
5
  SHA512:
6
- metadata.gz: 909040c18c0dc539426554bc2a67d7ca93030d77cbbab67ec7a63920fcb3b1fe1eacbe87378fce63a949a645d9cba9ecf745d258230a97c7963dc6d82ecad559
7
- data.tar.gz: 0032dcc96cb9fbcfcfe4eed270c4dc3e5340e595ff7cd0a638f156df8b3490508c59131c1da016aa9f9d3fa5b2846297509297df49f2f9106f8034765e7ab26f
6
+ metadata.gz: 88721cb3c1123f98074a748b7411d0be1cca648ec706d7dc77bea488af1eadb5405a76f8c42162aa195ccbe74ef5c6e927d2aab8cafcdd9f7906e949791ebc74
7
+ data.tar.gz: ce7d34b70c77bbb60e631a0f4c7306c0d391c09bd9583b0361c10ff6dbeefa407141f4a74d622ceb12064f00c3ff10c04e47d73740b6da528399073e4c12e8e7
data/Makefile CHANGED
@@ -3,9 +3,6 @@ PREFIX = notspecified
3
3
  BINDIR = $(PREFIX)/bin
4
4
  JRUBY_VERSION = notspecified
5
5
  JRUBY_MODULE = 1
6
- INSTALLDIR = $(PREFIX)/lib/ruby/shared/rubygems/defaults
7
- INSTALLDIR9000 = $(PREFIX)/lib/ruby/stdlib/rubygems/defaults
8
- OLDINSTALLDIR = $(PREFIX)/lib/ruby/site_ruby/1.8/rubygems/defaults
9
6
 
10
7
  ifeq (true,$(shell test -x $(BINDIR)/jruby && echo true))
11
8
  RAKE=$(BINDIR)/jruby -S rake
@@ -42,22 +39,7 @@ install:
42
39
  @if [ -f $(BINDIR)/jruby -a ! -w $(BINDIR)/jruby ]; then echo "Cannot write to '$(BINDIR)/jruby'."; exit 1; fi
43
40
  cp ./jruby $(BINDIR)/jruby
44
41
  @if [ x$(PREFIX) = xnotspecified ]; then echo "Please define where to install by passing PREFIX=<jruby-home>."; exit 1; fi
45
- @if [ ! -w $(INSTALLDIR) ]; then \
46
- if [ ! -w $(OLDINSTALLDIR) ]; then \
47
- if [ ! -w $(INSTALLDIR9000) ]; then \
48
- echo "Neither '$(INSTALLDIR9000)' nor '$(INSTALLDIR)' nor '$(OLDINSTALLDIR)' exist and are writable"; exit 1; \
49
- else \
50
- echo "cp ./lib/rubygems/defaults/jruby_native.rb $(INSTALLDIR9000)"; \
51
- cp ./lib/rubygems/defaults/jruby_native.rb $(INSTALLDIR9000); \
52
- fi; \
53
- else \
54
- echo "cp ./lib/rubygems/defaults/jruby_native.rb $(OLDINSTALLDIR)"; \
55
- cp ./lib/rubygems/defaults/jruby_native.rb $(OLDINSTALLDIR); \
56
- fi; \
57
- else \
58
- echo "cp ./lib/rubygems/defaults/jruby_native.rb $(INSTALLDIR)"; \
59
- cp ./lib/rubygems/defaults/jruby_native.rb $(INSTALLDIR); \
60
- fi;
42
+ @if [ ! -f $(BINDIR)/jruby.sh ]; then cp ./exe/jruby.sh $(BINDIR)/jruby.sh; fi
61
43
 
62
44
  test:
63
45
  $(RAKE)
data/Rakefile CHANGED
@@ -26,7 +26,7 @@ task :gemspec => './lib/jruby-launcher.rb' do
26
26
  s.summary = %q{Native launcher for JRuby}
27
27
  s.email = ["nick@nicksieger.com", "vsizikov@gmail.com"]
28
28
  s.extensions = ["extconf.rb"]
29
- s.files = FileList["COPYING", "README.md", "Makefile", "Rakefile", "*.c", "*.cpp", "*.h", "inc/*.*", "**/*.rb", "resources/*.*"]
29
+ s.files = FileList["COPYING", "README.md", "Makefile", "Rakefile", "*.c", "*.cpp", "*.h", "inc/*.*", "**/*.rb", "resources/*.*", "exe/jruby.sh"]
30
30
  s.homepage = %q{http://jruby.org}
31
31
  end
32
32
  end
data/exe/jruby.sh ADDED
@@ -0,0 +1,986 @@
1
+ #!/bin/sh
2
+ # shellcheck shell=dash # local variable support
3
+ # shellcheck disable=1007 # spurious warnings when initializing multiple vars
4
+
5
+ # -----------------------------------------------------------------------------
6
+ # jruby.sh - Start Script for the JRuby interpreter
7
+ #
8
+ # This script handles all Ruby and JRuby command-line arguments, detects the
9
+ # location of the `java` command and JRuby standard library, and launches JRuby
10
+ # using appropriate flags and configuration. A few flags provide additional
11
+ # information:
12
+ #
13
+ # * `jruby --help` for standard options, most based on Ruby flags.
14
+ # * `jruby --properties` to list all JRuby JVM properties for finer-grained
15
+ # configuration.
16
+ # * `jruby --environment` to show the `java` command line that will be run and
17
+ # log output explaining how we got there.
18
+ #
19
+ # This script is intended to be compatible with POSIX shell as much as possible
20
+ # modulo a few small features known to be nonstandard but present in nearly all
21
+ # POSIX shell implementations. We tell shellcheck to treat this source as dash,
22
+ # a version of ash that adds those features and which has been the standard
23
+ # Debian /bin/sh since 2011.
24
+ #
25
+ # See https://en.wikipedia.org/wiki/Almquist_shell#Adoption_in_Debian_and_Ubuntu
26
+ #
27
+ # There are a number of utility functions defined here to cope with the lack of
28
+ # arrays in shell. These functions simulate arrays through other mechanism and
29
+ # ensure we do not damage quoting during argument processing.
30
+ # -----------------------------------------------------------------------------
31
+
32
+ # Enable uninitialized variable warnings
33
+ set -u
34
+
35
+ # ----- Guarantee local variables are available -------------------------------
36
+ if command -v local >/dev/null; then
37
+ :
38
+ elif command -v typeset >/dev/null; then
39
+ # ksh93 and older have typeset but not local, and expand aliases at parse
40
+ # time so require re-sourcing the script
41
+ alias local=typeset
42
+ if [ -z "${KSH_VERSION-}" ] || (eval : '"${.sh.version}"' >/dev/null 2>&1); then
43
+ # shellcheck source=/dev/null
44
+ . "$0"
45
+ exit
46
+ fi
47
+ else
48
+ echo >&2 "Error: Your shell does not support local variables. Re-run this script with one that does (e.g. bash, ksh)"
49
+ exit 1
50
+ fi
51
+
52
+ # ----- Helper functions ------------------------------------------------------
53
+
54
+ # esceval [ARGUMENT...]
55
+ #
56
+ # Escape ARGUMENT for safe use with eval
57
+ # Returns escaped arguments via $REPLY
58
+ # Thanks to @mentalisttraceur for original implementation:
59
+ # https://github.com/mentalisttraceur/esceval
60
+ esceval()
61
+ {
62
+ local escaped= unescaped= output=
63
+ REPLY=
64
+
65
+ [ $# -gt 0 ] || return 0
66
+ while true; do
67
+ escaped=\'
68
+ unescaped=$1
69
+ while true; do
70
+ case $unescaped in
71
+ (*\'*)
72
+ escaped="$escaped${unescaped%%\'*}'\''"
73
+ unescaped=${unescaped#*\'}
74
+ ;;
75
+ (*) break ;;
76
+ esac
77
+ done
78
+ escaped=$escaped$unescaped\'
79
+ shift
80
+ [ $# -gt 0 ] || break
81
+ output="$output $escaped"
82
+ done
83
+ REPLY="$output $escaped"
84
+ }
85
+
86
+ # assign LISTNAME ELEMENT [ELEMENT...]
87
+ #
88
+ # Assign ELEMENT to the list named by LISTNAME.
89
+ assign() {
90
+ local listname="$1"
91
+ local REPLY=
92
+ shift
93
+
94
+ esceval "$@"
95
+ eval "$listname=\"\${REPLY}\""
96
+ }
97
+
98
+ # append LISTNAME ELEMENT [ELEMENT...]
99
+ #
100
+ # Append ELEMENT to the list named by LISTNAME.
101
+ append() {
102
+ local listname="$1"
103
+ local REPLY=
104
+ shift
105
+
106
+ esceval "$@"
107
+ eval "$listname=\"\${$listname} \${REPLY}\""
108
+ }
109
+
110
+ # prepend LISTNAME ELEMENT [ELEMENT...]
111
+ #
112
+ # Prepend ELEMENT to the list named by LISTNAME, preserving order.
113
+ prepend() {
114
+ local listname="$1"
115
+ local REPLY=
116
+ shift
117
+
118
+ esceval "$@"
119
+ eval "$listname=\"\${REPLY} \${$listname}\""
120
+ }
121
+
122
+ # extend LISTNAME1 LISTNAME2
123
+ #
124
+ # Append the elements stored in the list named by LISTNAME2
125
+ # to the list named by LISTNAME1.
126
+ extend() {
127
+ eval "$1=\"\${$1} \${$2}\""
128
+ }
129
+
130
+ # preextend LISTNAME1 LISTNAME2
131
+ #
132
+ # Prepend the elements stored in the list named by LISTNAME2
133
+ # to the named by LISTNAME1, preserving order.
134
+ preextend() {
135
+ eval "$1=\"\${$2} \${$1}\""
136
+ }
137
+
138
+ # a_isempty
139
+ #
140
+ # Return 0 if an array is empty, otherwise return 1
141
+ a_isempty() {
142
+ case $ruby_args in
143
+ (*[![:space:]]*) return 1 ;; # If any nonblank, not empty
144
+ esac
145
+ return 0
146
+ }
147
+
148
+ # exists [FILE...]
149
+ #
150
+ # Returns 0 if all FILEs exist or none provided, otherwise returns 1
151
+ exists() {
152
+ while [ "$#" -gt 0 ]; do
153
+ [ -e "$1" ] || return
154
+ shift
155
+ done
156
+
157
+ return 0
158
+ }
159
+
160
+ # is_newer FILE OTHER...
161
+ #
162
+ # Returns 0 if FILE is newer than all OTHER files. If FILE doesn't exist,
163
+ # return error. If OTHER files don't exist, pretend they're older than FILE.
164
+ is_newer() {
165
+ local output master
166
+ master="$1"
167
+ shift
168
+
169
+ # Find any other files that are newer, negate outside find in case any don't exist
170
+ [ -e "$master" ] && ! find "$@" -newer "$master" 2>/dev/null | read -r _
171
+ }
172
+
173
+ # echo [STRING...]
174
+ #
175
+ # Dumb echo, i.e. print arguments joined by spaces with no further processing
176
+ echo() {
177
+ printf "%s\n" "$*"
178
+ }
179
+
180
+ # ----- Set variable defaults -------------------------------------------------
181
+
182
+ java_class=org.jruby.Main
183
+ JRUBY_SHELL=/bin/sh
184
+
185
+ # Detect cygwin and mingw environments
186
+ cygwin=false
187
+ case "$(uname)" in
188
+ CYGWIN*) cygwin=true ;;
189
+ MINGW*)
190
+ release_id=$(awk -F= '$1=="ID" { print $2; }' /etc/os-release 2> /dev/null)
191
+ case $release_id in
192
+ "msys2") ;;
193
+ *)
194
+ jruby.exe "$@"
195
+ exit $?
196
+ ;;
197
+ esac
198
+ ;;
199
+ esac
200
+ readonly cygwin
201
+
202
+ use_exec=true
203
+ jdb=false
204
+
205
+ NO_BOOTCLASSPATH=false
206
+ VERIFY_JRUBY=false
207
+ print_environment_log=false
208
+ regenerate_jsa_file=false
209
+ remove_jsa_files=false
210
+ log_cds=false
211
+
212
+ if [ -z "${JRUBY_OPTS-}" ]; then
213
+ JRUBY_OPTS=""
214
+ fi
215
+
216
+ if [ -z "${JAVA_STACK-}" ]; then
217
+ JAVA_STACK=-Xss2048k
218
+ fi
219
+
220
+ java_args=""
221
+ ruby_args=""
222
+
223
+ # shellcheck disable=2034 # variable is only read in an eval
224
+ java_opts_from_files=""
225
+ # shellcheck disable=2034 # variable is only read in an eval
226
+ jdb_args=""
227
+
228
+ # Force OpenJDK-based JVMs to use /dev/urandom for random number generation
229
+ # See https://github.com/jruby/jruby/issues/4685 among others.
230
+ # OpenJDK tries really hard to prevent you from using urandom.
231
+ # See https://bugs.openjdk.java.net/browse/JDK-6202721
232
+ # Non-file URL causes fallback to slow threaded SeedGenerator.
233
+ # See https://bz.apache.org/bugzilla/show_bug.cgi?id=56139
234
+ if [ -r "/dev/urandom" ]; then
235
+ JAVA_SECURITY_EGD="file:/dev/urandom"
236
+ fi
237
+
238
+ # Gather environment information as we go
239
+ readonly cr='
240
+ '
241
+ environment_log="JRuby Environment$cr================="
242
+ add_log() {
243
+ environment_log="${environment_log}${cr}${*-}"
244
+ }
245
+
246
+ # Logic to process "arguments files" on both Java 8 and Java 9+
247
+ process_java_opts() {
248
+ local java_opts_file="$1"
249
+ if [ -r "$java_opts_file" ]; then
250
+ add_log
251
+ add_log "Adding Java options from: $java_opts_file"
252
+
253
+ # On Java 9+, add an @argument for the given file.
254
+ # On earlier versions the file contents will be read and expanded on the Java command line.
255
+ if $use_modules; then
256
+ append java_opts_from_files "@$java_opts_file"
257
+ else
258
+ local line=
259
+ while read -r line; do
260
+ if [ "$line" ]; then
261
+ # shellcheck disable=2086 # Split options on whitespace
262
+ append java_opts_from_files $line
263
+ add_log " $line"
264
+ fi
265
+ done < "$java_opts_file"
266
+ fi
267
+ fi
268
+ }
269
+
270
+ # Pure shell dirname/basename
271
+ dir_name() {
272
+ local filename="$1" trail=
273
+ case $filename in
274
+ */*[!/]*)
275
+ trail=${filename##*[!/]}
276
+ filename=${filename%%"$trail"}
277
+ REPLY=${filename%/*}
278
+ ;;
279
+ *[!/]*)
280
+ trail=${filename##*[!/]}
281
+ REPLY="."
282
+ ;;
283
+ *)
284
+ REPLY="/"
285
+ ;;
286
+ esac
287
+ }
288
+
289
+ base_name() {
290
+ local filename="$1" trail=
291
+ case $filename in
292
+ */*[!/]*)
293
+ trail=${filename##*[!/]}
294
+ filename=${filename%%"$trail"}
295
+ REPLY=${filename##*/}
296
+ ;;
297
+ *[!/]*)
298
+ trail=${filename##*[!/]}
299
+ REPLY=${filename%%"$trail"}
300
+ ;;
301
+ *)
302
+ REPLY="/"
303
+ ;;
304
+ esac
305
+ }
306
+
307
+ # Determine whether path is absolute and contains no relative segments or symlinks
308
+ path_is_canonical() {
309
+ local path=
310
+ for path; do
311
+ case $path in
312
+ ([!/]*) return 1 ;;
313
+ (./*|../*) return 1 ;;
314
+ (*/.|*/..) return 1 ;;
315
+ (*/./*|*/../*) return 1 ;;
316
+ esac
317
+ while [ "$path" ]; do
318
+ [ -h "$path" ] && return 1
319
+ path="${path%/*}"
320
+ done
321
+ done
322
+ return 0
323
+ }
324
+
325
+ # Resolve directory to its canonical value
326
+ resolve_dir() {
327
+ # Some shells (dash, ksh) resolve relative paths by default before cd'ing, i.e.
328
+ # cd /foo/bar/../baz = cd /foo/baz
329
+ # This is fine unless bar is a symlink, in which case the second form is
330
+ # invalid. Passing -P to cd fixes this behaviour.
331
+ REPLY="$(cd -P -- "$1" && pwd)"
332
+ }
333
+
334
+ # Resolve symlink until it's not a symlink
335
+ resolve_file() {
336
+ local current="$1" target=
337
+
338
+ while [ -h "$current" ]; do
339
+ target="$(readlink "$current")" || return
340
+ case $target in
341
+ (/*) current="$target" ;;
342
+ # handle relative symlinks
343
+ (*) dir_name "$current"; current="$REPLY/$target" ;;
344
+ esac
345
+ done
346
+ REPLY="$current"
347
+ }
348
+
349
+ # Resolve path to its canonical value
350
+ resolve() {
351
+ local target="$1" base=
352
+ REPLY=
353
+
354
+ # Verify target actually exists (and isn't too deep in symlinks)
355
+ if ! [ -e "$target" ]; then
356
+ echo >&2 "Error: No such file or directory: $target"
357
+ return 1
358
+ fi
359
+
360
+ # Realpath is way faster than repeatedly calling readlink, so use it if possible
361
+ if command -v realpath >/dev/null; then
362
+ REPLY="$(realpath "$target")" && return
363
+ fi
364
+
365
+ # Take shortcut for directories
366
+ if [ -d "$target" ]; then
367
+ resolve_dir "$target" && return
368
+ fi
369
+
370
+ # Ensure $target is not a symlink
371
+ resolve_file "$target" || return
372
+ target="$REPLY"
373
+
374
+ # Resolve parent directory if it's not absolute
375
+ if ! path_is_canonical "$target"; then
376
+ dir_name "$target"
377
+ resolve_dir "$REPLY" || return
378
+ base="$REPLY"
379
+
380
+ base_name "$target"
381
+ target="$base/$REPLY"
382
+ fi
383
+ REPLY="$target"
384
+ }
385
+
386
+ # ----- Determine JRUBY_HOME based on this executable's path ------------------
387
+
388
+ # get the absolute path of the executable
389
+ if [ "${BASH-}" ]; then
390
+ # shellcheck disable=2128,3028
391
+ script_src="${BASH_SOURCE-}"
392
+ else
393
+ script_src="$0"
394
+ fi
395
+ dir_name "$script_src"
396
+ BASE_DIR="$(cd -P -- "$REPLY" >/dev/null && pwd -P)"
397
+ base_name "$script_src"
398
+ resolve "$BASE_DIR/$REPLY"
399
+ SELF_PATH="$REPLY"
400
+
401
+ JRUBY_HOME="${SELF_PATH%/*/*}"
402
+
403
+ # ----- File paths for various options and files we'll process later ----------
404
+
405
+ # Module options to open up packages we need to reflect
406
+ readonly jruby_module_opts_file="$JRUBY_HOME/bin/.jruby.module_opts"
407
+
408
+ # Cascading .java_opts files for localized JVM flags
409
+ readonly installed_jruby_java_opts_file="$JRUBY_HOME/bin/.jruby.java_opts"
410
+ if [ -z "${HOME-}" ]; then
411
+ readonly home_jruby_java_opts_file=""
412
+ else
413
+ readonly home_jruby_java_opts_file="$HOME/.jruby.java_opts"
414
+ fi
415
+ readonly pwd_jruby_java_opts_file="$PWD/.jruby.java_opts"
416
+
417
+ # Options from .dev_mode.java_opts for "--dev" mode, to reduce JRuby startup time
418
+ readonly dev_mode_opts_file="$JRUBY_HOME/bin/.dev_mode.java_opts"
419
+
420
+ # ----- Initialize environment log --------------------------------------------
421
+
422
+ add_log
423
+ add_log "JRuby executable:"
424
+ add_log " $script_src"
425
+ add_log "JRuby command line options:"
426
+ add_log " $*"
427
+ add_log "Current directory:"
428
+ add_log " $PWD"
429
+
430
+ add_log
431
+ add_log "Environment:"
432
+ add_log " JRUBY_HOME: $JRUBY_HOME"
433
+ add_log " JRUBY_OPTS: $JRUBY_OPTS"
434
+ add_log " JAVA_OPTS: ${JAVA_OPTS-}"
435
+
436
+ # ----- Discover JVM and prep environment to run it ---------------------------
437
+
438
+ # Determine where the java command is and ensure we have a good JAVA_HOME
439
+ if [ -z "${JAVACMD-}" ]; then
440
+ if [ -z "${JAVA_HOME-}" ]; then
441
+ readonly java_home_command="/usr/libexec/java_home"
442
+ if [ -r "$java_home_command" ] \
443
+ && [ -x "$java_home_command" ] \
444
+ && [ ! -d "$java_home_command" ]
445
+ then
446
+ # use java_home command when none is set (on MacOS)
447
+ JAVA_HOME="$("$java_home_command")" &&
448
+ JAVACMD="$JAVA_HOME"/bin/java
449
+ else
450
+ # Linux and others have a chain of symlinks
451
+ JAVACMD="$(command -v java)" &&
452
+ resolve "$JAVACMD" &&
453
+ JAVACMD="$REPLY"
454
+ fi
455
+ elif $cygwin; then
456
+ JAVACMD="$(cygpath -u "$JAVA_HOME")/bin/java"
457
+ else
458
+ resolve "$JAVA_HOME/bin/java" &&
459
+ JAVACMD="$REPLY"
460
+ fi
461
+ else
462
+ JAVACMD="$(command -v "$JAVACMD")" &&
463
+ resolve "$JAVACMD" &&
464
+ JAVACMD="$REPLY"
465
+ fi || {
466
+ # Something went wrong when looking for java
467
+ echo >&2 "${0##*/}: Error: Java executable not found!"
468
+ exit 2
469
+ }
470
+
471
+ # export separately from command execution
472
+ dir_name "$JAVACMD"
473
+ dir_name "$REPLY"
474
+ JAVA_HOME="$REPLY"
475
+
476
+ # Detect modularized Java
477
+ java_is_modular() {
478
+ # check that modules file is present
479
+ if [ -f "$JAVA_HOME"/lib/modules ]; then
480
+ return 0
481
+ fi
482
+
483
+ # check if a MODULES line appears in release
484
+ if [ -f "$JAVA_HOME"/release ] && grep -q ^MODULES "$JAVA_HOME"/release; then
485
+ return 0
486
+ fi
487
+
488
+ return 1
489
+ }
490
+
491
+ if java_is_modular; then
492
+ use_modules=true
493
+ else
494
+ use_modules=false
495
+ fi
496
+ readonly use_modules
497
+
498
+ add_log " JAVACMD: $JAVACMD"
499
+ add_log " JAVA_HOME: $JAVA_HOME"
500
+
501
+ if $use_modules; then
502
+ add_log
503
+ add_log "Detected Java modules at $JAVA_HOME"
504
+ fi
505
+
506
+ # ----- Detect Java version and determine available features ------------------
507
+ # shellcheck source=/dev/null
508
+ if [ -f "$JAVA_HOME/release" ]; then
509
+ java_version=$(. "$JAVA_HOME/release" && echo "${JAVA_VERSION-}")
510
+ if echo "${java_version}" | grep -q "1.8.\\.*"; then
511
+ java_version=8
512
+ fi
513
+ else
514
+ java_version=8
515
+ fi
516
+ # shellcheck source=/dev/null
517
+ if [ -f "$JRUBY_HOME/bin/.java-version" ]; then
518
+ minimum_java_version=$(. "$JRUBY_HOME/bin/.java-version" && echo "${JRUBY_MINIMUM_JAVA_VERSION-}")
519
+ else
520
+ # Only 9.4.12.0 and earlier will have shipped without a .java-version file, so fall back on minimum of 8
521
+ minimum_java_version=8
522
+ fi
523
+ add_log "Detected Java version: $java_version"
524
+
525
+ # Split version out for integer comparisons
526
+ java_major=${java_version%%.*}
527
+
528
+ # AppCDS support
529
+ if [ "$java_major" -ge 13 ] && exists "$JAVA_HOME"/lib/server/*.jsa; then
530
+ java_has_appcds=true
531
+ else
532
+ java_has_appcds=false
533
+ fi
534
+ readonly java_has_appcds
535
+
536
+ # Default to using AppCDS if available
537
+ use_jsa_file="$java_has_appcds"
538
+
539
+ # Present a useful error if running a Java version lower than bin/.java-version
540
+ if [ "$java_major" -lt "$minimum_java_version" ]; then
541
+ echo "This version of JRuby requires Java ${minimum_java_version}+."
542
+ echo "Make sure JAVA_HOME points at JDK ${minimum_java_version} or higher"
543
+ echo "Current JAVA_HOME: $JAVA_HOME"
544
+ exit 1
545
+ fi
546
+
547
+ # AppCDS autogeneration
548
+ if [ "$java_major" -ge 19 ]; then
549
+ java_has_appcds_autogenerate=true
550
+ else
551
+ java_has_appcds_autogenerate=false
552
+ fi
553
+ readonly java_has_appcds_autogenerate
554
+
555
+ # Native access
556
+ if [ "$java_major" -ge 22 ]; then
557
+ enable_native_access=true
558
+ else
559
+ enable_native_access=false
560
+ fi
561
+ readonly enable_native_access
562
+
563
+ # Unsafe memory access
564
+ if [ "$java_major" -ge 23 ]; then
565
+ enable_unsafe_memory=true
566
+ else
567
+ enable_unsafe_memory=false
568
+ fi
569
+ readonly enable_unsafe_memory
570
+
571
+ # ----- Process .java_opts files ----------------------------------------------
572
+
573
+ # We include options on the java command line in the following order:
574
+ #
575
+ # * JRuby installed bin/.jruby.java_opts (empty by default)
576
+ # * user directory .jruby.java_opts
577
+ # * current directory .jruby.java_opts
578
+ # * dev mode options from bin/.dev_mode.java_opts, if --dev is specified
579
+ # * module options from bin/.jruby.module_opts if modules are detected
580
+ # * JAVA_OPTS environment variable
581
+ # * command line flags
582
+
583
+ # Add local and global .jruby.java_opts
584
+ process_java_opts "$installed_jruby_java_opts_file"
585
+ process_java_opts "$home_jruby_java_opts_file"
586
+ process_java_opts "$pwd_jruby_java_opts_file"
587
+
588
+ # Capture some Java options to be passed separately
589
+ JAVA_OPTS_TEMP=""
590
+ for opt in ${JAVA_OPTS-}; do
591
+ case $opt in
592
+ -Xmx*) JAVA_MEM="$opt" ;;
593
+ -Xss*) JAVA_STACK="$opt" ;;
594
+ *) JAVA_OPTS_TEMP="$JAVA_OPTS_TEMP $opt" ;;
595
+ esac
596
+ done
597
+
598
+ JAVA_OPTS="$JAVA_OPTS_TEMP"
599
+
600
+ # ----- Set up the JRuby class/module path ------------------------------------
601
+
602
+ CP_DELIMITER=":"
603
+
604
+ # Find main jruby jar and add it to the classpath
605
+ jruby_jar=
606
+ for j in "$JRUBY_HOME"/lib/jruby.jar "$JRUBY_HOME"/lib/jruby-complete.jar; do
607
+ if [ ! -e "$j" ]; then
608
+ continue
609
+ fi
610
+ if [ "${JRUBY_CP-}" ]; then
611
+ JRUBY_CP="$JRUBY_CP$CP_DELIMITER$j"
612
+ else
613
+ JRUBY_CP="$j"
614
+ fi
615
+ if [ -n "$jruby_jar" ]; then
616
+ echo "WARNING: more than one JRuby JAR found in lib directory" 1>&2
617
+ fi
618
+ jruby_jar="$j"
619
+ done
620
+ readonly jruby_jar
621
+
622
+ if $cygwin; then
623
+ JRUBY_CP="$(cygpath -p -w "$JRUBY_CP")"
624
+ fi
625
+
626
+ # ----- Add additional jars from lib to classpath -----------------------------
627
+
628
+ if [ "${JRUBY_PARENT_CLASSPATH-}" ]; then
629
+ # Use same classpath propagated from parent jruby
630
+ CP="$JRUBY_PARENT_CLASSPATH"
631
+ else
632
+ # add other jars in lib to CP for command-line execution
633
+ for j in "$JRUBY_HOME"/lib/*.jar; do
634
+ case "${j#"$JRUBY_HOME/lib/"}" in
635
+ jruby.jar|jruby-complete.jar) continue
636
+ esac
637
+ if [ -z "${CP-}" ]; then
638
+ CP="$j"
639
+ else
640
+ CP="$CP$CP_DELIMITER$j"
641
+ fi
642
+ done
643
+
644
+ if [ "${CP-}" ] && $cygwin; then
645
+ CP="$(cygpath -p -w "$CP")"
646
+ fi
647
+ fi
648
+
649
+ if $cygwin; then
650
+ # switch delimiter only after building Unix style classpaths
651
+ CP_DELIMITER=";"
652
+ fi
653
+
654
+ readonly CP_DELIMITER
655
+
656
+ # ----- Continue processing JRuby options into JVM options --------------------
657
+
658
+ # Split out any -J argument for passing to the JVM.
659
+ # Scanning for args is aborted by '--'.
660
+ # shellcheck disable=2086
661
+ set -- $JRUBY_OPTS "$@"
662
+ # increment pointer, permute arguments
663
+ while [ $# -gt 0 ]
664
+ do
665
+ case $1 in
666
+ # Stuff after '-J' in this argument goes to JVM
667
+ -J-Xmx*) JAVA_MEM="${1#-J}" ;;
668
+ -J-Xss*) JAVA_STACK="${1#-J}" ;;
669
+ -J)
670
+ "$JAVACMD" -help
671
+ echo "(Prepend -J in front of these options when using 'jruby' command)" 1>&2
672
+ exit
673
+ ;;
674
+ -J-X)
675
+ "$JAVACMD" -X
676
+ echo "(Prepend -J in front of these options when using 'jruby' command)" 1>&2
677
+ exit
678
+ ;;
679
+ -J-classpath|-J-cp)
680
+ if [ -z "${CP-}" ]; then
681
+ CP="$2"
682
+ else
683
+ CP="$CP$CP_DELIMITER$2"
684
+ fi
685
+ CLASSPATH=""
686
+ shift
687
+ ;;
688
+ -J-ea*)
689
+ VERIFY_JRUBY=true
690
+ append java_args "${1#-J}"
691
+ ;;
692
+ -J-Djava.security.egd=*) JAVA_SECURITY_EGD=${1#-J-Djava.security.egd=} ;;
693
+ # This must be the last check for -J
694
+ -J*) append java_args "${1#-J}" ;;
695
+ # Pass -X... and -X? search options through
696
+ -X*...|-X*\?) append ruby_args "$1" ;;
697
+ # Match -Xa.b.c=d to translate to -Da.b.c=d as a java option
698
+ -X*.*) append java_args -Djruby."${1#-X}" ;;
699
+ # Match switches that take an argument
700
+ -[CeIS])
701
+ append ruby_args "$1" "$2"
702
+ shift
703
+ ;;
704
+ # Run with JMX management enabled
705
+ --manage)
706
+ append java_args -Dcom.sun.management.jmxremote
707
+ append java_args -Djruby.management.enabled=true
708
+ ;;
709
+ # Don't launch a GUI window, no matter what
710
+ --headless) append java_args -Djava.awt.headless=true ;;
711
+ # Run under JDB
712
+ --jdb)
713
+ jdb=true
714
+ if [ -z "$JAVA_HOME" ]; then
715
+ JAVACMD='jdb'
716
+ else
717
+ if $cygwin; then
718
+ JAVACMD="$(cygpath -u "$JAVA_HOME")/bin/jdb"
719
+ else
720
+ JAVACMD="$JAVA_HOME/bin/jdb"
721
+ fi
722
+ fi
723
+ JDB_SOURCEPATH="${JRUBY_HOME}/core/src/main/java:${JRUBY_HOME}/lib/ruby/stdlib:."
724
+ append jdb_args -sourcepath "$JDB_SOURCEPATH"
725
+ append ruby_args -X+C
726
+ ;;
727
+ --client|--server|--noclient)
728
+ echo "Warning: the $1 flag is deprecated and has no effect most JVMs" 1>&2
729
+ ;;
730
+ --dev)
731
+ process_java_opts "$dev_mode_opts_file"
732
+ # For OpenJ9 use environment variable to enable quickstart and shareclasses
733
+ export OPENJ9_JAVA_OPTIONS="-Xquickstart -Xshareclasses"
734
+ ;;
735
+ --sample) append java_args -Xprof ;;
736
+ --record)
737
+ append java_args -XX:+FlightRecorder -XX:StartFlightRecording=dumponexit=true
738
+ ;;
739
+ --no-bootclasspath) NO_BOOTCLASSPATH=true ;;
740
+ --ng*)
741
+ echo "Error: Nailgun is no longer supported" 1>&2
742
+ exit 1
743
+ ;;
744
+ --environment) print_environment_log=true ;;
745
+ # warn but ignore
746
+ --1.8|--1.9|--2.0) echo "warning: $1 ignored" 1>&2 ;;
747
+ --checkpoint=*)
748
+ java_class=org.jruby.main.CheckpointMain
749
+ append java_args -XX:CRaCCheckpointTo="${1#--checkpoint=}" ;;
750
+ # capture a checkpoint to specified location
751
+ --checkpoint)
752
+ java_class=org.jruby.main.CheckpointMain
753
+ append java_args -XX:CRaCCheckpointTo=.jruby.checkpoint ;;
754
+ # restore from checkpoint
755
+ --restore=*) append java_args -XX:CRaCRestoreFrom="${1#--restore=}" ;;
756
+ --restore) append java_args -XX:CRaCRestoreFrom=.jruby.checkpoint ;;
757
+ --cache)
758
+ if ! $java_has_appcds; then
759
+ echo "Error: Java $java_major doesn't support automatic AppCDS" >&2
760
+ exit 2
761
+ fi
762
+ regenerate_jsa_file=true # Force regeneration of archive
763
+ ;;
764
+ --nocache) use_jsa_file=false ;;
765
+ --rmcache) remove_jsa_files=true ;;
766
+ --logcache) log_cds=true ;;
767
+ # Abort processing on the double dash
768
+ --) break ;;
769
+ # Other opts go to ruby
770
+ -*) append ruby_args "$1" ;;
771
+ # Abort processing on first non-opt arg
772
+ *) break ;;
773
+ esac
774
+ shift
775
+ done
776
+
777
+ # Force JDK to use specified java.security.egd rand source
778
+ if [ -n "${JAVA_SECURITY_EGD-}" ]; then
779
+ append java_args "-Djava.security.egd=$JAVA_SECURITY_EGD"
780
+ fi
781
+
782
+ # The rest of the arguments are for ruby
783
+ append ruby_args "$@"
784
+
785
+ JAVA_OPTS="$JAVA_OPTS ${JAVA_MEM-} ${JAVA_STACK-}"
786
+
787
+ JFFI_OPTS="-Djffi.boot.library.path=$JRUBY_HOME/lib/jni"
788
+
789
+ CLASSPATH="${CP-}${CP_DELIMITER}${CLASSPATH-}"
790
+
791
+ # ----- Module and Class Data Sharing flags for Java 9+ -----------------------
792
+
793
+ if $use_modules; then
794
+ # Switch to non-boot path since we can't use bootclasspath on 9+
795
+ NO_BOOTCLASSPATH=true
796
+
797
+ # Add base opens we need for Ruby compatibility
798
+ process_java_opts "$jruby_module_opts_file"
799
+ fi
800
+
801
+ # Default JVM Class Data Sharing Archive (jsa) file for JVMs that support it
802
+ readonly jruby_jsa_file="$JRUBY_HOME/lib/jruby-java$java_version.jsa"
803
+
804
+ # Find JSAs for all Java versions
805
+ assign jruby_jsa_files "$JRUBY_HOME"/lib/jruby-java*.jsa
806
+ readonly jruby_jsa_files
807
+
808
+ # Allow overriding default JSA file location
809
+ if [ -n "${JRUBY_JSA-}" ]; then
810
+ jruby_jsa_file="$JRUBY_JSA"
811
+ fi
812
+
813
+ # Ensure the AppCDS parent directory is actually writable
814
+ if dir_name "$jruby_jsa_file" && ! [ -w "$REPLY" ]; then
815
+ if $use_jsa_file || $regenerate_jsa_file || $remove_jsa_files; then
816
+ echo "Warning: AppCDS archive directory is not writable, disabling AppCDS operations" >&2
817
+ fi
818
+ regenerate_jsa_file=false
819
+ remove_jsa_files=false
820
+ use_jsa_file=false
821
+ fi
822
+
823
+ # Initialize AppCDS
824
+ if $use_jsa_file; then
825
+ # Default to no-op script when explicitly generating
826
+ if $regenerate_jsa_file && a_isempty "$ruby_args"; then
827
+ append ruby_args -e 1
828
+ fi
829
+
830
+ # Archive should be regenerated manually if requested or it's outdated relative to JRuby
831
+ if ! $regenerate_jsa_file && is_newer "$jruby_jar" "$jruby_jsa_file"; then
832
+ regenerate_jsa_file=true
833
+ fi
834
+
835
+ # Defer generation to Java if flag is available
836
+ if $java_has_appcds_autogenerate; then
837
+ append java_args -XX:+AutoCreateSharedArchive
838
+
839
+ add_log
840
+ add_log "Automatically generating and using CDS archive at:"
841
+ add_log " $jruby_jsa_file"
842
+ fi
843
+
844
+ # Determine if we should read or explicitly write the archive
845
+ if $regenerate_jsa_file && ! $java_has_appcds_autogenerate; then
846
+ # Explicitly create archive if outdated
847
+ append java_args -XX:ArchiveClassesAtExit="$jruby_jsa_file"
848
+
849
+ add_log
850
+ add_log "Regenerating CDS archive at:"
851
+ add_log " $jruby_jsa_file"
852
+ else
853
+ # Read archive if not explicitly regenerating
854
+ append java_args -XX:SharedArchiveFile="$jruby_jsa_file"
855
+
856
+ if ! $java_has_appcds_autogenerate; then
857
+ add_log
858
+ add_log "Using CDS archive at:"
859
+ add_log " $jruby_jsa_file"
860
+ fi
861
+ fi
862
+
863
+ if $log_cds; then
864
+ add_log "Logging CDS output to:"
865
+ add_log " $jruby_jsa_file.log"
866
+ append java_args -Xlog:cds=info:file="$jruby_jsa_file".log
867
+ append java_args -Xlog:cds+dynamic=info:file="$jruby_jsa_file".log
868
+ else
869
+ append java_args -Xlog:cds=off -Xlog:cds+dynamic=off
870
+ fi
871
+ fi
872
+
873
+ # Enable access to native libraries
874
+ if $enable_native_access; then
875
+ append java_args --enable-native-access=org.jruby.dist
876
+ fi
877
+
878
+ # Enable access to Unsafe memory functions
879
+ if $enable_unsafe_memory; then
880
+ append java_args --sun-misc-unsafe-memory-access=allow
881
+ fi
882
+
883
+ # Enable access to Unsafe memory functions
884
+
885
+ # ----- Tweak console environment for cygwin ----------------------------------
886
+
887
+ if $cygwin; then
888
+ use_exec=false
889
+ JRUBY_HOME="$(cygpath --mixed "$JRUBY_HOME")"
890
+ JRUBY_SHELL="$(cygpath --mixed "$JRUBY_SHELL")"
891
+
892
+ eval set -- "$ruby_args"
893
+
894
+ case $1 in
895
+ /*)
896
+ if [ -f "$1" ] || [ -d "$1" ]; then
897
+ # replace first element of ruby_args with cygwin form
898
+ win_arg="$(cygpath -w "$1")"
899
+ shift
900
+ set -- "$win_arg" "$@"
901
+ assign ruby_args "$@"
902
+ fi
903
+ ;;
904
+ esac
905
+
906
+ # fix JLine to use UnixTerminal
907
+ if stty -icanon min 1 -echo > /dev/null 2>&1; then
908
+ JAVA_OPTS="$JAVA_OPTS -Djline.terminal=jline.UnixTerminal"
909
+ fi
910
+
911
+ fi
912
+
913
+ # ----- Final prepration of the Java command line -----------------------------
914
+
915
+ # Don't quote JAVA_OPTS; we want it to expand
916
+ # shellcheck disable=2086
917
+ prepend java_args $JAVA_OPTS "$JFFI_OPTS"
918
+
919
+ # Include all options from files at the beginning of the Java command line
920
+ preextend java_args java_opts_from_files
921
+
922
+ if $jdb; then
923
+ preextend java_args jdb_args
924
+ fi
925
+
926
+ prepend java_args "$JAVACMD"
927
+
928
+ if $NO_BOOTCLASSPATH || $VERIFY_JRUBY; then
929
+ if $use_modules; then
930
+ # Use module path instead of classpath for the jruby libs
931
+ append java_args --module-path "$JRUBY_CP" -classpath "$CLASSPATH"
932
+ else
933
+ append java_args -classpath "$JRUBY_CP$CP_DELIMITER$CLASSPATH"
934
+ fi
935
+ else
936
+ append java_args -Xbootclasspath/a:"$JRUBY_CP"
937
+ append java_args -classpath "$CLASSPATH"
938
+ append java_args -Djruby.home="$JRUBY_HOME"
939
+ fi
940
+
941
+ append java_args -Djruby.home="$JRUBY_HOME" \
942
+ -Djruby.lib="$JRUBY_HOME/lib" \
943
+ -Djruby.script=jruby \
944
+ -Djruby.shell="$JRUBY_SHELL" \
945
+ "$java_class"
946
+ extend java_args ruby_args
947
+
948
+ eval set -- "$java_args"
949
+
950
+ add_log
951
+ add_log "Java command line:"
952
+ add_log " $*"
953
+
954
+ if $print_environment_log; then
955
+ echo "$environment_log"
956
+ exit 0
957
+ fi
958
+
959
+ # ----- Perform final mutations after logging ---------------------------------
960
+ # Delete All AppCDS files and exit if requested
961
+ if $remove_jsa_files; then
962
+ eval rm -f -- "$jruby_jsa_files"
963
+ exit
964
+ fi
965
+
966
+ if $regenerate_jsa_file && [ -e "$jruby_jsa_file" ]; then
967
+ # Delete selected AppCDS file if requested or if it's outdated
968
+ rm -f -- "$jruby_jsa_file"
969
+ fi
970
+
971
+ # ----- Run JRuby! ------------------------------------------------------------
972
+
973
+ if $use_exec; then
974
+ exec "$@"
975
+ else
976
+ "$@"
977
+
978
+ # Record the exit status immediately, or it will be overridden.
979
+ JRUBY_STATUS=$?
980
+
981
+ if $cygwin; then
982
+ stty icanon echo > /dev/null 2>&1
983
+ fi
984
+
985
+ exit $JRUBY_STATUS
986
+ fi
@@ -1,3 +1,3 @@
1
1
  module JRubyLauncher
2
- VERSION = "2.0.0.pr1"
2
+ VERSION = "2.0.0.pre3"
3
3
  end
@@ -2,7 +2,7 @@ require 'tmpdir'
2
2
  require File.expand_path('../spec_helper.rb', __FILE__)
3
3
  load File.expand_path('../../lib/jruby-launcher.rb', __FILE__)
4
4
 
5
- describe "JRuby native launcher" do
5
+ describe "JRuby native launcher", if: /Windows/.match?(ENV_JAVA['os.name']) do
6
6
  it "should run org.jruby.Main" do
7
7
  jruby_launcher_args("").last.should == "org/jruby/Main"
8
8
  end
data/unixlauncher.c CHANGED
@@ -137,7 +137,6 @@ int unixlauncher_run(int argc, char *argv[], char *envp[]) {
137
137
  fprintf(stderr, "%s: %s: %s\n", original_self, strerror(errno), script_path);
138
138
  }
139
139
 
140
- free(self_path);
141
140
  free(script_path);
142
141
  return EXIT_FAILURE;
143
142
  }
data/version.h CHANGED
@@ -6,6 +6,6 @@
6
6
  #ifndef _VERSION_H_
7
7
  #define _VERSION_H_
8
8
 
9
- #define JRUBY_LAUNCHER_VERSION "2.0.0.pr1"
9
+ #define JRUBY_LAUNCHER_VERSION "2.0.0.pre3"
10
10
 
11
11
  #endif // ! _VERSION_H_
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jruby-launcher
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.pr1
4
+ version: 2.0.0.pre3
5
5
  platform: java
6
6
  authors:
7
7
  - Nick Sieger
8
8
  - Vladimir Sizikov
9
+ autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2025-03-31 00:00:00.000000000 Z
12
+ date: 2025-04-08 00:00:00.000000000 Z
12
13
  dependencies: []
13
14
  description: Builds and installs a native launcher for JRuby on your system
14
15
  email:
@@ -26,6 +27,7 @@ files:
26
27
  - argnames.h
27
28
  - argparser.cpp
28
29
  - argparser.h
30
+ - exe/jruby.sh
29
31
  - extconf.rb
30
32
  - inc/Makefile-conf.mk
31
33
  - inc/Makefile-impl.mk
@@ -35,7 +37,6 @@ files:
35
37
  - jvmlauncher.cpp
36
38
  - jvmlauncher.h
37
39
  - lib/jruby-launcher.rb
38
- - lib/rubygems/defaults/jruby_native.rb
39
40
  - nbexecloader.h
40
41
  - ng.c
41
42
  - platformlauncher.cpp
@@ -55,6 +56,7 @@ files:
55
56
  homepage: http://jruby.org
56
57
  licenses: []
57
58
  metadata: {}
59
+ post_install_message:
58
60
  rdoc_options: []
59
61
  require_paths:
60
62
  - lib
@@ -65,11 +67,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
65
67
  version: '0'
66
68
  required_rubygems_version: !ruby/object:Gem::Requirement
67
69
  requirements:
68
- - - ">="
70
+ - - ">"
69
71
  - !ruby/object:Gem::Version
70
- version: '0'
72
+ version: 1.3.1
71
73
  requirements: []
72
- rubygems_version: 3.6.3
74
+ rubygems_version: 3.0.3.1
75
+ signing_key:
73
76
  specification_version: 4
74
77
  summary: Native launcher for JRuby
75
78
  test_files: []
@@ -1,4 +0,0 @@
1
- class Gem::ConfigFile
2
- PLATFORM_DEFAULTS['install'] = '--no-rdoc --no-ri'
3
- PLATFORM_DEFAULTS['update'] = '--no-rdoc --no-ri'
4
- end