jruby-launcher 1.1.18-java → 1.1.19-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 +4 -4
 - data/lib/jruby-launcher.rb +1 -1
 - data/pkg/jruby-launcher-1.1.17-java/lib/jruby-launcher.rb +1 -1
 - data/pkg/jruby-launcher-1.1.18-java/extconf.rb +12 -0
 - data/pkg/jruby-launcher-1.1.18-java/lib/jruby-launcher.rb +3 -0
 - data/pkg/jruby-launcher-1.1.18-java/lib/rubygems/defaults/jruby_native.rb +4 -0
 - data/pkg/jruby-launcher-1.1.18-java/pkg/jruby-launcher-1.1.17-java/extconf.rb +12 -0
 - data/pkg/jruby-launcher-1.1.18-java/pkg/jruby-launcher-1.1.17-java/lib/jruby-launcher.rb +3 -0
 - data/pkg/jruby-launcher-1.1.18-java/pkg/jruby-launcher-1.1.17-java/lib/rubygems/defaults/jruby_native.rb +4 -0
 - data/pkg/jruby-launcher-1.1.18-java/pkg/jruby-launcher-1.1.17-java/spec/launcher_spec.rb +288 -0
 - data/pkg/jruby-launcher-1.1.18-java/pkg/jruby-launcher-1.1.17-java/spec/spec_helper.rb +76 -0
 - data/pkg/jruby-launcher-1.1.18-java/spec/launcher_spec.rb +288 -0
 - data/pkg/jruby-launcher-1.1.18-java/spec/spec_helper.rb +76 -0
 - data/unixlauncher.cpp +5 -3
 - data/version.h +1 -1
 - metadata +12 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 4ecfe0c07cb66457b2c9cc77b1d668a15835d56bcf326de6e8f9cfcd1122763f
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: ad0992bab78ac9c83d1b48448e29ec01e93701201ec34f9ac8d6e1c26dca3e3c
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 8676543dbae71684742514ba1a27e6915dafe8f885056e04470aa50aa722c8b594cdd240135d43a46547fd33f616b3f45081adfe0ee0ac18a2a1d3685a0993c0
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 953e37dbafefc57de9d17e342e3e550ee87c8f01eb44518557d41db6ba488e8eac1dcca1527daf09db67a7efb9c1249934213886feebf23c3ee2bfa9b91f90cc
         
     | 
    
        data/lib/jruby-launcher.rb
    CHANGED
    
    
| 
         @@ -0,0 +1,12 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            mf = File.read('Makefile')
         
     | 
| 
      
 2 
     | 
    
         
            +
            mf = mf.gsub(/^BINDIR\s*=.*$/, "BINDIR = #{RbConfig::CONFIG['bindir']}")
         
     | 
| 
      
 3 
     | 
    
         
            +
            mf = mf.gsub(/^PREFIX\s*=.*$/, "PREFIX = #{File.dirname(RbConfig::CONFIG['libdir'])}")
         
     | 
| 
      
 4 
     | 
    
         
            +
            mf = mf.gsub(/^JRUBY_VERSION\s*=.*$/, "JRUBY_VERSION = #{JRUBY_VERSION}")
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            # Launcher will use .module_opts file if present, otherwise hardcoded add-opens for this module.
         
     | 
| 
      
 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 =")
         
     | 
| 
      
 10 
     | 
    
         
            +
            end
         
     | 
| 
      
 11 
     | 
    
         
            +
            puts mf
         
     | 
| 
      
 12 
     | 
    
         
            +
            File.open('Makefile', 'wb') {|f| f << mf}
         
     | 
| 
         @@ -0,0 +1,12 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            mf = File.read('Makefile')
         
     | 
| 
      
 2 
     | 
    
         
            +
            mf = mf.gsub(/^BINDIR\s*=.*$/, "BINDIR = #{RbConfig::CONFIG['bindir']}")
         
     | 
| 
      
 3 
     | 
    
         
            +
            mf = mf.gsub(/^PREFIX\s*=.*$/, "PREFIX = #{File.dirname(RbConfig::CONFIG['libdir'])}")
         
     | 
| 
      
 4 
     | 
    
         
            +
            mf = mf.gsub(/^JRUBY_VERSION\s*=.*$/, "JRUBY_VERSION = #{JRUBY_VERSION}")
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            # Launcher will use .module_opts file if present, otherwise hardcoded add-opens for this module.
         
     | 
| 
      
 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 =")
         
     | 
| 
      
 10 
     | 
    
         
            +
            end
         
     | 
| 
      
 11 
     | 
    
         
            +
            puts mf
         
     | 
| 
      
 12 
     | 
    
         
            +
            File.open('Makefile', 'wb') {|f| f << mf}
         
     | 
| 
         @@ -0,0 +1,288 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'tmpdir'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require File.expand_path('../spec_helper.rb', __FILE__)
         
     | 
| 
      
 3 
     | 
    
         
            +
            load File.expand_path('../../lib/jruby-launcher.rb', __FILE__)
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            describe "JRuby native launcher" do
         
     | 
| 
      
 6 
     | 
    
         
            +
              it "should run org.jruby.Main" do
         
     | 
| 
      
 7 
     | 
    
         
            +
                jruby_launcher_args("").last.should == "org/jruby/Main"
         
     | 
| 
      
 8 
     | 
    
         
            +
              end
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
              it "should pass unrecognized arguments to JRuby" do
         
     | 
| 
      
 11 
     | 
    
         
            +
                jruby_launcher_args("-J-Dsome.option -v --help")[-3..-1].should == ["org/jruby/Main", "-v", "--help"]
         
     | 
| 
      
 12 
     | 
    
         
            +
              end
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
              it "should print help message" do
         
     | 
| 
      
 15 
     | 
    
         
            +
                args = jruby_launcher_args("-Xhelp 2>&1")
         
     | 
| 
      
 16 
     | 
    
         
            +
                args.select {|l| l =~ /JRuby Launcher usage/}.should_not be_empty
         
     | 
| 
      
 17 
     | 
    
         
            +
                args.should include("-X")
         
     | 
| 
      
 18 
     | 
    
         
            +
                args = jruby_launcher_args("-X 2>&1")
         
     | 
| 
      
 19 
     | 
    
         
            +
                args.detect {|l| l =~ /JRuby Launcher usage/}.should_not be_empty
         
     | 
| 
      
 20 
     | 
    
         
            +
                args.should include("-X")
         
     | 
| 
      
 21 
     | 
    
         
            +
              end
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
              it "should use $JAVACMD when JAVACMD is specified" do
         
     | 
| 
      
 24 
     | 
    
         
            +
                javacmd_path = File.join("path", "to", "jato")
         
     | 
| 
      
 25 
     | 
    
         
            +
                with_environment "JAVACMD" => javacmd_path do
         
     | 
| 
      
 26 
     | 
    
         
            +
                  if windows?
         
     | 
| 
      
 27 
     | 
    
         
            +
                    jruby_launcher_args("-v 2>&1").join.should =~ /#{javacmd_path}/
         
     | 
| 
      
 28 
     | 
    
         
            +
                  else
         
     | 
| 
      
 29 
     | 
    
         
            +
                    jruby_launcher_args("-v").first.should == javacmd_path
         
     | 
| 
      
 30 
     | 
    
         
            +
                  end
         
     | 
| 
      
 31 
     | 
    
         
            +
                end
         
     | 
| 
      
 32 
     | 
    
         
            +
              end
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
              it "should use $JAVA_HOME/bin/java when JAVA_HOME is specified" do
         
     | 
| 
      
 35 
     | 
    
         
            +
                with_environment "JAVA_HOME" => File.join("some", "java", "home") do
         
     | 
| 
      
 36 
     | 
    
         
            +
                  if windows?
         
     | 
| 
      
 37 
     | 
    
         
            +
                    jruby_launcher_args("-v 2>&1").join.should =~ %r{some/java/home}
         
     | 
| 
      
 38 
     | 
    
         
            +
                  else
         
     | 
| 
      
 39 
     | 
    
         
            +
                    jruby_launcher_args("-v").first.should == File.join("some", "java", "home", "bin", "java")
         
     | 
| 
      
 40 
     | 
    
         
            +
                  end
         
     | 
| 
      
 41 
     | 
    
         
            +
                end
         
     | 
| 
      
 42 
     | 
    
         
            +
              end
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
              it "should use -Xjdkhome argument above JAVA_HOME" do
         
     | 
| 
      
 45 
     | 
    
         
            +
                with_environment "JAVA_HOME" => File.join("env", "java", "home") do
         
     | 
| 
      
 46 
     | 
    
         
            +
                  if windows?
         
     | 
| 
      
 47 
     | 
    
         
            +
                    jruby_launcher_args("-Xjdkhome some/java/home 2>&1").join.should =~ %r{some/java/home}
         
     | 
| 
      
 48 
     | 
    
         
            +
                  else
         
     | 
| 
      
 49 
     | 
    
         
            +
                    jruby_launcher_args("-Xjdkhome some/java/home").first.should == File.join("some", "java", "home", "bin", "java")
         
     | 
| 
      
 50 
     | 
    
         
            +
                  end
         
     | 
| 
      
 51 
     | 
    
         
            +
                end
         
     | 
| 
      
 52 
     | 
    
         
            +
              end
         
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
      
 54 
     | 
    
         
            +
              it "should drop the backslashes at the end of JAVA_HOME" do
         
     | 
| 
      
 55 
     | 
    
         
            +
                with_environment "JAVA_HOME" => File.join("some", "java", "home\\\\") do
         
     | 
| 
      
 56 
     | 
    
         
            +
                  if windows?
         
     | 
| 
      
 57 
     | 
    
         
            +
                    jruby_launcher_args("").join.should =~ %r{some/java/home}
         
     | 
