Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JVM version detection breaks on java 9 #142

Closed
ketan opened this issue Sep 26, 2017 · 1 comment
Closed

JVM version detection breaks on java 9 #142

ketan opened this issue Sep 26, 2017 · 1 comment

Comments

@ketan
Copy link
Member

ketan commented Sep 26, 2017

Note: Originally reported at jruby/jruby#4798, but moved here since it's more appropriate.

Environment

$ jruby --version
jruby 9.1.13.0 (2.3.3) 2017-09-06 8e1c115 Java HotSpot(TM) 64-Bit Server VM 9+181 on 9+181 +jit [darwin-x86_64]

$ java -version
java version "9"
Java(TM) SE Runtime Environment (build 9+181)
Java HotSpot(TM) 64-Bit Server VM (build 9+181, mixed mode)

$ java -XshowSettings 2>&1 | grep java.version
    java.version = 9

Expected Behavior

  • JRuby should be able to install a rubygem
  • bin/jruby -S gem install bundler --version 1.14.6

Actual Behavior

$ tools/jruby/bin/jruby -S gem install bundler --version 1.14.6 --backtrace --debug
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.jruby.util.io.FilenoUtil to method sun.nio.ch.SelChImpl.getFD()
WARNING: Please consider reporting this to the maintainers of org.jruby.util.io.FilenoUtil
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
NOTE:  Debugging mode prints all exceptions even when rescued
java.lang.StringIndexOutOfBoundsException: begin 0, end 3, length 1
	at java.lang.String.checkBoundsBeginEnd(java/lang/String.java:3116)
	at java.lang.String.substring(java/lang/String.java:1885)
	at org.jruby.ext.openssl.OpenSSL.javaVersion6(org/jruby/ext/openssl/OpenSSL.java:263)
	at org.jruby.ext.openssl.Random.createHolderImpl(org/jruby/ext/openssl/Random.java:61)
	at org.jruby.ext.openssl.Random.createRandom(org/jruby/ext/openssl/Random.java:277)
	at org.jruby.ext.openssl.OpenSSL.createOpenSSL(org/jruby/ext/openssl/OpenSSL.java:78)
	at org.jruby.ext.openssl.OpenSSL.load(org/jruby/ext/openssl/OpenSSL.java:53)
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(jdk/internal/reflect/NativeMethodAccessorImpl.java:62)
	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(jdk/internal/reflect/DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(java/lang/reflect/Method.java:564)
	at org.jruby.javasupport.JavaMethod.invokeDirectWithExceptionHandling(org/jruby/javasupport/JavaMethod.java:453)
	at org.jruby.javasupport.JavaMethod.invokeStaticDirect(org/jruby/javasupport/JavaMethod.java:365)
	at RUBY.<main>(/Users/ketanpadegaonkar/projects/gocd/gocd/tools/jruby/lib/ruby/stdlib/jopenssl/load.rb:26)
	at org.jruby.Ruby.runInterpreter(org/jruby/Ruby.java:840)
	at org.jruby.Ruby.loadFile(org/jruby/Ruby.java:2877)
	at org.jruby.RubyKernel.requireCommon(org/jruby/RubyKernel.java:962)
	at org.jruby.RubyKernel.require(org/jruby/RubyKernel.java:955)
	at org.jruby.RubyKernel$INVOKER$s$1$0$require19.call(org/jruby/RubyKernel$INVOKER$s$1$0$require19.gen)
	at Users.ketanpadegaonkar.projects.gocd.gocd.tools.jruby.lib.ruby.stdlib.rubygems.core_ext.kernel_require.invokeOther30:gem_original_require(Users/ketanpadegaonkar/projects/gocd/gocd/tools/jruby/lib/ruby/stdlib/rubygems/core_ext//Users/ketanpadegaonkar/projects/gocd/gocd/tools/jruby/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:59)
	at Users.ketanpadegaonkar.projects.gocd.gocd.tools.jruby.lib.ruby.stdlib.rubygems.core_ext.kernel_require.require(/Users/ketanpadegaonkar/projects/gocd/gocd/tools/jruby/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:59)
	at RUBY.<main>(/Users/ketanpadegaonkar/projects/gocd/gocd/tools/jruby/lib/ruby/stdlib/openssl.rb:1)
	at org.jruby.Ruby.runInterpreter(org/jruby/Ruby.java:840)
	at org.jruby.Ruby.loadFile(org/jruby/Ruby.java:2877)
	at org.jruby.RubyKernel.requireCommon(org/jruby/RubyKernel.java:962)
	at org.jruby.RubyKernel.require(org/jruby/RubyKernel.java:955)
	at org.jruby.RubyKernel$INVOKER$s$1$0$require19.call(org/jruby/RubyKernel$INVOKER$s$1$0$require19.gen)
	at Users.ketanpadegaonkar.projects.gocd.gocd.tools.jruby.lib.ruby.stdlib.rubygems.core_ext.kernel_require.invokeOther30:gem_original_require(Users/ketanpadegaonkar/projects/gocd/gocd/tools/jruby/lib/ruby/stdlib/rubygems/core_ext//Users/ketanpadegaonkar/projects/gocd/gocd/tools/jruby/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:59)
	at Users.ketanpadegaonkar.projects.gocd.gocd.tools.jruby.lib.ruby.stdlib.rubygems.core_ext.kernel_require.require(/Users/ketanpadegaonkar/projects/gocd/gocd/tools/jruby/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:59)
	at RUBY.<main>(/Users/ketanpadegaonkar/projects/gocd/gocd/tools/jruby/lib/ruby/stdlib/openssl.rb:1)
	at org.jruby.Ruby.runInterpreter(org/jruby/Ruby.java:840)
	at org.jruby.Ruby.loadFile(org/jruby/Ruby.java:2877)
	at org.jruby.RubyKernel.requireCommon(org/jruby/RubyKernel.java:962)
	at org.jruby.RubyKernel.require(org/jruby/RubyKernel.java:955)
	at org.jruby.RubyKernel$INVOKER$s$1$0$require19.call(org/jruby/RubyKernel$INVOKER$s$1$0$require19.gen)
	at Users.ketanpadegaonkar.projects.gocd.gocd.tools.jruby.lib.ruby.stdlib.rubygems.core_ext.kernel_require.invokeOther30:gem_original_require(Users/ketanpadegaonkar/projects/gocd/gocd/tools/jruby/lib/ruby/stdlib/rubygems/core_ext//Users/ketanpadegaonkar/projects/gocd/gocd/tools/jruby/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:59)
	at Users.ketanpadegaonkar.projects.gocd.gocd.tools.jruby.lib.ruby.stdlib.rubygems.core_ext.kernel_require.require(/Users/ketanpadegaonkar/projects/gocd/gocd/tools/jruby/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:59)
	at RUBY.<main>(/Users/ketanpadegaonkar/projects/gocd/gocd/tools/jruby/lib/ruby/stdlib/rubygems/security.rb:1)
	at org.jruby.Ruby.runInterpreter(org/jruby/Ruby.java:840)
	at org.jruby.Ruby.loadFile(org/jruby/Ruby.java:2877)
	at org.jruby.RubyKernel.requireCommon(org/jruby/RubyKernel.java:962)
	at org.jruby.RubyKernel.require(org/jruby/RubyKernel.java:955)
	at org.jruby.RubyKernel$INVOKER$s$1$0$require19.call(org/jruby/RubyKernel$INVOKER$s$1$0$require19.gen)
	at Users.ketanpadegaonkar.projects.gocd.gocd.tools.jruby.lib.ruby.stdlib.rubygems.core_ext.kernel_require.invokeOther30:gem_original_require(Users/ketanpadegaonkar/projects/gocd/gocd/tools/jruby/lib/ruby/stdlib/rubygems/core_ext//Users/ketanpadegaonkar/projects/gocd/gocd/tools/jruby/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:59)
	at Users.ketanpadegaonkar.projects.gocd.gocd.tools.jruby.lib.ruby.stdlib.rubygems.core_ext.kernel_require.require(/Users/ketanpadegaonkar/projects/gocd/gocd/tools/jruby/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:59)
	at RUBY.<main>(/Users/ketanpadegaonkar/projects/gocd/gocd/tools/jruby/lib/ruby/stdlib/rubygems/security.rb:12)
	at org.jruby.Ruby.runInterpreter(org/jruby/Ruby.java:840)
	at org.jruby.Ruby.loadFile(org/jruby/Ruby.java:2877)
	at org.jruby.RubyKernel.requireCommon(org/jruby/RubyKernel.java:962)
	at org.jruby.RubyKernel.require(org/jruby/RubyKernel.java:955)
	at org.jruby.RubyKernel$INVOKER$s$1$0$require19.call(org/jruby/RubyKernel$INVOKER$s$1$0$require19.gen)
	at Users.ketanpadegaonkar.projects.gocd.gocd.tools.jruby.lib.ruby.stdlib.rubygems.core_ext.kernel_require.invokeOther30:gem_original_require(Users/ketanpadegaonkar/projects/gocd/gocd/tools/jruby/lib/ruby/stdlib/rubygems/core_ext//Users/ketanpadegaonkar/projects/gocd/gocd/tools/jruby/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:59)
	at Users.ketanpadegaonkar.projects.gocd.gocd.tools.jruby.lib.ruby.stdlib.rubygems.core_ext.kernel_require.require(/Users/ketanpadegaonkar/projects/gocd/gocd/tools/jruby/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:59)
	at RUBY.<main>(/Users/ketanpadegaonkar/projects/gocd/gocd/tools/jruby/lib/ruby/stdlib/rubygems/package.rb:1)
	at org.jruby.Ruby.runInterpreter(org/jruby/Ruby.java:840)
	at org.jruby.Ruby.loadFile(org/jruby/Ruby.java:2877)
	at org.jruby.RubyKernel.requireCommon(org/jruby/RubyKernel.java:962)
	at org.jruby.RubyKernel.require(org/jruby/RubyKernel.java:955)
	at org.jruby.RubyKernel$INVOKER$s$1$0$require19.call(org/jruby/RubyKernel$INVOKER$s$1$0$require19.gen)
	at Users.ketanpadegaonkar.projects.gocd.gocd.tools.jruby.lib.ruby.stdlib.rubygems.core_ext.kernel_require.invokeOther30:gem_original_require(Users/ketanpadegaonkar/projects/gocd/gocd/tools/jruby/lib/ruby/stdlib/rubygems/core_ext//Users/ketanpadegaonkar/projects/gocd/gocd/tools/jruby/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:59)
	at Users.ketanpadegaonkar.projects.gocd.gocd.tools.jruby.lib.ruby.stdlib.rubygems.core_ext.kernel_require.require(/Users/ketanpadegaonkar/projects/gocd/gocd/tools/jruby/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:59)
	at RUBY.(root)(/Users/ketanpadegaonkar/projects/gocd/gocd/tools/jruby/lib/ruby/stdlib/rubygems/package.rb:44)
	at RUBY.(root)(/Users/ketanpadegaonkar/projects/gocd/gocd/tools/jruby/lib/ruby/stdlib/rubygems/dependency_installer.rb:1)
	at RUBY.(root)(/Users/ketanpadegaonkar/projects/gocd/gocd/tools/jruby/lib/ruby/stdlib/rubygems/dependency_installer.rb:4)
	at RUBY.(root)(/Users/ketanpadegaonkar/projects/gocd/gocd/tools/jruby/lib/ruby/stdlib/rubygems/commands/install_command.rb:1)
	at RUBY.(root)(/Users/ketanpadegaonkar/projects/gocd/gocd/tools/jruby/lib/ruby/stdlib/rubygems/commands/install_command.rb:4)
	at RUBY.(root)(/Users/ketanpadegaonkar/projects/gocd/gocd/tools/jruby/lib/ruby/stdlib/rubygems/command_manager.rb:1)
	at RUBY.<main>(/Users/ketanpadegaonkar/projects/gocd/gocd/tools/jruby/lib/ruby/stdlib/rubygems/command_manager.rb:207)
	at org.jruby.Ruby.runInterpreter(org/jruby/Ruby.java:840)
	at org.jruby.Ruby.loadFile(org/jruby/Ruby.java:2877)
	at org.jruby.RubyKernel.loadCommon(org/jruby/RubyKernel.java:981)
	at org.jruby.RubyKernel.load(org/jruby/RubyKernel.java:973)
	at org.jruby.RubyKernel$INVOKER$s$0$1$load19.call(org/jruby/RubyKernel$INVOKER$s$0$1$load19.gen)
	at Users.ketanpadegaonkar.projects.gocd.gocd.tools.jruby.bin.gem.invokeOther3:load(Users/ketanpadegaonkar/projects/gocd/gocd/tools/jruby/bin//Users/ketanpadegaonkar/projects/gocd/gocd/tools/jruby/bin/gem:4)
	at Users.ketanpadegaonkar.projects.gocd.gocd.tools.jruby.bin.gem.<main>(/Users/ketanpadegaonkar/projects/gocd/gocd/tools/jruby/bin/gem:4)
	at java.lang.invoke.MethodHandle.invokeWithArguments(java/lang/invoke/MethodHandle.java:638)
	at org.jruby.Ruby.runScript(org/jruby/Ruby.java:828)
	at org.jruby.Ruby.runNormally(org/jruby/Ruby.java:747)
	at org.jruby.Ruby.runNormally(org/jruby/Ruby.java:765)
	at org.jruby.Ruby.runFromMain(org/jruby/Ruby.java:578)
	at org.jruby.Main.doRunFromMain(org/jruby/Main.java:417)
	at org.jruby.Main.internalRun(org/jruby/Main.java:305)
	at org.jruby.Main.run(org/jruby/Main.java:232)
	at org.jruby.Main.main(org/jruby/Main.java:204)
Exception `LoadError' at org/jruby/RubyKernel.java:955 - load error: jopenssl/load -- java.lang.StringIndexOutOfBoundsException: begin 0, end 3, length 1
Exception `LoadError' at org/jruby/RubyKernel.java:955 - load error: jopenssl/load -- java.lang.StringIndexOutOfBoundsException: begin 0, end 3, length 1
Exception `LoadError' at org/jruby/RubyKernel.java:955 - load error: jopenssl/load -- java.lang.StringIndexOutOfBoundsException: begin 0, end 3, length 1
Exception `LoadError' at org/jruby/RubyKernel.java:955 - load error: jopenssl/load -- java.lang.StringIndexOutOfBoundsException: begin 0, end 3, length 1
Exception `LoadError' at org/jruby/RubyKernel.java:955 - load error: jopenssl/load -- java.lang.StringIndexOutOfBoundsException: begin 0, end 3, length 1
Exception `LoadError' at org/jruby/RubyKernel.java:955 - load error: jopenssl/load -- java.lang.StringIndexOutOfBoundsException: begin 0, end 3, length 1
Exception `LoadError' at org/jruby/RubyKernel.java:955 - load error: jopenssl/load -- java.lang.StringIndexOutOfBoundsException: begin 0, end 3, length 1
ERROR:  Loading command: install (LoadError)
	load error: jopenssl/load -- java.lang.StringIndexOutOfBoundsException: begin 0, end 3, length 1
	org/jruby/RubyKernel.java:955:in `require'
	/Users/ketanpadegaonkar/projects/gocd/gocd/tools/jruby/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:59:in `require'
	/Users/ketanpadegaonkar/projects/gocd/gocd/tools/jruby/lib/ruby/stdlib/openssl.rb:1:in `<main>'
	org/jruby/RubyKernel.java:955:in `require'
	/Users/ketanpadegaonkar/projects/gocd/gocd/tools/jruby/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:59:in `require'
	/Users/ketanpadegaonkar/projects/gocd/gocd/tools/jruby/lib/ruby/stdlib/rubygems/security.rb:1:in `<main>'
	org/jruby/RubyKernel.java:955:in `require'
	/Users/ketanpadegaonkar/projects/gocd/gocd/tools/jruby/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:59:in `require'
	/Users/ketanpadegaonkar/projects/gocd/gocd/tools/jruby/lib/ruby/stdlib/rubygems/security.rb:12:in `<main>'
	org/jruby/RubyKernel.java:955:in `require'
	/Users/ketanpadegaonkar/projects/gocd/gocd/tools/jruby/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:59:in `require'
	/Users/ketanpadegaonkar/projects/gocd/gocd/tools/jruby/lib/ruby/stdlib/rubygems/package.rb:1:in `<main>'
	org/jruby/RubyKernel.java:955:in `require'
	/Users/ketanpadegaonkar/projects/gocd/gocd/tools/jruby/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:59:in `require'
	/Users/ketanpadegaonkar/projects/gocd/gocd/tools/jruby/lib/ruby/stdlib/rubygems/package.rb:44:in `<main>'
	org/jruby/RubyKernel.java:955:in `require'
	/Users/ketanpadegaonkar/projects/gocd/gocd/tools/jruby/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:59:in `require'
	/Users/ketanpadegaonkar/projects/gocd/gocd/tools/jruby/lib/ruby/stdlib/rubygems/dependency_installer.rb:1:in `(root)'
	/Users/ketanpadegaonkar/projects/gocd/gocd/tools/jruby/lib/ruby/stdlib/rubygems/dependency_installer.rb:4:in `(root)'
	/Users/ketanpadegaonkar/projects/gocd/gocd/tools/jruby/lib/ruby/stdlib/rubygems/commands/install_command.rb:1:in `(root)'
	/Users/ketanpadegaonkar/projects/gocd/gocd/tools/jruby/lib/ruby/stdlib/rubygems/commands/install_command.rb:4:in `(root)'
	/Users/ketanpadegaonkar/projects/gocd/gocd/tools/jruby/lib/ruby/stdlib/rubygems/command_manager.rb:1:in `(root)'
	/Users/ketanpadegaonkar/projects/gocd/gocd/tools/jruby/lib/ruby/stdlib/rubygems/command_manager.rb:207:in `load_and_instantiate'
	/Users/ketanpadegaonkar/projects/gocd/gocd/tools/jruby/lib/ruby/stdlib/rubygems/command_manager.rb:127:in `<main>'
	org/jruby/RubyKernel.java:973:in `load'
	/Users/ketanpadegaonkar/projects/gocd/gocd/tools/jruby/bin/gem:4:in `<main>'
ERROR:  While executing gem ... (NoMethodError)
    undefined method `invoke_with_build_args' for nil:NilClass
	/Users/ketanpadegaonkar/projects/gocd/gocd/tools/jruby/lib/ruby/stdlib/rubygems/command_manager.rb:171:in `process_args'
	/Users/ketanpadegaonkar/projects/gocd/gocd/tools/jruby/lib/ruby/stdlib/rubygems/command_manager.rb:141:in `run'
	/Users/ketanpadegaonkar/projects/gocd/gocd/tools/jruby/lib/ruby/stdlib/rubygems/gem_runner.rb:59:in `run'
	/Users/ketanpadegaonkar/projects/gocd/gocd/tools/jruby/bin/jgem:21:in `<main>'
	org/jruby/RubyKernel.java:973:in `load'
	/Users/ketanpadegaonkar/projects/gocd/gocd/tools/jruby/bin/gem:4:in `<main>'
Exception `Gem::SystemExitException' at /Users/ketanpadegaonkar/projects/gocd/gocd/tools/jruby/lib/ruby/stdlib/rubygems/user_interaction.rb:394 - Exiting RubyGems with exit_code 1

Analysis

On further analysis, it appears that this bug is a combination of 2 things:

  • on java 9, the system property java.version is set to 9 as against 1.{6,7,8}.X in earlier versions
  • this causes these sets of methods to fail (
    static boolean javaVersion6(final boolean atLeast) {
    final int gt = "1.6".compareTo( javaVersion("0.0").substring(0, 3) );
    return atLeast ? gt <= 0 : gt == 0;
    }
    static boolean javaVersion7(final boolean atLeast) {
    final int gt = "1.7".compareTo( javaVersion("0.0").substring(0, 3) );
    return atLeast ? gt <= 0 : gt == 0;
    }
    static boolean javaVersion8(final boolean atLeast) {
    final int gt = "1.8".compareTo( javaVersion("0.0").substring(0, 3) );
    return atLeast ? gt <= 0 : gt == 0;
    }
    ), because the java.version does not follow the major.minor schema anymore.
ketan added a commit to ketan/jruby-openssl that referenced this issue Sep 26, 2017
ketan added a commit to ketan/jruby-openssl that referenced this issue Sep 26, 2017
@chingc
Copy link

chingc commented Sep 28, 2017

Thanks for fixing this. I'm eager to see your PR merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants