jruby-launcher 1.1.13-java → 1.1.18-java

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b11fc4e524ed4b37e0f46d973c6622df18dbf9676a5ca2c03fbb046a1dcd216b
4
- data.tar.gz: 2b12dc9ce4c66cd0142747f9ec5898c051414f53f2080119c25c827df336eb13
3
+ metadata.gz: ee2a847c5f128137c841713780abadbab52109b3907b83f207c81bf3875e285b
4
+ data.tar.gz: 79c3d6ead6c02523f0b3756ed9f93ba0f5f36bd869297ba87636cb98d920e1e0
5
5
  SHA512:
6
- metadata.gz: 0ebe917d3d4f1c416533a5e3afbb0ce5a1394c14c43f6618b97b0b8dc09265d6a84071da2f69423fe1d5da9d49ce3f5f03e47fc247d8c67fe38395bfaa064d29
7
- data.tar.gz: ca74d57e9ca2f052e705209271eb8a6426122c9620b0423e0828de3dd7eb818808fa6f2624c2109e750582c372cb8011424e304b794eb4036e3a725b7429b136
6
+ metadata.gz: c71302725612bbe3e9a4c28329719528b4d15cf3b890eba24625206c735d2db27e94ad5dec691866ff21092ea24e7e8a657cba5e381ed2ed66c316b742ee61ae
7
+ data.tar.gz: 0f1844a66a8d8c98cce8ab8f719ef021aa7c66470aad9943c53561222c229a9639ec0dfc4c1e01b7bf8b961ec5400e75d6202aec7c886fb6d630782d77fd0add
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"
@@ -557,12 +558,25 @@ void ArgParser::useModulesIfPresent() {
557
558
 
558
559
  if (jdkhome.empty()) {
559
560
  logMsg("Unable to detect JPMS modules as JAVA_HOME is not specified");
560
- } else if (access((jdkhome + "/jmods").c_str(), R_OK) == 0) {
561
+ } else if (access((jdkhome + "/lib/modules").c_str(), R_OK) == 0 ||
562
+ releaseFileHasModules()) {
561
563
  logMsg("JPMS jmods dir detected, using module flags");
562
564
  useModulePath = 1;
563
565
  }
564
566
  }
565
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
+
566
580
  void ArgParser::constructBootClassPath() {
567
581
  logMsg("constructBootClassPath()");
568
582
  addedToBootCP.clear();
data/argparser.h CHANGED
@@ -54,6 +54,7 @@ protected:
54
54
  void addOptionsToCommandLine(std::list<std::string> & commandLine);
55
55
  bool endsWith(const std::string &string, const std::string &end);
56
56
  void useModulesIfPresent();
57
+ bool releaseFileHasModules();
57
58
 
58
59
  protected:
59
60
  bool separateProcess;
@@ -1,3 +1,3 @@
1
1
  module JRubyLauncher
2
- VERSION = "1.1.13"
2
+ VERSION = "1.1.18"
3
3
  end
@@ -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
- # Pre-9.2.1: ALL-UNNAMED because no name was exported
8
- # 9.2.1 and higher: org.jruby.dist
9
- if JRUBY_VERSION !~ /(^1)|(^9\.[01])|(^9\.2\.0\.0)/
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}
@@ -1,3 +1,3 @@
1
1
  module JRubyLauncher
2
- VERSION = "1.1.13"
2
+ VERSION = "1.1.18"
3
3
  end
@@ -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
- with_environment "JAVACMD" => File.join("jato") do
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 =~ %r{jato}
27
+ jruby_launcher_args("-v 2>&1").join.should =~ /#{javacmd_path}/
27
28
  else
28
- jruby_launcher_args("-v").first.should == File.join("jato")
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
- Dir.mkdir(File.join(java_home, 'jmods'))
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
@@ -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
- with_environment "JAVACMD" => File.join("jato") do
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 =~ %r{jato}
27
+ jruby_launcher_args("-v 2>&1").join.should =~ /#{javacmd_path}/
27
28
  else
28
- jruby_launcher_args("-v").first.should == File.join("jato")
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
- Dir.mkdir(File.join(java_home, 'jmods'))
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/unixlauncher.cpp CHANGED
@@ -1,5 +1,7 @@
1
1
  #include <stdlib.h>
2
2
  #include <unistd.h>
3
+ #include <limits.h>
4
+ #include <string.h>
3
5
  #include "unixlauncher.h"
4
6
  #include "utilsfuncs.h"
5
7
 
