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: 568ddd8747cf
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: f4e7faabc3d5
Choose a head ref
  • 7 commits
  • 333 files changed
  • 2 contributors

Commits on Dec 27, 2015

  1. Copy the full SHA
    e5133ba View commit details
  2. Update stdlib to 2.3.0.

    headius committed Dec 27, 2015
    Copy the full SHA
    66570f0 View commit details
  3. Copy the full SHA
    12b14d4 View commit details
  4. Copy the full SHA
    3798e0b View commit details

Commits on Dec 28, 2015

  1. Copy the full SHA
    db5bc2e View commit details
  2. Fix use of incorrect field.

    headius committed Dec 28, 2015
    Copy the full SHA
    80ef241 View commit details
  3. Copy the full SHA
    f4e7faa View commit details
Showing 333 changed files with 3,497 additions and 1,970 deletions.
24 changes: 20 additions & 4 deletions core/src/main/java/org/jruby/Ruby.java
Original file line number Diff line number Diff line change
@@ -1272,13 +1272,21 @@ && getInstanceConfig().getCompileMode() != CompileMode.TRUFFLE) {
// out of base boot mode
bootingCore = false;

// init Ruby-based kernel
if (getInstanceConfig().getCompileMode() != CompileMode.TRUFFLE) {
// init Ruby-based kernel
initRubyKernel();
}

// everything booted, so SizedQueue should be available; set up root fiber
if (getInstanceConfig().getCompileMode() != CompileMode.TRUFFLE) {
// Define blank modules for feature detection in preludes
if (!config.isDisableGems()) {
defineModule("Gem");
}
if (!config.isDisableDidYouMean()) {
defineModule("DidYouMean");
}

initRubyPreludes();

// everything booted, so SizedQueue should be available; set up root fiber
ThreadFiber.initRootFiber(tc);
}

@@ -1784,6 +1792,14 @@ private void initRubyKernel() {
loadService.loadFromClassLoader(getClassLoader(), "jruby/kernel.rb", false);
}

private void initRubyPreludes() {
// We cannot load any .rb and debug new parser features
if (RubyInstanceConfig.DEBUG_PARSER) return;

// load Ruby parts of core
loadService.loadFromClassLoader(getClassLoader(), "jruby/preludes.rb", false);
}

private void addLazyBuiltin(String name, String shortName, String className) {
addBuiltinIfAllowed(name, new LateLoadingLibrary(shortName, className, getClassLoader()));
}
15 changes: 15 additions & 0 deletions core/src/main/java/org/jruby/RubyInstanceConfig.java
Original file line number Diff line number Diff line change
@@ -1187,6 +1187,13 @@ public boolean isDisableGems() {
return disableGems;
}

/**
* @see Options#CLI_DID_YOU_MEAN_ENABLE
*/
public boolean isDisableDidYouMean() {
return disableDidYouMean;
}

/**
* @see Options#CLI_RUBYOPT_ENABLE
*/
@@ -1201,6 +1208,13 @@ public void setDisableGems(boolean dg) {
this.disableGems = dg;
}

/**
* @see Options#CLI_DID_YOU_MEAN_ENABLE
*/
public void setDisableDidYouMean(boolean ddym) {
this.disableDidYouMean = ddym;
}

/**
* @see Options#BACKTRACE_STYLE
*/
@@ -1536,6 +1550,7 @@ public ClassLoader getCurrentThreadClassLoader() {
private String threadDumpSignal = null;
private boolean hardExit = false;
private boolean disableGems = !Options.CLI_RUBYGEMS_ENABLE.load();
private boolean disableDidYouMean = !Options.CLI_DID_YOU_MEAN_ENABLE.load();
private boolean disableRUBYOPT = !Options.CLI_RUBYOPT_ENABLE.load();
private boolean updateNativeENVEnabled = true;
private boolean kernelGsubDefined;
30 changes: 15 additions & 15 deletions core/src/main/java/org/jruby/RubyThread.java
Original file line number Diff line number Diff line change
@@ -821,21 +821,6 @@ public static IRubyObject pass(IRubyObject recv) {
return recv.getRuntime().getNil();
}

@JRubyMethod(meta = true)
public static IRubyObject exclusive(ThreadContext context, IRubyObject recv, Block block) {
Ruby runtime = context.runtime;
ThreadService ts = runtime.getThreadService();
boolean critical = ts.getCritical();

ts.setCritical(true);

try {
return block.yieldSpecific(context);
} finally {
ts.setCritical(critical);
}
}

@JRubyMethod(meta = true)
public static RubyArray list(IRubyObject recv) {
RubyThread[] activeThreads = recv.getRuntime().getThreadService().getActiveRubyThreads();
@@ -1996,4 +1981,19 @@ public void checkMail(ThreadContext context) {
public boolean selectForAccept(RubyIO io) {
return select(io, SelectionKey.OP_ACCEPT);
}

@Deprecated // moved to ruby kernel
public static IRubyObject exclusive(ThreadContext context, IRubyObject recv, Block block) {
Ruby runtime = context.runtime;
ThreadService ts = runtime.getThreadService();
boolean critical = ts.getCritical();

ts.setCritical(true);

try {
return block.yieldSpecific(context);
} finally {
ts.setCritical(critical);
}
}
}
1 change: 1 addition & 0 deletions core/src/main/java/org/jruby/util/cli/Options.java
Original file line number Diff line number Diff line change
@@ -213,6 +213,7 @@ public class Options {
public static final Option<String> CLI_BACKUP_EXTENSION = string(CLI, "cli.backup.extension", "Backup extension for in-place ARGV files. Same as -i.");
public static final Option<ProfilingMode> CLI_PROFILING_MODE = enumeration(CLI, "cli.profiling.mode", ProfilingMode.class, ProfilingMode.OFF, "Enable instrumented profiling modes.");
public static final Option<Boolean> CLI_RUBYGEMS_ENABLE = bool(CLI, "cli.rubygems.enable", true, "Enable/disable RubyGems.");
public static final Option<Boolean> CLI_DID_YOU_MEAN_ENABLE = bool(CLI, "cli.did_you_mean.enable", true, "Enable/disable did_you_mean.");
public static final Option<Boolean> CLI_RUBYOPT_ENABLE = bool(CLI, "cli.rubyopt.enable", true, "Enable/disable RUBYOPT processing at start.");
public static final Option<Boolean> CLI_STRIP_HEADER = bool(CLI, "cli.strip.header", false, "Strip text before shebang in script. Same as -x.");
public static final Option<Boolean> CLI_LOAD_GEMFILE = bool(CLI, "cli.load.gemfile", false, "Load a bundler Gemfile in cwd before running. Same as -G.");
10 changes: 1 addition & 9 deletions core/src/main/ruby/jruby/kernel.rb
Original file line number Diff line number Diff line change
@@ -32,12 +32,4 @@
load 'jruby/kernel/time.rb'
load 'jruby/kernel/gc.rb'
load 'jruby/kernel/range.rb'
load 'jruby/kernel/load_error.rb'

# From enc/prelude.rb in MRI
begin
require 'unicode_normalize'
rescue LoadError
end

load 'jruby/kernel/rubygems.rb' unless JRuby::CONFIG.rubygems_disabled?
load 'jruby/kernel/load_error.rb'
4 changes: 4 additions & 0 deletions core/src/main/ruby/jruby/kernel/enc_prelude.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
begin
require 'unicode_normalize'
rescue LoadError
end
7 changes: 7 additions & 0 deletions core/src/main/ruby/jruby/kernel/gem_prelude.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
if defined?(Gem)
require 'rubygems.rb'
begin
require 'did_you_mean'
rescue LoadError
end if defined?(DidYouMean)
end
2 changes: 0 additions & 2 deletions core/src/main/ruby/jruby/kernel/io.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# Under MRI (<2.1), EAGAIN is extended on every creation with the appropriate
# module. Due to the absurd overhead that results, we use these classes instead.
class IO
class EAGAINWaitReadable < Errno::EAGAIN
include IO::WaitReadable
134 changes: 134 additions & 0 deletions core/src/main/ruby/jruby/kernel/prelude.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
class Thread
MUTEX_FOR_THREAD_EXCLUSIVE = Mutex.new # :nodoc:

# call-seq:
# Thread.exclusive { block } => obj
#
# Wraps the block in a single, VM-global Mutex.synchronize, returning the
# value of the block. A thread executing inside the exclusive section will
# only block other threads which also use the Thread.exclusive mechanism.
def self.exclusive
warn "Thread.exclusive is deprecated, use Mutex", caller
MUTEX_FOR_THREAD_EXCLUSIVE.synchronize{
yield
}
end
end

class IO

# call-seq:
# ios.read_nonblock(maxlen [, options]) -> string
# ios.read_nonblock(maxlen, outbuf [, options]) -> outbuf
#
# Reads at most <i>maxlen</i> bytes from <em>ios</em> using
# the read(2) system call after O_NONBLOCK is set for
# the underlying file descriptor.
#
# If the optional <i>outbuf</i> argument is present,
# it must reference a String, which will receive the data.
# The <i>outbuf</i> will contain only the received data after the method call
# even if it is not empty at the beginning.
#
# read_nonblock just calls the read(2) system call.
# It causes all errors the read(2) system call causes: Errno::EWOULDBLOCK, Errno::EINTR, etc.
# The caller should care such errors.
#
# If the exception is Errno::EWOULDBLOCK or Errno::EAGAIN,
# it is extended by IO::WaitReadable.
# So IO::WaitReadable can be used to rescue the exceptions for retrying
# read_nonblock.
#
# read_nonblock causes EOFError on EOF.
#
# If the read byte buffer is not empty,
# read_nonblock reads from the buffer like readpartial.
# In this case, the read(2) system call is not called.
#
# When read_nonblock raises an exception kind of IO::WaitReadable,
# read_nonblock should not be called
# until io is readable for avoiding busy loop.
# This can be done as follows.
#
# # emulates blocking read (readpartial).
# begin
# result = io.read_nonblock(maxlen)
# rescue IO::WaitReadable
# IO.select([io])
# retry
# end
#
# Although IO#read_nonblock doesn't raise IO::WaitWritable.
# OpenSSL::Buffering#read_nonblock can raise IO::WaitWritable.
# If IO and SSL should be used polymorphically,
# IO::WaitWritable should be rescued too.
# See the document of OpenSSL::Buffering#read_nonblock for sample code.
#
# Note that this method is identical to readpartial
# except the non-blocking flag is set.
#
# By specifying `exception: false`, the options hash allows you to indicate
# that read_nonblock should not raise an IO::WaitReadable exception, but
# return the symbol :wait_readable instead.
def read_nonblock(len, buf = nil, exception: true)
__read_nonblock(len, buf, exception)
end

# call-seq:
# ios.write_nonblock(string) -> integer
# ios.write_nonblock(string [, options]) -> integer
#
# Writes the given string to <em>ios</em> using
# the write(2) system call after O_NONBLOCK is set for
# the underlying file descriptor.
#
# It returns the number of bytes written.
#
# write_nonblock just calls the write(2) system call.
# It causes all errors the write(2) system call causes: Errno::EWOULDBLOCK, Errno::EINTR, etc.
# The result may also be smaller than string.length (partial write).
# The caller should care such errors and partial write.
#
# If the exception is Errno::EWOULDBLOCK or Errno::EAGAIN,
# it is extended by IO::WaitWritable.
# So IO::WaitWritable can be used to rescue the exceptions for retrying write_nonblock.
#
# # Creates a pipe.
# r, w = IO.pipe
#
# # write_nonblock writes only 65536 bytes and return 65536.
# # (The pipe size is 65536 bytes on this environment.)
# s = "a" #100000
# p w.write_nonblock(s) #=> 65536
#
# # write_nonblock cannot write a byte and raise EWOULDBLOCK (EAGAIN).
# p w.write_nonblock("b") # Resource temporarily unavailable (Errno::EAGAIN)
#
# If the write buffer is not empty, it is flushed at first.
#
# When write_nonblock raises an exception kind of IO::WaitWritable,
# write_nonblock should not be called
# until io is writable for avoiding busy loop.
# This can be done as follows.
#
# begin
# result = io.write_nonblock(string)
# rescue IO::WaitWritable, Errno::EINTR
# IO.select(nil, [io])
# retry
# end
#
# Note that this doesn't guarantee to write all data in string.
# The length written is reported as result and it should be checked later.
#
# On some platforms such as Windows, write_nonblock is not supported
# according to the kind of the IO object.
# In such cases, write_nonblock raises <code>Errno::EBADF</code>.
#
# By specifying `exception: false`, the options hash allows you to indicate
# that write_nonblock should not raise an IO::WaitWritable exception, but
# return the symbol :wait_writable instead.
def write_nonblock(buf, exception: true)
__write_nonblock(buf, exception)
end
end
4 changes: 4 additions & 0 deletions core/src/main/ruby/jruby/preludes.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Load preludes
load 'jruby/kernel/prelude.rb'
load 'jruby/kernel/enc_prelude.rb'
load 'jruby/kernel/gem_prelude.rb'
10 changes: 6 additions & 4 deletions lib/ruby/stdlib/English.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# Modified for JRuby
# In JRuby, we define these aliases by default, so this file
# does nothing.

# frozen_string_literal: false
#
# Modified for JRuby
# In JRuby, we define these aliases by default, so this file
# does nothing.
#
# Include the English library file in a Ruby script, and you can
# reference the global variables such as \VAR{\$\_} using less
# cryptic names, listed in the following table.% \vref{tab:english}.
1 change: 1 addition & 0 deletions lib/ruby/stdlib/abbrev.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: false
#--
# Copyright (c) 2001,2003 Akinori MUSHA <knu@iDaemons.org>
#
22 changes: 19 additions & 3 deletions lib/ruby/stdlib/base64.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: false
#
# = base64.rb: methods for base64-encoding and -decoding strings
#
@@ -77,15 +78,30 @@ def strict_decode64(str)
# This method complies with ``Base 64 Encoding with URL and Filename Safe
# Alphabet'' in RFC 4648.
# The alphabet uses '-' instead of '+' and '_' instead of '/'.
def urlsafe_encode64(bin)
strict_encode64(bin).tr("+/", "-_")
# Note that the result can still contain '='.
# You can remove the padding by setting +padding+ as false.
def urlsafe_encode64(bin, padding: true)
str = strict_encode64(bin).tr("+/", "-_")
str = str.delete("=") unless padding
str
end

# Returns the Base64-decoded version of +str+.
# This method complies with ``Base 64 Encoding with URL and Filename Safe
# Alphabet'' in RFC 4648.
# The alphabet uses '-' instead of '+' and '_' instead of '/'.
#
# The padding character is optional.
# This method accepts both correctly-padded and unpadded input.
# Note that it still rejects incorrectly-padded input.
def urlsafe_decode64(str)
strict_decode64(str.tr("-_", "+/"))
# NOTE: RFC 4648 does say nothing about unpadded input, but says that
# "the excess pad characters MAY also be ignored", so it is inferred that
# unpadded input is also acceptable.
str = str.tr("-_", "+/")
if !str.end_with?("=") && str.length % 4 != 0
str = str.ljust((str.length + 3) & ~3, "=")
end
strict_decode64(str)
end
end
Loading