Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 0a2bede904d0
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 3c0e10bf744a
Choose a head ref
  • 2 commits
  • 4 files changed
  • 1 contributor

Commits on May 18, 2018

  1. Copy the full SHA
    11acd74 View commit details
  2. restore JRuby::CONFIG back as it used to be before (9.1)

    ... we'll eventually need a way to avoid JRuby.runtime.instance_config
    so this actually might make sense (or we can change back later)
    
    partially reverts commit bad6bd3
    kares committed May 18, 2018
    Copy the full SHA
    3c0e10b View commit details
30 changes: 11 additions & 19 deletions core/src/main/java/org/jruby/ext/jruby/JRubyLibrary.java
Original file line number Diff line number Diff line change
@@ -83,22 +83,23 @@ public void load(Ruby runtime, boolean wrap) {
JRuby.defineClassUnder("FiberLocal", runtime.getObject(), JRubyFiberLocal.ALLOCATOR)
.defineAnnotatedMethods(JRubyExecutionContextLocal.class);

/**
* JRuby::CONFIG ~ shortcut for JRuby.runtime.instance_config
* @since 9.2
*/
IRubyObject config = Java.getInstance(runtime, runtime.getInstanceConfig());
config.getMetaClass().defineAlias("rubygems_disabled?", "isDisableGems");
config.getMetaClass().defineAlias("did_you_mean_disabled?", "isDisableDidYouMean");
JRuby.setConstant("CONFIG", config);
RubyModule CONFIG = JRuby.defineModuleUnder("CONFIG");
CONFIG.getSingletonClass().defineAnnotatedMethods(JRubyConfig.class);
}

@Deprecated // old JRuby.defineModuleUnder("CONFIG")
/**
* JRuby::CONFIG
*/
public static class JRubyConfig {
// @JRubyMethod(name = "rubygems_disabled?")
@JRubyMethod(name = "rubygems_disabled?")
public static IRubyObject rubygems_disabled_p(ThreadContext context, IRubyObject self) {
return context.runtime.newBoolean(context.runtime.getInstanceConfig().isDisableGems());
}

@JRubyMethod(name = "did_you_mean_disabled?")
public static IRubyObject did_you_mean_disabled_p(ThreadContext context, IRubyObject self) {
return context.runtime.newBoolean(context.runtime.getInstanceConfig().isDisableDidYouMean());
}
}

/**
@@ -200,15 +201,6 @@ public static IRubyObject identity_hash(ThreadContext context, IRubyObject recv,
return context.runtime.newFixnum(System.identityHashCode(obj));
}

@JRubyMethod(module = true) // for RubyGems' JRuby defaults
public static IRubyObject classpath_launcher(ThreadContext context, IRubyObject recv) {
final Ruby runtime = context.runtime;
String launcher = runtime.getInstanceConfig().getEnvironment().get("RUBY");
if ( launcher == null ) launcher = ClasspathLauncher.jrubyCommand(runtime);
return runtime.newString(launcher);
}


@JRubyMethod(module = true, name = "parse", alias = "ast_for", required = 1, optional = 3)
public static IRubyObject parse(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block) {
// def parse(content = nil, filename = DEFAULT_FILENAME, extra_position_info = false, lineno = 0, &block)
23 changes: 22 additions & 1 deletion core/src/main/java/org/jruby/ext/jruby/JRubyUtilLibrary.java
Original file line number Diff line number Diff line change
@@ -44,6 +44,7 @@
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.runtime.load.Library;
import org.jruby.util.ClasspathLauncher;

import static org.jruby.util.URLUtil.getPath;

@@ -55,10 +56,11 @@
*/
public class JRubyUtilLibrary implements Library {

@Deprecated // JRuby::Util no longer used by JRuby itself
// JRuby::Util no longer used by JRuby itself
public void load(Ruby runtime, boolean wrap) throws IOException {
RubyModule JRubyUtil = runtime.getOrCreateModule("JRuby").defineModuleUnder("Util");
JRubyUtil.defineAnnotatedMethods(JRubyUtilLibrary.class);
JRubyUtil.setConstant("SEPARATOR", runtime.newString(org.jruby.util.cli.ArgumentProcessor.SEPARATOR));
}

@JRubyMethod(module = true)
@@ -103,6 +105,25 @@ public static IRubyObject getClassLoaderResources(IRubyObject recv, IRubyObject
}
}