@@ -46,6 +48,9 @@ int UnixLauncher::run(int argc, char* argv[], char* envp[]) {
46
48
 
47
49
  if (getenv("JAVACMD") != NULL) {
48
50
  java = getenv("JAVACMD");
51
+ if (java.find_last_of('/') == -1) {
52
+ java = findOnPath(java.c_str());
53
+ }
49
54
  } else {
50
55
  if (!jdkhome.empty()) {
51
56
  java = jdkhome + "/bin/java";
@@ -56,10 +61,6 @@ int UnixLauncher::run(int argc, char* argv[], char* envp[]) {
56
61
  java = java_home + "/bin/java";
57
62
  } else {
58
63
  java = findOnPath("java");
59
- if (!java.empty()) {
60
- int home_index = java.find_last_of('/', java.find_last_of('/') - 1);
61
- jdkhome = java.substr(0, home_index);
62
- }
63
64
  }
64
65
  }
65
66
 
@@ -68,6 +69,29 @@ int UnixLauncher::run(int argc, char* argv[], char* envp[]) {
68
69
  return 255;
69
70
  }
70
71
 
72
+ // still no jdk home, use other means to resolve it
73
+ if (jdkhome.empty()) {
74
+ if (access("/usr/libexec/java_home", X_OK) != -1) {
75
+ // try java_home command when not set (on MacOS)
76
+ FILE *fp;
77
+ char tmp[PATH_MAX + 1];
78
+
79
+ fp = popen("/usr/libexec/java_home", "r");
80
+ if (fp != NULL) {
81
+ fgets(tmp, sizeof(tmp), fp);
82
+ tmp[strcspn(tmp, "\n")] = 0;
83
+ jdkhome = tmp;
84
+ pclose(fp);
85
+ } else {
86
+ logErr(true, false, "failed to run /usr/libexec/java_home");
87
+ }
88
+ } else {
89
+ java = resolveSymlinks(java);
90
+ int home_index = java.find_last_of('/', java.find_last_of('/') - 1);
91
+ jdkhome = java.substr(0, home_index);
92
+ }
93
+ }
94
+
71
95
  prepareOptions();
72
96
 
73
97
  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>
@@ -146,6 +147,19 @@ string findOnPath(const char* name) {
146
147
  return "";
147
148
  }
148
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
+
149
163
  const char* getSysError(char *str, int strSize) {
150
164
  #ifdef WIN32
151
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/version.h CHANGED
@@ -6,6 +6,6 @@
6
6
  #ifndef _VERSION_H_
7
7
  #define _VERSION_H_
8
8
 
9
- #define JRUBY_LAUNCHER_VERSION "1.1.13"
9
+ #define JRUBY_LAUNCHER_VERSION "1.1.18"
10
10
 
11
11
  #endif // ! _VERSION_H_
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.13
4
+ version: 1.1.18
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: 2020-03-20 00:00:00.000000000 Z
12
+ date: 2021-06-30 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:
@@ -39,11 +39,11 @@ files:
39
39
  - lib/rubygems/defaults/jruby_native.rb
40
40
  - nbexecloader.h
41
41
  - ng.c
42
- - pkg/jruby-launcher-1.1.12-java/extconf.rb
43
- - pkg/jruby-launcher-1.1.12-java/lib/jruby-launcher.rb
44
- - pkg/jruby-launcher-1.1.12-java/lib/rubygems/defaults/jruby_native.rb
45
- - pkg/jruby-launcher-1.1.12-java/spec/launcher_spec.rb
46
- - pkg/jruby-launcher-1.1.12-java/spec/spec_helper.rb
42
+ - pkg/jruby-launcher-1.1.17-java/extconf.rb
43
+ - pkg/jruby-launcher-1.1.17-java/lib/jruby-launcher.rb
44
+ - pkg/jruby-launcher-1.1.17-java/lib/rubygems/defaults/jruby_native.rb
45
+ - pkg/jruby-launcher-1.1.17-java/spec/launcher_spec.rb
46
+ - pkg/jruby-launcher-1.1.17-java/spec/spec_helper.rb
47
47
  - platformlauncher.cpp
48
48
  - platformlauncher.h
49
49
  - rb_w32_cmdvector.h
@@ -76,7 +76,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
76
76
  - !ruby/object:Gem::Version
77
77
  version: '0'
78
78
  requirements: []
79
- rubygems_version: 3.0.6
79
+ rubygems_version: 3.1.6
80
80
  signing_key:
81
81
  specification_version: 4
82
82
  summary: Native launcher for JRuby