| 
      
 58 
     | 
    
         
            +
                  else
         
     | 
| 
      
 59 
     | 
    
         
            +
                    jruby_launcher_args("").first.should == File.join("some", "java", "home", "bin", "java")
         
     | 
| 
      
 60 
     | 
    
         
            +
                  end
         
     | 
| 
      
 61 
     | 
    
         
            +
                end
         
     | 
| 
      
 62 
     | 
    
         
            +
              end
         
     | 
| 
      
 63 
     | 
    
         
            +
             
     | 
| 
      
 64 
     | 
    
         
            +
              it "should complain about a missing log argument" do
         
     | 
| 
      
 65 
     | 
    
         
            +
                jruby_launcher("-Xtrace 2>&1").should =~ /Argument is missing for "-Xtrace"/
         
     | 
| 
      
 66 
     | 
    
         
            +
                jruby_launcher("-Xtrace -- 2>&1").should =~ /Argument is missing for "-Xtrace"/
         
     | 
| 
      
 67 
     | 
    
         
            +
              end
         
     | 
| 
      
 68 
     | 
    
         
            +
             
     | 
| 
      
 69 
     | 
    
         
            +
              it "should complain about a missing jdkhome argument" do
         
     | 
| 
      
 70 
     | 
    
         
            +
                jruby_launcher("-Xjdkhome 2>&1").should =~ /Argument is missing/
         
     | 
| 
      
 71 
     | 
    
         
            +
                jruby_launcher("-Xjdkhome -- 2>&1").should =~ /Argument is missing/
         
     | 
| 
      
 72 
     | 
    
         
            +
              end
         
     | 
| 
      
 73 
     | 
    
         
            +
             
     | 
| 
      
 74 
     | 
    
         
            +
              it "should complain about a missing classpath append argument" do
         
     | 
| 
      
 75 
     | 
    
         
            +
                jruby_launcher("-Xcp:a 2>&1").should =~ /Argument is missing/
         
     | 
| 
      
 76 
     | 
    
         
            +
                jruby_launcher("-Xcp:a -- 2>&1").should =~ /Argument is missing/
         
     | 
| 
      
 77 
     | 
    
         
            +
              end
         
     | 
| 
      
 78 
     | 
    
         
            +
             
     | 
| 
      
 79 
     | 
    
         
            +
              it "should run nailgun server with --ng-server option" do
         
     | 
| 
      
 80 
     | 
    
         
            +
                jruby_launcher_args("--ng-server").last.should == "com/martiansoftware/nailgun/NGServer"
         
     | 
| 
      
 81 
     | 
    
         
            +
              end
         
     | 
| 
      
 82 
     | 
    
         
            +
             
     | 
| 
      
 83 
     | 
    
         
            +
              it "should run nailgun client with --ng option" do
         
     | 
| 
      
 84 
     | 
    
         
            +
                jruby_launcher_args('--ng -e "puts 1"').should == ["org.jruby.util.NailMain", "-e", "puts 1"]
         
     | 
| 
      
 85 
     | 
    
         
            +
              end
         
     | 
| 
      
 86 
     | 
    
         
            +
             
     | 
| 
      
 87 
     | 
    
         
            +
              it "should handle -J JVM options" do
         
     | 
| 
      
 88 
     | 
    
         
            +
                jruby_launcher_args("-J-Darg1=value1 -J-Darg2=value2").should include("-Darg1=value1", "-Darg2=value2")
         
     | 
| 
      
 89 
     | 
    
         
            +
              end
         
     | 
| 
      
 90 
     | 
    
         
            +
             
     | 
| 
      
 91 
     | 
    
         
            +
              it "should pass -Xprop.erty=value as -J-Djruby.prop.erty=value" do
         
     | 
| 
      
 92 
     | 
    
         
            +
                jruby_launcher_args("-Xprop.erty=value").should include("-Djruby.prop.erty=value")
         
     | 
| 
      
 93 
     | 
    
         
            +
              end
         
     | 
| 
      
 94 
     | 
    
         
            +
             
     | 
| 
      
 95 
     | 
    
         
            +
              it "should pass -Xproperties as --properties" do
         
     | 
| 
      
 96 
     | 
    
         
            +
                jruby_launcher_args("-Xproperties").should include("--properties")
         
     | 
| 
      
 97 
     | 
    
         
            +
              end
         
     | 
| 
      
 98 
     | 
    
         
            +
             
     | 
| 
      
 99 
     | 
    
         
            +
              it "should allow max heap to be overridden" do
         
     | 
| 
      
 100 
     | 
    
         
            +
                jruby_launcher_args("-J-Xmx256m").should include("-Xmx256m")
         
     | 
| 
      
 101 
     | 
    
         
            +
              end
         
     | 
| 
      
 102 
     | 
    
         
            +
             
     | 
| 
      
 103 
     | 
    
         
            +
              it "should default to 2048k max stack" do
         
     | 
| 
      
 104 
     | 
    
         
            +
                jruby_launcher_args("").should include("-Xss2048k")
         
     | 
| 
      
 105 
     | 
    
         
            +
              end
         
     | 
| 
      
 106 
     | 
    
         
            +
             
     | 
| 
      
 107 
     | 
    
         
            +
              it "should allow max stack to be overridden" do
         
     | 
| 
      
 108 
     | 
    
         
            +
                jruby_launcher_args("-J-Xss512k").should include("-Xss512k")
         
     | 
| 
      
 109 
     | 
    
         
            +
              end
         
     | 
| 
      
 110 
     | 
    
         
            +
             
     | 
| 
      
 111 
     | 
    
         
            +
              it "should add the contents of the CLASSPATH environment variable" do
         
     | 
| 
      
 112 
     | 
    
         
            +
                with_environment "CLASSPATH" => "some.jar" do
         
     | 
| 
      
 113 
     | 
    
         
            +
                  classpath_arg(jruby_launcher_args("")).should =~ /some.jar/
         
     | 
| 
      
 114 
     | 
    
         
            +
                end
         
     | 
| 
      
 115 
     | 
    
         
            +
              end
         
     | 
| 
      
 116 
     | 
    
         
            +
             
     | 
| 
      
 117 
     | 
    
         
            +
              it "should add the classpath elements in proper order" do
         
     | 
| 
      
 118 
     | 
    
         
            +
                s = File::PATH_SEPARATOR
         
     | 
| 
      
 119 
     | 
    
         
            +
                with_environment "CLASSPATH" => "some-env.jar" do
         
     | 
| 
      
 120 
     | 
    
         
            +
                  args = jruby_launcher_args("-Xcp:a some-other.jar -Xcp:p some.jar")
         
     | 
| 
      
 121 
     | 
    
         
            +
                  classpath_arg(args).should =~ /some.jar.*#{s}some-env.jar#{s}some-other.jar/
         
     | 
| 
      
 122 
     | 
    
         
            +
                end
         
     | 
| 
      
 123 
     | 
    
         
            +
              end
         
     | 
| 
      
 124 
     | 
    
         
            +
             
     | 
| 
      
 125 
     | 
    
         
            +
              it "should use the --server compiler" do
         
     | 
| 
      
 126 
     | 
    
         
            +
                jruby_launcher_args("--server").should include("-server")
         
     | 
| 
      
 127 
     | 
    
         
            +
              end
         
     | 
| 
      
 128 
     | 
    
         
            +
             
     | 
| 
      
 129 
     | 
    
         
            +
              it "should use the --client compiler" do
         
     | 
| 
      
 130 
     | 
    
         
            +
                jruby_launcher_args("--client").should include("-client")
         
     | 
| 
      
 131 
     | 
    
         
            +
              end
         
     | 
| 
      
 132 
     | 
    
         
            +
             
     | 
| 
      
 133 
     | 
    
         
            +
              it "should set the JMX settings when --manage is present" do
         
     | 
| 
      
 134 
     | 
    
         
            +
                jruby_launcher_args("--manage").should include("-Dcom.sun.management.jmxremote", "-Djruby.management.enabled=true")
         
     | 
| 
      
 135 
     | 
    
         
            +
              end
         
     | 
| 
      
 136 
     | 
    
         
            +
             
     | 
| 
      
 137 
     | 
    
         
            +
              it "should set the headless flag when --headless is present" do
         
     | 
| 
      
 138 
     | 
    
         
            +
                jruby_launcher_args("--headless").should include("-Djava.awt.headless=true")
         
     | 
| 
      
 139 
     | 
    
         
            +
              end
         
     | 
| 
      
 140 
     | 
    
         
            +
             
     | 
| 
      
 141 
     | 
    
         
            +
              it "should pass -Xprof when --sample is present" do
         
     | 
| 
      
 142 
     | 
    
         
            +
                jruby_launcher_args("--sample").should include("-Xprof")
         
     | 
| 
      
 143 
     | 
    
         
            +
              end
         
     | 
| 
      
 144 
     | 
    
         
            +
             
     | 
| 
      
 145 
     | 
    
         
            +
              it "should stop argument processing when a -- is seen" do
         
     | 
| 
      
 146 
     | 
    
         
            +
                jruby_launcher_args("-- -Xhelp -Xtrace --headless").should include("-Xhelp", "-Xtrace", "--headless")
         
     | 
| 
      
 147 
     | 
    
         
            +
              end
         
     | 
| 
      
 148 
     | 
    
         
            +
             
     | 
| 
      
 149 
     | 
    
         
            +
              # JRUBY-4151
         
     | 
| 
      
 150 
     | 
    
         
            +
              it "should properly handle single quotes" do
         
     | 
| 
      
 151 
     | 
    
         
            +
                jruby_launcher_args("-e 'ABC DEF'").should include("ABC DEF")
         
     | 
| 
      
 152 
     | 
    
         
            +
              end
         
     | 
| 
      
 153 
     | 
    
         
            +
             
     | 
