jruby-launcher 1.1.12-java → 1.1.17-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Makefile +2 -1
- data/Rakefile +1 -1
- data/argparser.cpp +19 -2
- data/argparser.h +1 -0
- data/extconf.rb +3 -4
- data/lib/jruby-launcher.rb +1 -1
- data/platformlauncher.cpp +20 -5
- data/rb_w32_cmdvector.h +3 -3
- data/spec/launcher_spec.rb +15 -5
- data/spec/spec_helper.rb +0 -5
- data/unixlauncher.cpp +10 -0
- data/utilsfuncs.cpp +14 -1
- data/utilsfuncs.h +1 -0
- data/utilsfuncswin.cpp +20 -2
- data/version.h +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 362ec35e0d3c674dc7eca8aa2df8ccd97b183dc5a8caa8490666149f4c41c70e
|
4
|
+
data.tar.gz: ed87dade0caf41331b0ad7c149191bf2dd5cb352f79c7f5a93a2e6e3c45e9966
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6444e3b8be2e0389634a54070e83a2cc252eec656704847f43a964e15c8dfaeb5bd0e4b68712a46a0b60c6a72c4fced3353a23c843bf1a4ed24b243d90fbdb8a
|
7
|
+
data.tar.gz: b2053acbaf369dd76b40fb2d55644ccaa2c14012db24bf9c2826667e4532a181cd9d2aa00114ce7ebc381e6d63628df6e8967c60647aed031065888470a1048b
|
data/Makefile
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
PREFIX = notspecified
|
3
3
|
BINDIR = $(PREFIX)/bin
|
4
4
|
JRUBY_VERSION = notspecified
|
5
|
-
JRUBY_MODULE =
|
5
|
+
JRUBY_MODULE = 1
|
6
6
|
INSTALLDIR = $(PREFIX)/lib/ruby/shared/rubygems/defaults
|
7
7
|
INSTALLDIR9000 = $(PREFIX)/lib/ruby/stdlib/rubygems/defaults
|
8
8
|
OLDINSTALLDIR = $(PREFIX)/lib/ruby/site_ruby/1.8/rubygems/defaults
|
@@ -114,6 +114,7 @@ include $(SUB_IMPLMK)
|
|
114
114
|
|
115
115
|
# Pick conf based on OS. for mingw64, must manually override for now.
|
116
116
|
ifeq ($(OS),Windows_NT)
|
117
|
+
CC=gcc
|
117
118
|
CONF=mingw
|
118
119
|
else
|
119
120
|
CONF=unix
|
data/Rakefile
CHANGED
@@ -32,7 +32,7 @@ task :gemspec => './lib/jruby-launcher.rb' do
|
|
32
32
|
end
|
33
33
|
|
34
34
|
desc "Create gem file"
|
35
|
-
task :package => [:update_version, :gemspec
|
35
|
+
task :package => [:update_version, :gemspec] do
|
36
36
|
Gem::PackageTask.new(@gemspec) do |pkg|
|
37
37
|
end
|
38
38
|
Rake::Task['gem'].invoke
|
data/argparser.cpp
CHANGED
@@ -10,6 +10,7 @@
|
|
10
10
|
#include <algorithm>
|
11
11
|
#include <unistd.h>
|
12
12
|
#include <limits>
|
13
|
+
#include <fstream>
|
13
14
|
#include "utilsfuncs.h"
|
14
15
|
#include "argparser.h"
|
15
16
|
#include "argnames.h"
|
@@ -250,7 +251,6 @@ bool ArgParser::parseArgs(int argc, char *argv[]) {
|
|
250
251
|
|
251
252
|
// Force OpenJDK-based JVMs to use /dev/urandom for random number generation
|
252
253
|
// See https://github.com/jruby/jruby/issues/4685 among others.
|
253
|
-
struct stat buffer;
|
254
254
|
if (access("/dev/urandom", R_OK) == 0) {
|
255
255
|
// OpenJDK tries really hard to prevent you from using urandom.
|
256
256
|
// See https://bugs.openjdk.java.net/browse/JDK-6202721
|
@@ -488,8 +488,12 @@ void ArgParser::prepareOptions() {
|
|
488
488
|
|
489
489
|
if (!bootClassPath.empty()) {
|
490
490
|
if (useModulePath) {
|
491
|
+
#ifdef JRUBY_MODULE
|
491
492
|
// When modules are present, use module path for the jruby libs (aka bootClassPath)
|
492
493
|
option = OPT_CMDLINE_MODULE_PATH;
|
494
|
+
#else
|
495
|
+
option = OPT_BOOT_CLASS_PATH;
|
496
|
+
#endif
|
493
497
|
} else {
|
494
498
|
option = OPT_BOOT_CLASS_PATH;
|
495
499
|
}
|
@@ -554,12 +558,25 @@ void ArgParser::useModulesIfPresent() {
|
|
554
558
|
|
555
559
|
if (jdkhome.empty()) {
|
556
560
|
logMsg("Unable to detect JPMS modules as JAVA_HOME is not specified");
|
557
|
-
} else if (access((jdkhome + "/
|
561
|
+
} else if (access((jdkhome + "/lib/modules").c_str(), R_OK) == 0 ||
|
562
|
+
releaseFileHasModules()) {
|
558
563
|
logMsg("JPMS jmods dir detected, using module flags");
|
559
564
|
useModulePath = 1;
|
560
565
|
}
|
561
566
|
}
|
562
567
|
|
568
|
+
bool ArgParser::releaseFileHasModules() {
|
569
|
+
string releaseFile = jdkhome + "/release";
|
570
|
+
std::string line;
|
571
|
+
ifstream in(releaseFile.c_str());
|
572
|
+
if (in.is_open()) {
|
573
|
+
while (getline(in,line)) {
|
574
|
+
if (line.find("MODULES") == 0) return true;
|
575
|
+
}
|
576
|
+
}
|
577
|
+
return false;
|
578
|
+
}
|
579
|
+
|
563
580
|
void ArgParser::constructBootClassPath() {
|
564
581
|
logMsg("constructBootClassPath()");
|
565
582
|
addedToBootCP.clear();
|
data/argparser.h
CHANGED
data/extconf.rb
CHANGED
@@ -4,10 +4,9 @@ mf = mf.gsub(/^PREFIX\s*=.*$/, "PREFIX = #{File.dirname(RbConfig::CONFIG['libdir
|
|
4
4
|
mf = mf.gsub(/^JRUBY_VERSION\s*=.*$/, "JRUBY_VERSION = #{JRUBY_VERSION}")
|
5
5
|
|
6
6
|
# Launcher will use .module_opts file if present, otherwise hardcoded add-opens for this module.
|
7
|
-
#
|
8
|
-
|
9
|
-
|
10
|
-
mf = mf.gsub(/^JRUBY_MODULE\s*=.*$/, "JRUBY_MODULE = 1")
|
7
|
+
# Module options are only supported on JRuby 9.2.1 or higher.
|
8
|
+
if JRUBY_VERSION =~ /(^1)|(^9\.[01])|(^9\.2\.0\.0)/
|
9
|
+
mf = mf.gsub(/^JRUBY_MODULE\s*=.*1$/, "JRUBY_MODULE =")
|
11
10
|
end
|
12
11
|
puts mf
|
13
12
|
File.open('Makefile', 'wb') {|f| f << mf}
|
data/lib/jruby-launcher.rb
CHANGED
data/platformlauncher.cpp
CHANGED
@@ -147,14 +147,29 @@ bool PlatformLauncher::start(char* argv[], int argc, DWORD *retCode, const char*
|
|
147
147
|
suppressConsole = false;
|
148
148
|
} else {
|
149
149
|
if (jdkhome.empty()) {
|
150
|
-
|
151
|
-
|
152
|
-
|
150
|
+
// attempt to get JDK home from registry
|
151
|
+
jvmLauncher.initialize(REQ_JAVA_VERSION);
|
152
|
+
}
|
153
|
+
|
154
|
+
if (!jdkhome.empty()) {
|
155
|
+
java = jdkhome + "\\bin\\java.exe";
|
156
|
+
} else if (getenv("JAVA_HOME") != NULL) {
|
157
|
+
string java_home = string(getenv("JAVA_HOME"));
|
158
|
+
jdkhome = java_home;
|
159
|
+
java_home = trimTrailingBackslashes(java_home);
|
160
|
+
java = java_home + "\\bin\\java.exe";
|
161
|
+
} else {
|
162
|
+
java = findOnPath("java.exe");
|
163
|
+
if (!java.empty()) {
|
164
|
+
int home_index = java.find_last_of('\\', java.find_last_of('\\') - 1);
|
165
|
+
jdkhome = java.substr(0, home_index);
|
153
166
|
}
|
154
167
|
}
|
168
|
+
}
|
155
169
|
|
156
|
-
|
157
|
-
java
|
170
|
+
if (java.empty()) {
|
171
|
+
printToConsole("No `java.exe' executable found on PATH.");
|
172
|
+
return 255;
|
158
173
|
}
|
159
174
|
|
160
175
|
prepareOptions();
|
data/rb_w32_cmdvector.h
CHANGED
@@ -52,7 +52,7 @@ int rb_w32_cmdvector(const char *cmd, char ***vec) {
|
|
52
52
|
char *ptr, *base, *buffer, *cmdline;
|
53
53
|
char **vptr;
|
54
54
|
char quote;
|
55
|
-
NtCmdLineElement *curr
|
55
|
+
NtCmdLineElement *curr;
|
56
56
|
NtCmdLineElement *cmdhead = NULL, **cmdtail = &cmdhead;
|
57
57
|
|
58
58
|
//
|
@@ -237,7 +237,7 @@ int rb_w32_cmdvector(const char *cmd, char ***vec) {
|
|
237
237
|
buffer = (char *)malloc(len);
|
238
238
|
if (!buffer) {
|
239
239
|
do_nothing:
|
240
|
-
while (curr = cmdhead) {
|
240
|
+
while ((curr = cmdhead)) {
|
241
241
|
cmdhead = curr->next;
|
242
242
|
if (curr->flags & NTMALLOC) free(curr->str);
|
243
243
|
free(curr);
|
@@ -263,7 +263,7 @@ int rb_w32_cmdvector(const char *cmd, char ***vec) {
|
|
263
263
|
|
264
264
|
ptr = buffer + (elements+1) * sizeof(char *);
|
265
265
|
|
266
|
-
while (curr = cmdhead) {
|
266
|
+
while ((curr = cmdhead)) {
|
267
267
|
strlcpy(ptr, curr->str, curr->len + 1);
|
268
268
|
*vptr++ = ptr;
|
269
269
|
ptr += curr->len + 1;
|
data/spec/launcher_spec.rb
CHANGED
@@ -21,11 +21,12 @@ describe "JRuby native launcher" do
|
|
21
21
|
end
|
22
22
|
|
23
23
|
it "should use $JAVACMD when JAVACMD is specified" do
|
24
|
-
|
24
|
+
javacmd_path = File.join("path", "to", "jato")
|
25
|
+
with_environment "JAVACMD" => javacmd_path do
|
25
26
|
if windows?
|
26
|
-
jruby_launcher_args("-v 2>&1").join.should =~
|
27
|
+
jruby_launcher_args("-v 2>&1").join.should =~ /#{javacmd_path}/
|
27
28
|
else
|
28
|
-
jruby_launcher_args("-v").first.should ==
|
29
|
+
jruby_launcher_args("-v").first.should == javacmd_path
|
29
30
|
end
|
30
31
|
end
|
31
32
|
end
|
@@ -180,6 +181,9 @@ describe "JRuby native launcher" do
|
|
180
181
|
|
181
182
|
# JRUBY-4706
|
182
183
|
it "should put JRuby on regular classpath when -Xnobootclasspath is used" do
|
184
|
+
# Java 9+ do not like bootclasspath so we do not use it
|
185
|
+
skip if ENV_JAVA['java.specification.version'].to_i >= 9
|
186
|
+
|
183
187
|
args = jruby_launcher_args("-e true")
|
184
188
|
args.grep(/Xbootclasspath/).should_not be_empty
|
185
189
|
args = jruby_launcher_args("-Xnobootclasspath -e true")
|
@@ -236,6 +240,9 @@ describe "JRuby native launcher" do
|
|
236
240
|
after { FileUtils.rm_rf jruby_home }
|
237
241
|
|
238
242
|
it "should add jruby.jar to the bootclasspath" do
|
243
|
+
# Java 9+ do not like bootclasspath so we do not use it
|
244
|
+
skip if ENV_JAVA['java.specification.version'].to_i >= 9
|
245
|
+
|
239
246
|
with_environment "JRUBY_HOME" => jruby_home do
|
240
247
|
jruby_launcher_args("").should include("-Xbootclasspath/a:#{jruby_home}/lib/jruby.jar")
|
241
248
|
end
|
@@ -257,9 +264,12 @@ describe "JRuby native launcher" do
|
|
257
264
|
jruby_launcher_args("-e %s%s%s%s%s 2>&1").should include('-e', '%s%s%s%s%s')
|
258
265
|
end
|
259
266
|
|
260
|
-
it "should use --module-path on java9+" do
|
267
|
+
it "should use --module-path on java9+ jruby 9.2.1+" do
|
268
|
+
# versions prior to 9.2.1 do not set a predictable module name
|
269
|
+
skip unless (JRUBY_VERSION.split('.') <=> ['9', '2', '1']) >= 0
|
270
|
+
|
261
271
|
Dir.mktmpdir do |java_home|
|
262
|
-
|
272
|
+
FileUtils.mkdir_p(File.join(java_home, 'lib/modules'))
|
263
273
|
with_environment 'JAVA_HOME' => java_home do
|
264
274
|
jruby_launcher_args('').grep(/^--module-path=.*jruby.jar/).should_not be_empty
|
265
275
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -2,11 +2,6 @@ require 'rspec'
|
|
2
2
|
require 'rbconfig'
|
3
3
|
require 'fileutils'
|
4
4
|
|
5
|
-
if defined?(JRUBY_VERSION)
|
6
|
-
require 'jruby'
|
7
|
-
JRuby.runtime.instance_config.run_ruby_in_process = false
|
8
|
-
end
|
9
|
-
|
10
5
|
module JRubyLauncherHelper
|
11
6
|
JRUBY_EXE = ''
|
12
7
|
WINDOWS = RbConfig::CONFIG['target_os'] =~ /mswin/
|
data/unixlauncher.cpp
CHANGED
@@ -46,6 +46,9 @@ int UnixLauncher::run(int argc, char* argv[], char* envp[]) {
|
|
46
46
|
|
47
47
|
if (getenv("JAVACMD") != NULL) {
|
48
48
|
java = getenv("JAVACMD");
|
49
|
+
if (java.find_last_of('/') == -1) {
|
50
|
+
java = findOnPath(java.c_str());
|
51
|
+
}
|
49
52
|
} else {
|
50
53
|
if (!jdkhome.empty()) {
|
51
54
|
java = jdkhome + "/bin/java";
|
@@ -64,6 +67,13 @@ int UnixLauncher::run(int argc, char* argv[], char* envp[]) {
|
|
64
67
|
return 255;
|
65
68
|
}
|
66
69
|
|
70
|
+
// still no jdk home, use java command to resolve it
|
71
|
+
if (jdkhome.empty()) {
|
72
|
+
java = resolveSymlinks(java);
|
73
|
+
int home_index = java.find_last_of('/', java.find_last_of('/') - 1);
|
74
|
+
jdkhome = java.substr(0, home_index);
|
75
|
+
}
|
76
|
+
|
67
77
|
prepareOptions();
|
68
78
|
|
69
79
|
list<string> commandLine;
|
data/utilsfuncs.cpp
CHANGED
@@ -54,6 +54,7 @@
|
|
54
54
|
#include <unistd.h>
|
55
55
|
#include "utilsfuncs.h"
|
56
56
|
#include "argnames.h"
|
57
|
+
#include <limits.h>
|
57
58
|
|
58
59
|
#ifndef WIN32
|
59
60
|
#include <sys/stat.h>
|
@@ -123,7 +124,6 @@ string findOnPath(const char* name) {
|
|
123
124
|
string path(getenv("PATH"));
|
124
125
|
size_t start = 0;
|
125
126
|
size_t sep;
|
126
|
-
char * found;
|
127
127
|
|
128
128
|
while (start < path.length()) {
|
129
129
|
sep = path.find(PATH_SEP, start);
|
@@ -147,6 +147,19 @@ string findOnPath(const char* name) {
|
|
147
147
|
return "";
|
148
148
|
}
|
149
149
|
|
150
|
+
string resolveSymlinks(string path) {
|
151
|
+
#ifndef WIN32
|
152
|
+
struct stat st;
|
153
|
+
char tmp[PATH_MAX + 1];
|
154
|
+
|
155
|
+
if (lstat(path.c_str(), &st) == 0 && (st.st_mode & S_IFMT) == S_IFLNK) {
|
156
|
+
realpath(path.c_str(), tmp);
|
157
|
+
path = tmp;
|
158
|
+
}
|
159
|
+
#endif
|
160
|
+
return path;
|
161
|
+
}
|
162
|
+
|
150
163
|
const char* getSysError(char *str, int strSize) {
|
151
164
|
#ifdef WIN32
|
152
165
|
int err = GetLastError();
|
data/utilsfuncs.h
CHANGED
@@ -57,6 +57,7 @@ bool printToConsole(const char *msg);
|
|
57
57
|
char** convertToArgvArray(std::list<std::string> args);
|
58
58
|
void addToArgList(std::list<std::string> & args, int argc, char ** argv);
|
59
59
|
std::string findOnPath(const char* name);
|
60
|
+
std::string resolveSymlinks(std::string name);
|
60
61
|
bool checkDirectory(const char* path);
|
61
62
|
void printListToConsole(std::list<std::string> l);
|
62
63
|
std::string trimTrailingBackslashes(std::string orig);
|
data/utilsfuncswin.cpp
CHANGED
@@ -39,10 +39,27 @@ bool disableFolderVirtualization(HANDLE hProcess) {
|
|
39
39
|
return true;
|
40
40
|
}
|
41
41
|
|
42
|
+
typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL);
|
43
|
+
|
44
|
+
LPFN_ISWOW64PROCESS IsWow64Process;
|
45
|
+
|
46
|
+
BOOL is64bits() {
|
47
|
+
BOOL is64Bits = FALSE;
|
48
|
+
IsWow64Process = (LPFN_ISWOW64PROCESS) GetProcAddress(GetModuleHandle(TEXT("kernel32")),"IsWow64Process");
|
49
|
+
|
50
|
+
if (IsWow64Process && !IsWow64Process(GetCurrentProcess(),&is64Bits)) {}
|
51
|
+
|
52
|
+
return is64Bits;
|
53
|
+
}
|
54
|
+
|
55
|
+
#define KEY_WOW64_64KEY 0x0100
|
56
|
+
#define KEY_WOW64_32KEY 0x0200
|
57
|
+
|
42
58
|
bool getStringFromRegistry(HKEY rootKey, const char *keyName, const char *valueName, string &value) {
|
43
59
|
logMsg("getStringFromRegistry()\n\tkeyName: %s\n\tvalueName: %s", keyName, valueName);
|
60
|
+
DWORD openFlags = KEY_READ | (is64bits() ? KEY_WOW64_64KEY : KEY_WOW64_32KEY);
|
44
61
|
HKEY hKey = 0;
|
45
|
-
if (RegOpenKeyEx(rootKey, keyName, 0,
|
62
|
+
if (RegOpenKeyEx(rootKey, keyName, 0, openFlags, &hKey) == ERROR_SUCCESS) {
|
46
63
|
DWORD valSize = 4096;
|
47
64
|
DWORD type = 0;
|
48
65
|
char val[4096] = "";
|
@@ -64,8 +81,9 @@ bool getStringFromRegistry(HKEY rootKey, const char *keyName, const char *valueN
|
|
64
81
|
|
65
82
|
bool getDwordFromRegistry(HKEY rootKey, const char *keyName, const char *valueName, DWORD &value) {
|
66
83
|
logMsg("getDwordFromRegistry()\n\tkeyName: %s\n\tvalueName: %s", keyName, valueName);
|
84
|
+
DWORD openFlags = KEY_READ | (is64bits() ? KEY_WOW64_64KEY : KEY_WOW64_32KEY);
|
67
85
|
HKEY hKey = 0;
|
68
|
-
if (RegOpenKeyEx(rootKey, keyName, 0,
|
86
|
+
if (RegOpenKeyEx(rootKey, keyName, 0, openFlags, &hKey) == ERROR_SUCCESS) {
|
69
87
|
DWORD valSize = sizeof(DWORD);
|
70
88
|
DWORD type = 0;
|
71
89
|
if (RegQueryValueEx(hKey, valueName, 0, &type, (BYTE *) &value, &valSize) == ERROR_SUCCESS
|
data/version.h
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jruby-launcher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.17
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Nick Sieger
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2021-06-07 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Builds and installs a native launcher for JRuby on your system
|
15
15
|
email:
|
@@ -71,7 +71,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
71
71
|
- !ruby/object:Gem::Version
|
72
72
|
version: '0'
|
73
73
|
requirements: []
|
74
|
-
rubygems_version: 3.
|
74
|
+
rubygems_version: 3.1.6
|
75
75
|
signing_key:
|
76
76
|
specification_version: 4
|
77
77
|
summary: Native launcher for JRuby
|