@JRubyMethod(module = true) // for RubyGems' JRuby defaults
public static IRubyObject classpath_launcher(ThreadContext context, IRubyObject recv) {
final Ruby runtime = context.runtime;
String launcher = runtime.getInstanceConfig().getEnvironment().get("RUBY");
if ( launcher == null ) launcher = ClasspathLauncher.jrubyCommand(runtime);
return runtime.newString(launcher);
}

@JRubyMethod(name = "extra_gem_paths", module = true) // used from RGs' JRuby defaults
public static IRubyObject extra_gem_paths(ThreadContext context, IRubyObject recv) {
final Ruby runtime = context.runtime;
final List<String> extraGemPaths = runtime.getInstanceConfig().getExtraGemPaths();
IRubyObject[] extra_gem_paths = new IRubyObject[extraGemPaths.size()];
int i = 0; for (String gemPath : extraGemPaths) {
extra_gem_paths[i++] = runtime.newString(gemPath);
}
return RubyArray.newArrayNoCopy(runtime, extra_gem_paths);
}

@Deprecated // since 9.2 only loaded with require 'core_ext/string.rb'
public static class StringUtils {
public static IRubyObject unseeded_hash(ThreadContext context, IRubyObject recv) {
4 changes: 0 additions & 4 deletions core/src/main/ruby/jruby/jruby.rb
Original file line number Diff line number Diff line change
@@ -38,10 +38,6 @@ def compile_ir(content = nil, filename = DEFAULT_FILENAME, extra_position_info =
# @note implemented in *org.jruby.ext.jruby.JRubyLibrary*
def compile(content, filename = '', extra_position_info = false); end if false

# The current runtime's config (a `org.jruby.RubyInstanceConfig` instance).
# Changes to the configuration won't be reflected in the runtime, meant to be read-only.
CONFIG = runtime.instance_config if false

end

# NOTE: This is not a public API and is subject to change at our whim.
15 changes: 8 additions & 7 deletions lib/ruby/stdlib/rubygems/defaults/jruby.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# frozen_string_literal: true
require 'rbconfig'
require 'jruby'
require 'jruby/util'

module Gem

class << self
alias_method :__ruby__, :ruby
def ruby
ruby_path = __ruby__
ruby_path = JRuby::classpath_launcher if jarred_path?(ruby_path)
ruby_path = JRuby::Util.classpath_launcher if jarred_path?(ruby_path)
ruby_path
end

@@ -57,7 +58,7 @@ def self.win_platform?
# Allow specifying jar and classpath type gem path entries
def self.path_separator
return File::PATH_SEPARATOR unless File::PATH_SEPARATOR == ':'
/#{org.jruby.util.cli.ArgumentProcessor::SEPARATOR}/
/#{JRuby::Util::SEPARATOR}/
end
end

@@ -93,12 +94,12 @@ def dirs= dirs

def spec_directories_from_classpath
stuff = [ 'uri:classloader://specifications' ]
JRuby.runtime.instance_config.extra_gem_paths.each do |path|
JRuby::Util.extra_gem_paths.each do |path|
stuff << File.join(path, 'specifications')
end
stuff += JRuby.classloader_resources('specifications')
# some classloader return directory info. use only the "protocols"
# which jruby understands
stuff += JRuby::Util.classloader_resources('specifications')
# some classloader return directory info.
# use only the "protocols" which jruby understands
stuff.select { |s| File.directory?( s ) }
end
end