| 
      
 154 
     | 
    
         
            +
              # JRUBY-4581
         
     | 
| 
      
 155 
     | 
    
         
            +
              it "should prepend JRUBY_OPTS to the start of the argument list to process" do
         
     | 
| 
      
 156 
     | 
    
         
            +
                with_environment "JRUBY_OPTS" => "--server -J-Dsome.key=val -rubygems" do
         
     | 
| 
      
 157 
     | 
    
         
            +
                  jruby_launcher_args("-e 'ABC DEF'").should include("-server", "-Dsome.key=val", "-rubygems", "-e", "ABC DEF")
         
     | 
| 
      
 158 
     | 
    
         
            +
                end
         
     | 
| 
      
 159 
     | 
    
         
            +
              end
         
     | 
| 
      
 160 
     | 
    
         
            +
             
     | 
| 
      
 161 
     | 
    
         
            +
              # JRUBY-4611
         
     | 
| 
      
 162 
     | 
    
         
            +
              it "stops argument processing on first non-option argument" do
         
     | 
| 
      
 163 
     | 
    
         
            +
                jruby_launcher_args("foo.rb --sample")[-2..-1].should == ["foo.rb", "--sample"]
         
     | 
| 
      
 164 
     | 
    
         
            +
              end
         
     | 
| 
      
 165 
     | 
    
         
            +
             
     | 
| 
      
 166 
     | 
    
         
            +
              # JRUBY-4608
         
     | 
| 
      
 167 
     | 
    
         
            +
              if RbConfig::CONFIG['target_os'] =~ /darwin/i
         
     | 
| 
      
 168 
     | 
    
         
            +
                it "includes file.encoding=UTF-8 on Mac if JAVA_ENCODING is not set" do
         
     | 
| 
      
 169 
     | 
    
         
            +
                  jruby_launcher_args("-e true").should include("-Dfile.encoding=UTF-8")
         
     | 
| 
      
 170 
     | 
    
         
            +
                  with_environment "JAVA_ENCODING" => "MacRoman" do
         
     | 
| 
      
 171 
     | 
    
         
            +
                    jruby_launcher_args("-e true").should_not include("-Dfile.encoding=UTF-8")
         
     | 
| 
      
 172 
     | 
    
         
            +
                  end
         
     | 
| 
      
 173 
     | 
    
         
            +
                end
         
     | 
| 
      
 174 
     | 
    
         
            +
              end
         
     | 
| 
      
 175 
     | 
    
         
            +
             
     | 
| 
      
 176 
     | 
    
         
            +
              it "does not crash on empty args" do
         
     | 
| 
      
 177 
     | 
    
         
            +
                jruby_launcher_args("-e ''").should include("-e")
         
     | 
| 
      
 178 
     | 
    
         
            +
                jruby_launcher("-Xtrace '' 2>&1").should =~ /-Xtrace/
         
     | 
| 
      
 179 
     | 
    
         
            +
                jruby_launcher("-Xjdkhome '' 2>&1").should =~ /-Xjdkhome/
         
     | 
| 
      
 180 
     | 
    
         
            +
              end
         
     | 
| 
      
 181 
     | 
    
         
            +
             
     | 
| 
      
 182 
     | 
    
         
            +
              # JRUBY-4706
         
     | 
| 
      
 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 
     | 
    
         
            +
             
     | 
| 
      
 187 
     | 
    
         
            +
                args = jruby_launcher_args("-e true")
         
     | 
| 
      
 188 
     | 
    
         
            +
                args.grep(/Xbootclasspath/).should_not be_empty
         
     | 
| 
      
 189 
     | 
    
         
            +
                args = jruby_launcher_args("-Xnobootclasspath -e true")
         
     | 
| 
      
 190 
     | 
    
         
            +
                args.grep(/Xbootclasspath/).should be_empty
         
     | 
| 
      
 191 
     | 
    
         
            +
              end
         
     | 
| 
      
 192 
     | 
    
         
            +
             
     | 
| 
      
 193 
     | 
    
         
            +
              it "should put JRuby on regular classpath when VERIFY_JRUBY is set" do
         
     | 
| 
      
 194 
     | 
    
         
            +
                with_environment "VERIFY_JRUBY" => "true" do
         
     | 
| 
      
 195 
     | 
    
         
            +
                  args = jruby_launcher_args("-e true")
         
     | 
| 
      
 196 
     | 
    
         
            +
                  args.grep(/Xbootclasspath/).should be_empty
         
     | 
| 
      
 197 
     | 
    
         
            +
                end
         
     | 
| 
      
 198 
     | 
    
         
            +
              end
         
     | 
| 
      
 199 
     | 
    
         
            +
             
     | 
| 
      
 200 
     | 
    
         
            +
              # JRUBY-4709
         
     | 
| 
      
 201 
     | 
    
         
            +
              it "should include a bare : or ; at the end of the classpath, to include PWD in the path" do
         
     | 
| 
      
 202 
     | 
    
         
            +
                classpath_arg(jruby_launcher_args("-Xnobootclasspath -e true")).should =~
         
     | 
| 
      
 203 
     | 
    
         
            +
                  if windows?
         
     | 
| 
      
 204 
     | 
    
         
            +
                    /;$/
         
     | 
| 
      
 205 
     | 
    
         
            +
                  else
         
     | 
| 
      
 206 
     | 
    
         
            +
                    /:$/
         
     | 
| 
      
 207 
     | 
    
         
            +
                  end
         
     | 
| 
      
 208 
     | 
    
         
            +
              end
         
     | 
| 
      
 209 
     | 
    
         
            +
             
     | 
| 
      
 210 
     | 
    
         
            +
              # JRUBY-6016
         
     | 
| 
      
 211 
     | 
    
         
            +
              it "should honor JAVA_MEM" do
         
     | 
| 
      
 212 
     | 
    
         
            +
                with_environment "JAVA_MEM" => "-Xmx768m" do
         
     | 
| 
      
 213 
     | 
    
         
            +
                  jruby_launcher_args("").should include("-Xmx768m")
         
     | 
| 
      
 214 
     | 
    
         
            +
                end
         
     | 
| 
      
 215 
     | 
    
         
            +
              end
         
     | 
| 
      
 216 
     | 
    
         
            +
             
     | 
| 
      
 217 
     | 
    
         
            +
              it "should honor JAVA_STACK" do
         
     | 
| 
      
 218 
     | 
    
         
            +
                with_environment "JAVA_STACK" => "-Xss3072k" do
         
     | 
| 
      
 219 
     | 
    
         
            +
                  jruby_launcher_args("").should include("-Xss3072k")
         
     | 
| 
      
 220 
     | 
    
         
            +
                end
         
     | 
| 
      
 221 
     | 
    
         
            +
              end
         
     | 
| 
      
 222 
     | 
    
         
            +
             
     | 
| 
      
 223 
     | 
    
         
            +
              it "should honor JRUBY_HOME" do
         
     | 
| 
      
 224 
     | 
    
         
            +
                with_environment "JRUBY_HOME" => "/tmp" do
         
     | 
| 
      
 225 
     | 
    
         
            +
                  jruby_launcher_args("").should include("-Djruby.home=/tmp")
         
     | 
| 
      
 226 
     | 
    
         
            +
                end
         
     | 
| 
      
 227 
     | 
    
         
            +
              end
         
     | 
| 
      
 228 
     | 
    
         
            +
             
     | 
| 
      
 229 
     | 
    
         
            +
              context "JRUBY_HOME set and JRUBY_HOME/lib/jruby.jar exists" do
         
     | 
| 
      
 230 
     | 
    
         
            +
                let(:jruby_home) do
         
     | 
| 
      
 231 
     | 
    
         
            +
                  require 'tempfile'
         
     | 
| 
      
 232 
     | 
    
         
            +
                  t = Tempfile.new("jruby_home")
         
     | 
| 
      
 233 
     | 
    
         
            +
                  t.path.tap { t.close! }
         
     | 
| 
      
 234 
     | 
    
         
            +
                end
         
     | 
| 
      
 235 
     | 
    
         
            +
             
     | 
| 
      
 236 
     | 
    
         
            +
                before do
         
     | 
| 
      
 237 
     | 
    
         
            +
                  FileUtils.mkdir_p(File.join(jruby_home, "lib"))
         
     | 
| 
      
 238 
     | 
    
         
            +
                  FileUtils.touch(File.join(jruby_home, "lib", "jruby.jar"))
         
     | 
| 
      
 239 
     | 
    
         
            +
                end
         
     | 
| 
      
 240 
     | 
    
         
            +
                after { FileUtils.rm_rf jruby_home }
         
     | 
| 
      
 241 
     | 
    
         
            +
             
     | 
| 
      
 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 
     | 
    
         
            +
             
     | 
| 
      
 246 
     | 
    
         
            +
                  with_environment "JRUBY_HOME" => jruby_home do
         
     | 
| 
      
 247 
     | 
    
         
            +
                    jruby_launcher_args("").should include("-Xbootclasspath/a:#{jruby_home}/lib/jruby.jar")
         
     | 
| 
      
 248 
     | 
    
         
            +
                  end
         
     | 
| 
      
 249 
     | 
    
         
            +
                end
         
     | 
| 
      
 250 
     | 
    
         
            +
              end
         
     | 
| 
      
 251 
     | 
    
         
            +
             
     | 
| 
      
 252 
     | 
    
         
            +
              it "should place user-supplied options after default options" do
         
     | 
| 
      
 253 
     | 
    
         
            +
                args = jruby_launcher_args("-J-Djruby.home=/tmp")
         
     | 
| 
      
 254 
     | 
    
         
            +
                home_args = args.select {|x| x =~ /^-Djruby\.home/ }
         
     | 
| 
      
 255 
     | 
    
         
            +
                home_args.length.should == 2
         
     | 
| 
      
 256 
     | 
    
         
            +
                home_args.last.should == "-Djruby.home=/tmp"
         
     | 
| 
      
 257 
     | 
    
         
            +
              end
         
     | 
| 
      
 258 
     | 
    
         
            +
             
     | 
| 
      
 259 
     | 
    
         
            +
              it "should print the version" do
         
     | 
| 
      
 260 
     | 
    
         
            +
                jruby_launcher("-Xversion 2>&1").should =~ /Launcher Version #{JRubyLauncher::VERSION}/
         
     | 
| 
      
 261 
     | 
    
         
            +
              end
         
     | 
| 
      
 262 
     | 
    
         
            +
             
     | 
| 
      
 263 
     | 
    
         
            +
              it "should not crash on format-strings" do
         
     | 
| 
      
 264 
     | 
    
         
            +
                jruby_launcher_args("-e %s%s%s%s%s 2>&1").should include('-e', '%s%s%s%s%s')
         
     | 
| 
      
 265 
     | 
    
         
            +
              end
         
     | 
| 
      
 266 
     | 
    
         
            +
             
     | 
| 
      
 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 
     | 
    
         
            +
                
         
     | 
| 
      
 271 
     | 
    
         
            +
                Dir.mktmpdir do |java_home|
         
     | 
| 
      
 272 
     | 
    
         
            +
                  FileUtils.mkdir_p(File.join(java_home, 'lib/modules'))
         
     | 
| 
      
 273 
     | 
    
         
            +
                  with_environment 'JAVA_HOME' => java_home do
         
     | 
| 
      
 274 
     | 
    
         
            +
                    jruby_launcher_args('').grep(/^--module-path=.*jruby.jar/).should_not be_empty
         
     | 
| 
      
 275 
     | 
    
         
            +
                  end
         
     | 
| 
      
 276 
     | 
    
         
            +
                end
         
     | 
| 
      
 277 
     | 
    
         
            +
              end
         
     | 
| 
      
 278 
     | 
    
         
            +
             
     | 
| 
      
 279 
     | 
    
         
            +
              it "should not treat CLASSPATH entries as modules on java9+" do
         
     | 
| 
      
 280 
     | 
    
         
            +
                Dir.mktmpdir do |java_home|
         
     | 
| 
      
 281 
     | 
    
         
            +
                  Dir.mkdir(File.join(java_home, 'jmods'))
         
     | 
| 
      
 282 
     | 
    
         
            +
                  with_environment 'JAVA_HOME' => java_home, 'CLASSPATH' => '/some/lib.jar' do
         
     | 
| 
      
 283 
     | 
    
         
            +
                    jruby_launcher_args('').grep(/^--module-path=.*\/some\/lib.jar/).should be_empty
         
     | 
| 
      
 284 
     | 
    
         
            +
                    classpath_arg(jruby_launcher_args('')).should =~ /\/some\/lib.jar/
         
     | 
| 
      
 285 
     | 
    
         
            +
                  end
         
     | 
| 
      
 286 
     | 
    
         
            +
                end
         
     | 
| 
      
 287 
     | 
    
         
            +
              end
         
     | 
| 
      
 288 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,76 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'rspec'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'rbconfig'
         
     | 
| 
      
 3 
     | 
    
         
            +
            require 'fileutils'
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            module JRubyLauncherHelper
         
     | 
| 
      
 6 
     | 
    
         
            +
              JRUBY_EXE = ''
         
     | 
| 
      
 7 
     | 
    
         
            +
              WINDOWS = RbConfig::CONFIG['target_os'] =~ /mswin/
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
              def self.check_executable_built
         
     | 
| 
      
 10 
     | 
    
         
            +
                exe = File.expand_path("../../jruby", __FILE__) + RbConfig::CONFIG['EXEEXT']
         
     | 
| 
      
 11 
     | 
    
         
            +
                unless File.executable?(exe)
         
     | 
| 
      
 12 
     | 
    
         
            +
                  raise "Error: launcher executable not built; type `make' before continuing."
         
     | 
| 
      
 13 
     | 
    
         
            +
                end
         
     | 
| 
      
 14 
     | 
    
         
            +
                top = File.dirname(exe)
         
     | 
| 
      
 15 
     | 
    
         
            +
                name = File.basename(exe)
         
     | 
| 
      
 16 
     | 
    
         
            +
                home = File.join(top, "build/home")
         
     | 
| 
      
 17 
     | 
    
         
            +
                FileUtils.mkdir_p(File.join(home, "bin"))
         
     | 
| 
      
 18 
     | 
    
         
            +
                FileUtils.cp(exe, File.join(home, "bin"))
         
     | 
| 
      
 19 
     | 
    
         
            +
                if JRubyLauncherHelper::WINDOWS
         
     | 
| 
      
 20 
     | 
    
         
            +
                  FileUtils.cp(exe.sub(/exe/, 'dll'), File.join(home, "bin"))
         
     | 
| 
      
 21 
     | 
    
         
            +
                end
         
     | 
| 
      
 22 
     | 
    
         
            +
                FileUtils.mkdir_p(File.join(home, "lib"))
         
     | 
| 
      
 23 
     | 
    
         
            +
                FileUtils.touch(File.join(home, "lib/jruby.jar"))
         
     | 
| 
      
 24 
     | 
    
         
            +
                JRUBY_EXE.concat File.join(home, "bin", name)
         
     | 
| 
      
 25 
     | 
    
         
            +
              end
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
              def jruby_launcher(args)
         
     | 
| 
      
 28 
     | 
    
         
            +
                `#{JRUBY_EXE} #{args}`
         
     | 
| 
      
 29 
     | 
    
         
            +
              end
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
              def jruby_launcher_args(args)
         
     | 
| 
      
 32 
     | 
    
         
            +
                jruby_launcher("-Xcommand #{args}").split("\n")
         
     | 
| 
      
 33 
     | 
    
         
            +
              end
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
              def last_exit_code
         
     | 
| 
      
 36 
     | 
    
         
            +
                $?.exitstatus
         
     | 
| 
      
 37 
     | 
    
         
            +
              end
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
              def windows?
         
     | 
| 
      
 40 
     | 
    
         
            +
                WINDOWS
         
     | 
| 
      
 41 
     | 
    
         
            +
              end
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
              def classpath_arg(args)
         
     | 
| 
      
 44 
     | 
    
         
            +
                index = args.index("-cp")
         
     | 
| 
      
 45 
     | 
    
         
            +
                index.should > 0
         
     | 
| 
      
 46 
     | 
    
         
            +
                args[index + 1]
         
     | 
| 
      
 47 
     | 
    
         
            +
              end
         
     | 
| 
      
 48 
     | 
    
         
            +
             
     | 
| 
      
 49 
     | 
    
         
            +
              def with_environment(pairs = {})
         
     | 
| 
      
 50 
     | 
    
         
            +
                prev_env = {}
         
     | 
| 
      
 51 
     | 
    
         
            +
                pairs.each_pair do |k,v|
         
     | 
| 
      
 52 
     | 
    
         
            +
                  prev_env[k] = ENV[k] if ENV.has_key?(k)
         
     | 
| 
      
 53 
     | 
    
         
            +
                  ENV[k] = v
         
     | 
| 
      
 54 
     | 
    
         
            +
                end
         
     | 
| 
      
 55 
     | 
    
         
            +
                begin
         
     | 
| 
      
 56 
     | 
    
         
            +
                  yield
         
     | 
| 
      
 57 
     | 
    
         
            +
                ensure
         
     | 
| 
      
 58 
     | 
    
         
            +
                  pairs.keys.each {|k| ENV.delete(k)}
         
     | 
| 
      
 59 
     | 
    
         
            +
                  ENV.update(prev_env)
         
     | 
| 
      
 60 
     | 
    
         
            +
                end
         
     | 
| 
      
 61 
     | 
    
         
            +
              end
         
     | 
| 
      
 62 
     | 
    
         
            +
            end
         
     | 
| 
      
 63 
     | 
    
         
            +
             
     | 
| 
      
 64 
     | 
    
         
            +
            RSpec.configure do |config|
         
     | 
| 
      
 65 
     | 
    
         
            +
              config.before(:all) do
         
     | 
| 
      
 66 
     | 
    
         
            +
                JRubyLauncherHelper.check_executable_built
         
     | 
| 
      
 67 
     | 
    
         
            +
                # clear environment for better control
         
     | 
| 
      
 68 
     | 
    
         
            +
                ENV.delete("JAVA_HOME")
         
     | 
| 
      
 69 
     | 
    
         
            +
                ENV.delete("JRUBY_HOME")
         
     | 
| 
      
 70 
     | 
    
         
            +
                ENV.delete("JAVA_OPTS")
         
     | 
| 
      
 71 
     | 
    
         
            +
                ENV.delete("JRUBY_OPTS")
         
     | 
| 
      
 72 
     | 
    
         
            +
                ENV.delete("CLASSPATH")
         
     | 
| 
      
 73 
     | 
    
         
            +
                ENV.delete("JAVA_ENCODING")
         
     | 
| 
      
 74 
     | 
    
         
            +
              end
         
     | 
| 
      
 75 
     | 
    
         
            +
              config.include(JRubyLauncherHelper)
         
     | 
| 
      
 76 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,288 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'tmpdir'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require File.expand_path('../spec_helper.rb', __FILE__)
         
     | 
| 
      
 3 
     | 
    
         
            +
            load File.expand_path('../../lib/jruby-launcher.rb', __FILE__)
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            describe "JRuby native launcher" do
         
     | 
| 
      
 6 
     | 
    
         
            +
              it "should run org.jruby.Main" do
         
     | 
| 
      
 7 
     | 
    
         
            +
                jruby_launcher_args("").last.should == "org/jruby/Main"
         
     | 
| 
      
 8 
     | 
    
         
            +
              end
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
              it "should pass unrecognized arguments to JRuby" do
         
     | 
| 
      
 11 
     | 
    
         
            +
                jruby_launcher_args("-J-Dsome.option -v --help")[-3..-1].should == ["org/jruby/Main", "-v", "--help"]
         
     | 
| 
      
 12 
     | 
    
         
            +
              end
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
              it "should print help message" do
         
     | 
| 
      
 15 
     | 
    
         
            +
                args = jruby_launcher_args("-Xhelp 2>&1")
         
     | 
| 
      
 16 
     | 
    
         
            +
                args.select {|l| l =~ /JRuby Launcher usage/}.should_not be_empty
         
     | 
| 
      
 17 
     | 
    
         
            +
                args.should include("-X")
         
     | 
| 
      
 18 
     | 
    
         
            +
                args = jruby_launcher_args("-X 2>&1")
         
     | 
| 
      
 19 
     | 
    
         
            +
                args.detect {|l| l =~ /JRuby Launcher usage/}.should_not be_empty
         
     | 
| 
      
 20 
     | 
    
         
            +
                args.should include("-X")
         
     | 
| 
      
 21 
     | 
    
         
            +
              end
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
              it "should use $JAVACMD when JAVACMD is specified" do
         
     | 
| 
      
 24 
     | 
    
         
            +
                javacmd_path = File.join("path", "to", "jato")
         
     | 
| 
      
 25 
     | 
    
         
            +
                with_environment "JAVACMD" => javacmd_path do
         
     | 
| 
      
 26 
     | 
    
         
            +
                  if windows?
         
     | 
| 
      
 27 
     | 
    
         
            +
                    jruby_launcher_args("-v 2>&1").join.should =~ /#{javacmd_path}/
         
     | 
| 
      
 28 
     | 
    
         
            +
                  else
         
     | 
| 
      
 29 
     | 
    
         
            +
                    jruby_launcher_args("-v").first.should == javacmd_path
         
     | 
| 
      
 30 
     | 
    
         
            +
                  end
         
     | 
| 
      
 31 
     | 
    
         
            +
                end
         
     | 
| 
      
 32 
     | 
    
         
            +
              end
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
              it "should use $JAVA_HOME/bin/java when JAVA_HOME is specified" do
         
     | 
| 
      
 35 
     | 
    
         
            +
                with_environment "JAVA_HOME" => File.join("some", "java", "home") do
         
     | 
| 
      
 36 
     | 
    
         
            +
                  if windows?
         
     | 
| 
      
 37 
     | 
    
         
            +
                    jruby_launcher_args("-v 2>&1").join.should =~ %r{some/java/home}
         
     | 
| 
      
 38 
     | 
    
         
            +
                  else
         
     | 
| 
      
 39 
     | 
    
         
            +
                    jruby_launcher_args("-v").first.should == File.join("some", "java", "home", "bin", "java")
         
     | 
| 
      
 40 
     | 
    
         
            +
                  end
         
     | 
| 
      
 41 
     | 
    
         
            +
                end
         
     | 
| 
      
 42 
     | 
    
         
            +
              end
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
              it "should use -Xjdkhome argument above JAVA_HOME" do
         
     | 
| 
      
 45 
     | 
    
         
            +
                with_environment "JAVA_HOME" => File.join("env", "java", "home") do
         
     | 
| 
      
 46 
     | 
    
         
            +
                  if windows?
         
     | 
| 
      
 47 
     | 
    
         
            +
                    jruby_launcher_args("-Xjdkhome some/java/home 2>&1").join.should =~ %r{some/java/home}
         
     | 
| 
      
 48 
     | 
    
         
            +
                  else
         
     | 
| 
      
 49 
     | 
    
         
            +
                    jruby_launcher_args("-Xjdkhome some/java/home").first.should == File.join("some", "java", "home", "bin", "java")
         
     | 
| 
      
 50 
     | 
    
         
            +
                  end
         
     | 
| 
      
 51 
     | 
    
         
            +
                end
         
     | 
| 
      
 52 
     | 
    
         
            +
              end
         
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
      
 54 
     | 
    
         
            +
              it "should drop the backslashes at the end of JAVA_HOME" do
         
     | 
| 
      
 55 
     | 
    
         
            +
                with_environment "JAVA_HOME" => File.join("some", "java", "home\\\\") do
         
     | 
| 
      
 56 
     | 
    
         
            +
                  if windows?
         
     | 
| 
      
 57 
     | 
    
         
            +
                    jruby_launcher_args("").join.should =~ %r{some/java/home}
         
     | 
| 
      
 58 
     | 
    
         
            +
                  else
         
     | 
| 
      
 59 
     | 
    
         
            +
                    jruby_launcher_args("").first.should == File.join("some", "java", "home", "bin", "java")
         
     | 
| 
      
 60 
     | 
    
         
            +
                  end
         
     | 
| 
      
 61 
     | 
    
         
            +
                end
         
     | 
| 
      
 62 
     | 
    
         
            +
              end
         
     | 
| 
      
 63 
     | 
    
         
            +
             
     | 
| 
      
 64 
     | 
    
         
            +
              it "should complain about a missing log argument" do
         
     | 
| 
      
 65 
     | 
    
         
            +
                jruby_launcher("-Xtrace 2>&1").should =~ /Argument is missing for "-Xtrace"/
         
     | 
| 
      
 66 
     | 
    
         
            +
                jruby_launcher("-Xtrace -- 2>&1").should =~ /Argument is missing for "-Xtrace"/
         
     | 
| 
      
 67 
     | 
    
         
            +
              end
         
     | 
| 
      
 68 
     | 
    
         
            +
             
     | 
| 
      
 69 
     | 
    
         
            +
              it "should complain about a missing jdkhome argument" do
         
     | 
| 
      
 70 
     | 
    
         
            +
                jruby_launcher("-Xjdkhome 2>&1").should =~ /Argument is missing/
         
     | 
| 
      
 71 
     | 
    
         
            +
                jruby_launcher("-Xjdkhome -- 2>&1").should =~ /Argument is missing/
         
     | 
| 
      
 72 
     | 
    
         
            +
              end
         
     | 
| 
      
 73 
     | 
    
         
            +
             
     | 
| 
      
 74 
     | 
    
         
            +
              it "should complain about a missing classpath append argument" do
         
     | 
| 
      
 75 
     | 
    
         
            +
                jruby_launcher("-Xcp:a 2>&1").should =~ /Argument is missing/
         
     | 
| 
      
 76 
     | 
    
         
            +
                jruby_launcher("-Xcp:a -- 2>&1").should =~ /Argument is missing/
         
     | 
| 
      
 77 
     | 
    
         
            +
              end
         
     | 
| 
      
 78 
     | 
    
         
            +
             
     | 
| 
      
 79 
     | 
    
         
            +
              it "should run nailgun server with --ng-server option" do
         
     | 
| 
      
 80 
     | 
    
         
            +
                jruby_launcher_args("--ng-server").last.should == "com/martiansoftware/nailgun/NGServer"
         
     | 
| 
      
 81 
     | 
    
         
            +
              end
         
     | 
| 
      
 82 
     | 
    
         
            +
             
     | 
| 
      
 83 
     | 
    
         
            +
              it "should run nailgun client with --ng option" do
         
     | 
| 
      
 84 
     | 
    
         
            +
                jruby_launcher_args('--ng -e "puts 1"').should == ["org.jruby.util.NailMain", "-e", "puts 1"]
         
     | 
| 
      
 85 
     | 
    
         
            +
              end
         
     | 
| 
      
 86 
     | 
    
         
            +
             
     | 
| 
      
 87 
     | 
    
         
            +
              it "should handle -J JVM options" do
         
     | 
| 
      
 88 
     | 
    
         
            +
                jruby_launcher_args("-J-Darg1=value1 -J-Darg2=value2").should include("-Darg1=value1", "-Darg2=value2")
         
     | 
| 
      
 89 
     | 
    
         
            +
              end
         
     | 
| 
      
 90 
     | 
    
         
            +
             
     | 
| 
      
 91 
     | 
    
         
            +
              it "should pass -Xprop.erty=value as -J-Djruby.prop.erty=value" do
         
     | 
| 
      
 92 
     | 
    
         
            +
                jruby_launcher_args("-Xprop.erty=value").should include("-Djruby.prop.erty=value")
         
     | 
| 
      
 93 
     | 
    
         
            +
              end
         
     | 
| 
      
 94 
     | 
    
         
            +
             
     | 
| 
      
 95 
     | 
    
         
            +
              it "should pass -Xproperties as --properties" do
         
     | 
| 
      
 96 
     | 
    
         
            +
                jruby_launcher_args("-Xproperties").should include("--properties")
         
     | 
| 
      
 97 
     | 
    
         
            +
              end
         
     | 
| 
      
 98 
     | 
    
         
            +
             
     | 
| 
      
 99 
     | 
    
         
            +
              it "should allow max heap to be overridden" do
         
     | 
| 
      
 100 
     | 
    
         
            +
                jruby_launcher_args("-J-Xmx256m").should include("-Xmx256m")
         
     | 
| 
      
 101 
     | 
    
         
            +
              end
         
     | 
| 
      
 102 
     | 
    
         
            +
             
     | 
| 
      
 103 
     | 
    
         
            +
              it "should default to 2048k max stack" do
         
     | 
| 
      
 104 
     | 
    
         
            +
                jruby_launcher_args("").should include("-Xss2048k")
         
     | 
| 
      
 105 
     | 
    
         
            +
              end
         
     | 
| 
      
 106 
     | 
    
         
            +
             
     | 
| 
      
 107 
     | 
    
         
            +
              it "should allow max stack to be overridden" do
         
     | 
| 
      
 108 
     | 
    
         
            +
                jruby_launcher_args("-J-Xss512k").should include("-Xss512k")
         
     | 
| 
      
 109 
     | 
    
         
            +
              end
         
     | 
| 
      
 110 
     | 
    
         
            +
             
     | 
| 
      
 111 
     | 
    
         
            +
              it "should add the contents of the CLASSPATH environment variable" do
         
     | 
| 
      
 112 
     | 
    
         
            +
                with_environment "CLASSPATH" => "some.jar" do
         
     | 
| 
      
 113 
     | 
    
         
            +
                  classpath_arg(jruby_launcher_args("")).should =~ /some.jar/
         
     | 
| 
      
 114 
     | 
    
         
            +
                end
         
     | 
| 
      
 115 
     | 
    
         
            +
              end
         
     | 
| 
      
 116 
     | 
    
         
            +
             
     | 
| 
      
 117 
     | 
    
         
            +
              it "should add the classpath elements in proper order" do
         
     | 
| 
      
 118 
     | 
    
         
            +
                s = File::PATH_SEPARATOR
         
     | 
| 
      
 119 
     | 
    
         
            +
                with_environment "CLASSPATH" => "some-env.jar" do
         
     | 
| 
      
 120 
     | 
    
         
            +
                  args = jruby_launcher_args("-Xcp:a some-other.jar -Xcp:p some.jar")
         
     | 
| 
      
 121 
     | 
    
         
            +
                  classpath_arg(args).should =~ /some.jar.*#{s}some-env.jar#{s}some-other.jar/
         
     | 
| 
      
 122 
     | 
    
         
            +
                end
         
     | 
| 
      
 123 
     | 
    
         
            +
              end
         
     | 
| 
      
 124 
     | 
    
         
            +
             
     | 
| 
      
 125 
     | 
    
         
            +
              it "should use the --server compiler" do
         
     | 
| 
      
 126 
     | 
    
         
            +
                jruby_launcher_args("--server").should include("-server")
         
     | 
| 
      
 127 
     | 
    
         
            +
              end
         
     | 
| 
      
 128 
     | 
    
         
            +
             
     | 
| 
      
 129 
     | 
    
         
            +
              it "should use the --client compiler" do
         
     | 
| 
      
 130 
     | 
    
         
            +
                jruby_launcher_args("--client").should include("-client")
         
     | 
| 
      
 131 
     | 
    
         
            +
              end
         
     | 
| 
      
 132 
     | 
    
         
            +
             
     | 
| 
      
 133 
     | 
    
         
            +
              it "should set the JMX settings when --manage is present" do
         
     | 
| 
      
 134 
     | 
    
         
            +
                jruby_launcher_args("--manage").should include("-Dcom.sun.management.jmxremote", "-Djruby.management.enabled=true")
         
     | 
| 
      
 135 
     | 
    
         
            +
              end
         
     | 
| 
      
 136 
     | 
    
         
            +
             
     | 
| 
      
 137 
     | 
    
         
            +
              it "should set the headless flag when --headless is present" do
         
     | 
| 
      
 138 
     | 
    
         
            +
                jruby_launcher_args("--headless").should include("-Djava.awt.headless=true")
         
     | 
| 
      
 139 
     | 
    
         
            +
              end
         
     | 
| 
      
 140 
     | 
    
         
            +
             
     | 
| 
      
 141 
     | 
    
         
            +
              it "should pass -Xprof when --sample is present" do
         
     | 
| 
      
 142 
     | 
    
         
            +
                jruby_launcher_args("--sample").should include("-Xprof")
         
     | 
| 
      
 143 
     | 
    
         
            +
              end
         
     | 
| 
      
 144 
     | 
    
         
            +
             
     | 
| 
      
 145 
     | 
    
         
            +
              it "should stop argument processing when a -- is seen" do
         
     | 
| 
      
 146 
     | 
    
         
            +
                jruby_launcher_args("-- -Xhelp -Xtrace --headless").should include("-Xhelp", "-Xtrace", "--headless")
         
     | 
| 
      
 147 
     | 
    
         
            +
              end
         
     | 
| 
      
 148 
     | 
    
         
            +
             
     | 
| 
      
 149 
     | 
    
         
            +
              # JRUBY-4151
         
     | 
| 
      
 150 
     | 
    
         
            +
              it "should properly handle single quotes" do
         
     | 
| 
      
 151 
     | 
    
         
            +
                jruby_launcher_args("-e 'ABC DEF'").should include("ABC DEF")
         
     | 
| 
      
 152 
     | 
    
         
            +
              end
         
     | 
| 
      
 153 
     | 
    
         
            +
             
     | 
| 
      
 154 
     | 
    
         
            +
              # JRUBY-4581
         
     | 
| 
      
 155 
     | 
    
         
            +
              it "should prepend JRUBY_OPTS to the start of the argument list to process" do
         
     | 
| 
      
 156 
     | 
    
         
            +
                with_environment "JRUBY_OPTS" => "--server -J-Dsome.key=val -rubygems" do
         
     | 
| 
      
 157 
     | 
    
         
            +
                  jruby_launcher_args("-e 'ABC DEF'").should include("-server", "-Dsome.key=val", "-rubygems", "-e", "ABC DEF")
         
     | 
| 
      
 158 
     | 
    
         
            +
                end
         
     | 
| 
      
 159 
     | 
    
         
            +
              end
         
     | 
| 
      
 160 
     | 
    
         
            +
             
     | 
| 
      
 161 
     | 
    
         
            +
              # JRUBY-4611
         
     | 
| 
      
 162 
     | 
    
         
            +
              it "stops argument processing on first non-option argument" do
         
     | 
| 
      
 163 
     | 
    
         
            +
                jruby_launcher_args("foo.rb --sample")[-2..-1].should == ["foo.rb", "--sample"]
         
     | 
| 
      
 164 
     | 
    
         
            +
              end
         
     | 
| 
      
 165 
     | 
    
         
            +
             
     | 
| 
      
 166 
     | 
    
         
            +
              # JRUBY-4608
         
     | 
| 
      
 167 
     | 
    
         
            +
              if RbConfig::CONFIG['target_os'] =~ /darwin/i
         
     | 
| 
      
 168 
     | 
    
         
            +
                it "includes file.encoding=UTF-8 on Mac if JAVA_ENCODING is not set" do
         
     | 
| 
      
 169 
     | 
    
         
            +
                  jruby_launcher_args("-e true").should include("-Dfile.encoding=UTF-8")
         
     | 
| 
      
 170 
     | 
    
         
            +
                  with_environment "JAVA_ENCODING" => "MacRoman" do
         
     | 
| 
      
 171 
     | 
    
         
            +
                    jruby_launcher_args("-e true").should_not include("-Dfile.encoding=UTF-8")
         
     | 
| 
      
 172 
     | 
    
         
            +
                  end
         
     | 
| 
      
 173 
     | 
    
         
            +
                end
         
     | 
| 
      
 174 
     | 
    
         
            +
              end
         
     | 
| 
      
 175 
     | 
    
         
            +
             
     | 
| 
      
 176 
     | 
    
         
            +
              it "does not crash on empty args" do
         
     | 
| 
      
 177 
     | 
    
         
            +
                jruby_launcher_args("-e ''").should include("-e")
         
     | 
| 
      
 178 
     | 
    
         
            +
                jruby_launcher("-Xtrace '' 2>&1").should =~ /-Xtrace/
         
     | 
| 
      
 179 
     | 
    
         
            +
                jruby_launcher("-Xjdkhome '' 2>&1").should =~ /-Xjdkhome/
         
     | 
| 
      
 180 
     | 
    
         
            +
              end
         
     | 
| 
      
 181 
     | 
    
         
            +
             
     | 
| 
      
 182 
     | 
    
         
            +
              # JRUBY-4706
         
     | 
| 
      
 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 
     | 
    
         
            +
             
     | 
| 
      
 187 
     | 
    
         
            +
                args = jruby_launcher_args("-e true")
         
     | 
| 
      
 188 
     | 
    
         
            +
                args.grep(/Xbootclasspath/).should_not be_empty
         
     | 
| 
      
 189 
     | 
    
         
            +
                args = jruby_launcher_args("-Xnobootclasspath -e true")
         
     | 
| 
      
 190 
     | 
    
         
            +
                args.grep(/Xbootclasspath/).should be_empty
         
     | 
| 
      
 191 
     | 
    
         
            +
              end
         
     | 
| 
      
 192 
     | 
    
         
            +
             
     | 
| 
      
 193 
     | 
    
         
            +
              it "should put JRuby on regular classpath when VERIFY_JRUBY is set" do
         
     | 
| 
      
 194 
     | 
    
         
            +
                with_environment "VERIFY_JRUBY" => "true" do
         
     | 
| 
      
 195 
     | 
    
         
            +
                  args = jruby_launcher_args("-e true")
         
     | 
| 
      
 196 
     | 
    
         
            +
                  args.grep(/Xbootclasspath/).should be_empty
         
     | 
| 
      
 197 
     | 
    
         
            +
                end
         
     | 
| 
      
 198 
     | 
    
         
            +
              end
         
     | 
| 
      
 199 
     | 
    
         
            +
             
     | 
| 
      
 200 
     | 
    
         
            +
              # JRUBY-4709
         
     | 
| 
      
 201 
     | 
    
         
            +
              it "should include a bare : or ; at the end of the classpath, to include PWD in the path" do
         
     | 
| 
      
 202 
     | 
    
         
            +
                classpath_arg(jruby_launcher_args("-Xnobootclasspath -e true")).should =~
         
     | 
| 
      
 203 
     | 
    
         
            +
                  if windows?
         
     | 
| 
      
 204 
     | 
    
         
            +
                    /;$/
         
     | 
| 
      
 205 
     | 
    
         
            +
                  else
         
     | 
| 
      
 206 
     | 
    
         
            +
                    /:$/
         
     | 
| 
      
 207 
     | 
    
         
            +
                  end
         
     | 
| 
      
 208 
     | 
    
         
            +
              end
         
     | 
| 
      
 209 
     | 
    
         
            +
             
     | 
| 
      
 210 
     | 
    
         
            +
              # JRUBY-6016
         
     | 
| 
      
 211 
     | 
    
         
            +
              it "should honor JAVA_MEM" do
         
     | 
| 
      
 212 
     | 
    
         
            +
                with_environment "JAVA_MEM" => "-Xmx768m" do
         
     | 
| 
      
 213 
     | 
    
         
            +
                  jruby_launcher_args("").should include("-Xmx768m")
         
     | 
| 
      
 214 
     | 
    
         
            +
                end
         
     | 
| 
      
 215 
     | 
    
         
            +
              end
         
     | 
| 
      
 216 
     | 
    
         
            +
             
     | 
| 
      
 217 
     | 
    
         
            +
              it "should honor JAVA_STACK" do
         
     | 
| 
      
 218 
     | 
    
         
            +
                with_environment "JAVA_STACK" => "-Xss3072k" do
         
     | 
| 
      
 219 
     | 
    
         
            +
                  jruby_launcher_args("").should include("-Xss3072k")
         
     | 
| 
      
 220 
     | 
    
         
            +
                end
         
     | 
| 
      
 221 
     | 
    
         
            +
              end
         
     | 
| 
      
 222 
     | 
    
         
            +
             
     | 
| 
      
 223 
     | 
    
         
            +
              it "should honor JRUBY_HOME" do
         
     | 
| 
      
 224 
     | 
    
         
            +
                with_environment "JRUBY_HOME" => "/tmp" do
         
     | 
| 
      
 225 
     | 
    
         
            +
                  jruby_launcher_args("").should include("-Djruby.home=/tmp")
         
     | 
| 
      
 226 
     | 
    
         
            +
                end
         
     | 
| 
      
 227 
     | 
    
         
            +
              end
         
     | 
| 
      
 228 
     | 
    
         
            +
             
     | 
| 
      
 229 
     | 
    
         
            +
              context "JRUBY_HOME set and JRUBY_HOME/lib/jruby.jar exists" do
         
     | 
| 
      
 230 
     | 
    
         
            +
                let(:jruby_home) do
         
     | 
| 
      
 231 
     | 
    
         
            +
                  require 'tempfile'
         
     | 
| 
      
 232 
     | 
    
         
            +
                  t = Tempfile.new("jruby_home")
         
     | 
| 
      
 233 
     | 
    
         
            +
                  t.path.tap { t.close! }
         
     | 
| 
      
 234 
     | 
    
         
            +
                end
         
     | 
| 
      
 235 
     | 
    
         
            +
             
     | 
| 
      
 236 
     | 
    
         
            +
                before do
         
     | 
| 
      
 237 
     | 
    
         
            +
                  FileUtils.mkdir_p(File.join(jruby_home, "lib"))
         
     | 
| 
      
 238 
     | 
    
         
            +
                  FileUtils.touch(File.join(jruby_home, "lib", "jruby.jar"))
         
     | 
| 
      
 239 
     | 
    
         
            +
                end
         
     | 
| 
      
 240 
     | 
    
         
            +
                after { FileUtils.rm_rf jruby_home }
         
     | 
| 
      
 241 
     | 
    
         
            +
             
     | 
| 
      
 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 
     | 
    
         
            +
             
     | 
| 
      
 246 
     | 
    
         
            +
                  with_environment "JRUBY_HOME" => jruby_home do
         
     | 
| 
      
 247 
     | 
    
         
            +
                    jruby_launcher_args("").should include("-Xbootclasspath/a:#{jruby_home}/lib/jruby.jar")
         
     | 
| 
      
 248 
     | 
    
         
            +
                  end
         
     | 
| 
      
 249 
     | 
    
         
            +
                end
         
     | 
| 
      
 250 
     | 
    
         
            +
              end
         
     | 
| 
      
 251 
     | 
    
         
            +
             
     | 
| 
      
 252 
     | 
    
         
            +
              it "should place user-supplied options after default options" do
         
     | 
| 
      
 253 
     | 
    
         
            +
                args = jruby_launcher_args("-J-Djruby.home=/tmp")
         
     | 
| 
      
 254 
     | 
    
         
            +
                home_args = args.select {|x| x =~ /^-Djruby\.home/ }
         
     | 
| 
      
 255 
     | 
    
         
            +
                home_args.length.should == 2
         
     | 
| 
      
 256 
     | 
    
         
            +
                home_args.last.should == "-Djruby.home=/tmp"
         
     | 
| 
      
 257 
     | 
    
         
            +
              end
         
     | 
| 
      
 258 
     | 
    
         
            +
             
     | 
| 
      
 259 
     | 
    
         
            +
              it "should print the version" do
         
     | 
| 
      
 260 
     | 
    
         
            +
                jruby_launcher("-Xversion 2>&1").should =~ /Launcher Version #{JRubyLauncher::VERSION}/
         
     | 
| 
      
 261 
     | 
    
         
            +
              end
         
     | 
| 
      
 262 
     | 
    
         
            +
             
     | 
| 
      
 263 
     | 
    
         
            +
              it "should not crash on format-strings" do
         
     | 
| 
      
 264 
     | 
    
         
            +
                jruby_launcher_args("-e %s%s%s%s%s 2>&1").should include('-e', '%s%s%s%s%s')
         
     | 
| 
      
 265 
     | 
    
         
            +
              end
         
     | 
| 
      
 266 
     | 
    
         
            +
             
     | 
| 
      
 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 
     | 
    
         
            +
                
         
     | 
| 
      
 271 
     | 
    
         
            +
                Dir.mktmpdir do |java_home|
         
     | 
| 
      
 272 
     | 
    
         
            +
                  FileUtils.mkdir_p(File.join(java_home, 'lib/modules'))
         
     | 
| 
      
 273 
     | 
    
         
            +
                  with_environment 'JAVA_HOME' => java_home do
         
     | 
| 
      
 274 
     | 
    
         
            +
                    jruby_launcher_args('').grep(/^--module-path=.*jruby.jar/).should_not be_empty
         
     | 
| 
      
 275 
     | 
    
         
            +
                  end
         
     | 
| 
      
 276 
     | 
    
         
            +
                end
         
     | 
| 
      
 277 
     | 
    
         
            +
              end
         
     | 
| 
      
 278 
     | 
    
         
            +
             
     | 
| 
      
 279 
     | 
    
         
            +
              it "should not treat CLASSPATH entries as modules on java9+" do
         
     | 
| 
      
 280 
     | 
    
         
            +
                Dir.mktmpdir do |java_home|
         
     | 
| 
      
 281 
     | 
    
         
            +
                  Dir.mkdir(File.join(java_home, 'jmods'))
         
     | 
| 
      
 282 
     | 
    
         
            +
                  with_environment 'JAVA_HOME' => java_home, 'CLASSPATH' => '/some/lib.jar' do
         
     | 
| 
      
 283 
     | 
    
         
            +
                    jruby_launcher_args('').grep(/^--module-path=.*\/some\/lib.jar/).should be_empty
         
     | 
| 
      
 284 
     | 
    
         
            +
                    classpath_arg(jruby_launcher_args('')).should =~ /\/some\/lib.jar/
         
     | 
| 
      
 285 
     | 
    
         
            +
                  end
         
     | 
| 
      
 286 
     | 
    
         
            +
                end
         
     | 
| 
      
 287 
     | 
    
         
            +
              end
         
     | 
| 
      
 288 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,76 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'rspec'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'rbconfig'
         
     | 
| 
      
 3 
     | 
    
         
            +
            require 'fileutils'
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            module JRubyLauncherHelper
         
     | 
| 
      
 6 
     | 
    
         
            +
              JRUBY_EXE = ''
         
     | 
| 
      
 7 
     | 
    
         
            +
              WINDOWS = RbConfig::CONFIG['target_os'] =~ /mswin/
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
              def self.check_executable_built
         
     | 
| 
      
 10 
     | 
    
         
            +
                exe = File.expand_path("../../jruby", __FILE__) + RbConfig::CONFIG['EXEEXT']
         
     | 
| 
      
 11 
     | 
    
         
            +
                unless File.executable?(exe)
         
     | 
| 
      
 12 
     | 
    
         
            +
                  raise "Error: launcher executable not built; type `make' before continuing."
         
     | 
| 
      
 13 
     | 
    
         
            +
                end
         
     | 
| 
      
 14 
     | 
    
         
            +
                top = File.dirname(exe)
         
     | 
| 
      
 15 
     | 
    
         
            +
                name = File.basename(exe)
         
     | 
| 
      
 16 
     | 
    
         
            +
                home = File.join(top, "build/home")
         
     | 
| 
      
 17 
     | 
    
         
            +
                FileUtils.mkdir_p(File.join(home, "bin"))
         
     | 
| 
      
 18 
     | 
    
         
            +
                FileUtils.cp(exe, File.join(home, "bin"))
         
     | 
| 
      
 19 
     | 
    
         
            +
                if JRubyLauncherHelper::WINDOWS
         
     | 
| 
      
 20 
     | 
    
         
            +
                  FileUtils.cp(exe.sub(/exe/, 'dll'), File.join(home, "bin"))
         
     | 
| 
      
 21 
     | 
    
         
            +
                end
         
     | 
| 
      
 22 
     | 
    
         
            +
                FileUtils.mkdir_p(File.join(home, "lib"))
         
     | 
| 
      
 23 
     | 
    
         
            +
                FileUtils.touch(File.join(home, "lib/jruby.jar"))
         
     | 
| 
      
 24 
     | 
    
         
            +
                JRUBY_EXE.concat File.join(home, "bin", name)
         
     | 
| 
      
 25 
     | 
    
         
            +
              end
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
              def jruby_launcher(args)
         
     | 
| 
      
 28 
     | 
    
         
            +
                `#{JRUBY_EXE} #{args}`
         
     | 
| 
      
 29 
     | 
    
         
            +
              end
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
              def jruby_launcher_args(args)
         
     | 
| 
      
 32 
     | 
    
         
            +
                jruby_launcher("-Xcommand #{args}").split("\n")
         
     | 
| 
      
 33 
     | 
    
         
            +
              end
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
              def last_exit_code
         
     | 
| 
      
 36 
     | 
    
         
            +
                $?.exitstatus
         
     | 
| 
      
 37 
     | 
    
         
            +
              end
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
              def windows?
         
     | 
| 
      
 40 
     | 
    
         
            +
                WINDOWS
         
     | 
| 
      
 41 
     | 
    
         
            +
              end
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
              def classpath_arg(args)
         
     | 
| 
      
 44 
     | 
    
         
            +
                index = args.index("-cp")
         
     | 
| 
      
 45 
     | 
    
         
            +
                index.should > 0
         
     | 
| 
      
 46 
     | 
    
         
            +
                args[index + 1]
         
     | 
| 
      
 47 
     | 
    
         
            +
              end
         
     | 
| 
      
 48 
     | 
    
         
            +
             
     | 
| 
      
 49 
     | 
    
         
            +
              def with_environment(pairs = {})
         
     | 
| 
      
 50 
     | 
    
         
            +
                prev_env = {}
         
     | 
| 
      
 51 
     | 
    
         
            +
                pairs.each_pair do |k,v|
         
     | 
| 
      
 52 
     | 
    
         
            +
                  prev_env[k] = ENV[k] if ENV.has_key?(k)
         
     | 
| 
      
 53 
     | 
    
         
            +
                  ENV[k] = v
         
     | 
| 
      
 54 
     | 
    
         
            +
                end
         
     | 
| 
      
 55 
     | 
    
         
            +
                begin
         
     | 
| 
      
 56 
     | 
    
         
            +
                  yield
         
     | 
| 
      
 57 
     | 
    
         
            +
                ensure
         
     | 
| 
      
 58 
     | 
    
         
            +
                  pairs.keys.each {|k| ENV.delete(k)}
         
     | 
| 
      
 59 
     | 
    
         
            +
                  ENV.update(prev_env)
         
     | 
| 
      
 60 
     | 
    
         
            +
                end
         
     | 
| 
      
 61 
     | 
    
         
            +
              end
         
     | 
| 
      
 62 
     | 
    
         
            +
            end
         
     | 
| 
      
 63 
     | 
    
         
            +
             
     | 
| 
      
 64 
     | 
    
         
            +
            RSpec.configure do |config|
         
     | 
| 
      
 65 
     | 
    
         
            +
              config.before(:all) do
         
     | 
| 
      
 66 
     | 
    
         
            +
                JRubyLauncherHelper.check_executable_built
         
     | 
| 
      
 67 
     | 
    
         
            +
                # clear environment for better control
         
     | 
| 
      
 68 
     | 
    
         
            +
                ENV.delete("JAVA_HOME")
         
     | 
| 
      
 69 
     | 
    
         
            +
                ENV.delete("JRUBY_HOME")
         
     | 
| 
      
 70 
     | 
    
         
            +
                ENV.delete("JAVA_OPTS")
         
     | 
| 
      
 71 
     | 
    
         
            +
                ENV.delete("JRUBY_OPTS")
         
     | 
| 
      
 72 
     | 
    
         
            +
                ENV.delete("CLASSPATH")
         
     | 
| 
      
 73 
     | 
    
         
            +
                ENV.delete("JAVA_ENCODING")
         
     | 
| 
      
 74 
     | 
    
         
            +
              end
         
     | 
| 
      
 75 
     | 
    
         
            +
              config.include(JRubyLauncherHelper)
         
     | 
| 
      
 76 
     | 
    
         
            +
            end
         
     | 
    
        data/unixlauncher.cpp
    CHANGED
    
    | 
         @@ -1,3 +1,4 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            #include <stdio.h>
         
     | 
| 
       1 
2 
     | 
    
         
             
            #include <stdlib.h>
         
     | 
| 
       2 
3 
     | 
    
         
             
            #include <unistd.h>
         
     | 
| 
       3 
4 
     | 
    
         
             
            #include <limits.h>
         
     | 
| 
         @@ -71,19 +72,20 @@ int UnixLauncher::run(int argc, char* argv[], char* envp[]) { 
     | 
|
| 
       71 
72 
     | 
    
         | 
| 
       72 
73 
     | 
    
         
             
                // still no jdk home, use other means to resolve it
         
     | 
| 
       73 
74 
     | 
    
         
             
                if (jdkhome.empty()) {
         
     | 
| 
       74 
     | 
    
         
            -
                     
     | 
| 
      
 75 
     | 
    
         
            +
                    char javaHomeCommand[] = "/usr/libexec/java_home";
         
     | 
| 
      
 76 
     | 
    
         
            +
                    if (access(javaHomeCommand, R_OK | X_OK) != -1 && !checkDirectory(javaHomeCommand)) {
         
     | 
| 
       75 
77 
     | 
    
         
             
                        // try java_home command when not set (on MacOS)
         
     | 
| 
       76 
78 
     | 
    
         
             
                        FILE *fp;
         
     | 
| 
       77 
79 
     | 
    
         
             
                        char tmp[PATH_MAX + 1];
         
     | 
| 
       78 
80 
     | 
    
         | 
| 
       79 
     | 
    
         
            -
                        fp = popen( 
     | 
| 
      
 81 
     | 
    
         
            +
                        fp = popen(javaHomeCommand, "r");
         
     | 
| 
       80 
82 
     | 
    
         
             
                        if (fp != NULL) {
         
     | 
| 
       81 
83 
     | 
    
         
             
                            fgets(tmp, sizeof(tmp), fp);
         
     | 
| 
       82 
84 
     | 
    
         
             
                            tmp[strcspn(tmp, "\n")] = 0;
         
     | 
| 
       83 
85 
     | 
    
         
             
                            jdkhome = tmp;
         
     | 
| 
       84 
86 
     | 
    
         
             
                            pclose(fp);
         
     | 
| 
       85 
87 
     | 
    
         
             
                        } else {
         
     | 
| 
       86 
     | 
    
         
            -
                            logErr(true, false, "failed to run  
     | 
| 
      
 88 
     | 
    
         
            +
                            logErr(true, false, "failed to run %s", javaHomeCommand);
         
     | 
| 
       87 
89 
     | 
    
         
             
                        }
         
     | 
| 
       88 
90 
     | 
    
         
             
                    } else {
         
     | 
| 
       89 
91 
     | 
    
         
             
                        java = resolveSymlinks(java);
         
     | 
    
        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.19
         
     | 
| 
       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: 2021- 
     | 
| 
      
 12 
     | 
    
         
            +
            date: 2021-07-08 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:
         
     | 
| 
         @@ -44,6 +44,16 @@ files: 
     | 
|
| 
       44 
44 
     | 
    
         
             
            - pkg/jruby-launcher-1.1.17-java/lib/rubygems/defaults/jruby_native.rb
         
     | 
| 
       45 
45 
     | 
    
         
             
            - pkg/jruby-launcher-1.1.17-java/spec/launcher_spec.rb
         
     | 
| 
       46 
46 
     | 
    
         
             
            - pkg/jruby-launcher-1.1.17-java/spec/spec_helper.rb
         
     | 
| 
      
 47 
     | 
    
         
            +
            - pkg/jruby-launcher-1.1.18-java/extconf.rb
         
     | 
| 
      
 48 
     | 
    
         
            +
            - pkg/jruby-launcher-1.1.18-java/lib/jruby-launcher.rb
         
     | 
| 
      
 49 
     | 
    
         
            +
            - pkg/jruby-launcher-1.1.18-java/lib/rubygems/defaults/jruby_native.rb
         
     | 
| 
      
 50 
     | 
    
         
            +
            - pkg/jruby-launcher-1.1.18-java/pkg/jruby-launcher-1.1.17-java/extconf.rb
         
     | 
| 
      
 51 
     | 
    
         
            +
            - pkg/jruby-launcher-1.1.18-java/pkg/jruby-launcher-1.1.17-java/lib/jruby-launcher.rb
         
     | 
| 
      
 52 
     | 
    
         
            +
            - pkg/jruby-launcher-1.1.18-java/pkg/jruby-launcher-1.1.17-java/lib/rubygems/defaults/jruby_native.rb
         
     | 
| 
      
 53 
     | 
    
         
            +
            - pkg/jruby-launcher-1.1.18-java/pkg/jruby-launcher-1.1.17-java/spec/launcher_spec.rb
         
     | 
| 
      
 54 
     | 
    
         
            +
            - pkg/jruby-launcher-1.1.18-java/pkg/jruby-launcher-1.1.17-java/spec/spec_helper.rb
         
     | 
| 
      
 55 
     | 
    
         
            +
            - pkg/jruby-launcher-1.1.18-java/spec/launcher_spec.rb
         
     | 
| 
      
 56 
     | 
    
         
            +
            - pkg/jruby-launcher-1.1.18-java/spec/spec_helper.rb
         
     | 
| 
       47 
57 
     | 
    
         
             
            - platformlauncher.cpp
         
     | 
| 
       48 
58 
     | 
    
         
             
            - platformlauncher.h
         
     | 
| 
       49 
59 
     | 
    
         
             
            - rb_w32_cmdvector.h
         
     |