Skip to content
This repository

Kernel require #280

wants to merge 607 commits into from

Sorry. I need to figure out how to indicate that I just want a couple of lines changed. Hold on.

In jruby, the autoload mechanism doesn't actually call Kernel.require like the rubydocs claims it will. This change attempts to fix that.


autoload(module, filename) → nil click to toggle source

Registers filename to be loaded (using Kernel::require) the first time that module (which may be a String or a symbol) is accessed in the namespace of mod.

Note that this change uses the context when autoload is called rather than the context at the time when the require will happen. I wasn't sure what the right thing to do is, or how much it really matters or not.

The purpose of this change is to allow the user to override Kernel.require even with autoloading. rubygems is presmably the most well-known overrider of Kernel.require. It presumably ends up pulling in enough stuff into LOAD_PATH via direct requires that any autoloading it does still works, but I suspect it could be problematic if it tried to add paths for autoloaded files.

Also, my apologies that this commit has an old parent (it's whatever rvm was using).

Thanks for your consideration,


and others added some commits November 16, 2011
Charles Oliver Nutter Fix JRUBY-6212: IO#inspect in 1.9 could be prettier
(cherry picked from commit b7c3cc2)
Charles Oliver Nutter Fix for OpenJDK 7 and popen from 8798e1f 24f4592
Charles Oliver Nutter Fix JRUBY-6205: 'Bad file descriptor' when using IO.popen4 with OpenJ…
…DK 7

* Same fix as for popen some months ago. See 8798e1f
(cherry picked from commit 3adbb9e)


Charles Oliver Nutter Don't attempt to track lines that are <= 0, since they're probably in…
Charles Oliver Nutter Fix JRUBY-6201: File reading performance regression
Oddly enough, the regression here was in Module#name for anonymous
classes. For JRUBY-6030, anonymous classes that later gain a parent
namespace were fixed to recalculate their new name. However, the
change also made anonymous classes never cache their names. It turns
out that the way those names were being calculated was rather
expensive, and as a result a hidden perf issue surfaced.

For 1.6.x, I've modified the anonymous name calculation to cache,
since it never changes (it is based on identity hash code). I also
made an optimization pass on the normal non-anonymous class name
calculation, since master (1.7) no longer caches either name.
Charles Oliver Nutter Fix JRUBY-6198: When calling dup on file open in binmode the new obje…
…ct does not respect binmode

* binmode was propagated as a mode, but not as a flag on the underlying Stream.
(cherry picked from commit ed560a8)
Charles Oliver Nutter Fix JRUBY-6192: jruby::Handle declarations use 'extern "C"', causing …
…linker symbol mismatches
Uwe Kubosch * JRUBY-6172 Test
Signed-off-by: Hiro Asari <>
Uwe Kubosch * JRUBY-6172 Avoid using getCanonicalPath to expand JAR entry paths
Signed-off-by: Hiro Asari <>
Hiroshi Nakamura JRUBY-6208: GzipWriter creates corrupted gzip stream for binary data
default_external for GzipWriter IO stream is not specified by default.
Hiroshi Nakamura [1.9] Make Encoding.default_external = enc work
default_internal, too.
Hiro Asari In 1.9, BigDecimal#div raises FloatDomainError if self or argument is…
… a NaN.
Hiro Asari In 1.9, BigDecimal#div(INFINITY) returns 0 80b341c
Hiro Asari In 1.9, throw ZeroDivisionError if arg for BigDecimal#div is 0 and no…
… precision is given.
Hiro Asari In 1.9, BigDecimal("Infinity").div BigDecimal("1") raise FloatDomainE…
Benoit Daloze Struct#members and Struct::members should return an Array of Symbols …
…in 1.9

Signed-off-by: Hiro Asari <>
Hiro Asari In 1.9, Hash#merge! checks frozen-ness earlier than checking the argu…
…ment's emptiness.
Hiro Asari Fix BigDecimal#divmod in the 1.9 mode, according to RubySpec. da8a68c
Hiro Asari Add bin/rake to jar-complete. Fixes JRUBY-6233. e27686b
Hiro Asari Fix Array#* spec, where taintedness does not propagate to the return …
…value if arg = 0.
Hiro Asari Fix Fixnum#quo spec, where arg is a Bignum. fca0b1b
Hiro Asari In 1.9 mode, allow permutations larger than the number of elements in…
… the set.
Thomas E Enebo JRUBY-6120: Incorrect behavior of RubyMatchData updateCharOffset() an…
…d Strings with special characters
Thomas E Enebo Revert asm back to 3.3 on 1.6 branch deab67d
Charles Oliver Nutter Fix ASM reference in IntelliJ project. 2d9b189
Charles Oliver Nutter Fix JITed class names in backtraces. 5ecde60
Charles Oliver Nutter Repair damage from e0ee1ec.
I reversed the evaluation order of "colon2" assignment to ensure the
value evaluates first, but failed to remove "swap" operations
elsewhere that expected the RuntimeHelpers.setConstantInModule
method to take the LHS, RHS ordering. Fixed those locations and
added a test.
Charles Oliver Nutter Add target java version to compile-test target. D'oh! 0542fc8
Charles Oliver Nutter Make rake-based calls to java have permgen up to 512M. 74da27a
Charles Oliver Nutter Add install-gems as a dep of test-all, since it needs the dev gems. 8458cad
Charles Oliver Nutter A new implementation of ThreadFiber that passes specs.
The raw LockSupport use I had before was fast, but I did not deal
with the fact that any fiber could end up waking any thread,
regardless of whether that thread was waiting on the fiber. By
switching to Exchanger, a given fiber can only wake the thread
that is actually waiting on it.

This may not be as fast as the other impl, but works properly. I
will reinvestigate performance.


Charles Oliver Nutter Add RandomAccess to RubyArray implements. a69f064
Charles Oliver Nutter Remove unnecessary "this" printing from ThreadFiber exceptions. 00aa52c
Yoko Harada Fix for JRUBY-6229. Adds get/setProfilingMode methods. This correspon…
…ds to --profile.api/--profile.flat/--profile.graph command line options
Yoko Harada Adds setProfilingMode method to RubyInstanceConfig so that ScriptingC…
…ontainer user can change profile mode.
Hiro Asari Fix JRUBY-6237: Allow the syntax `a = b = f 1`
This was introduced with MRI 1.9.3.
Thomas E Enebo 1.9: when *[], false no longer explodes f497f26
Charles Oliver Nutter Fix JRUBY-6272: Encoding exception running JRuby 1.6.5 (1.8 mode)
Don't use cat19 for Hash#inspect in 1.8 mode.
Yoko Harada Possible fix for JRuby-6110. 6cc12dc
Yoko Harada Avoids NPE from ScriptingContainer.terminate() method and adds termin…
…ate tests for LocalContextProviders.
Charles Oliver Nutter Update JRuby versions to, since that's what we're working on. 7805966
Nick Klauer Windows won't move the `.jar.bak` file back to the `.jar` as there's …
…a file there, so forcing it works when tearing down.
Thomas E Enebo Do not test symlink on windows 0d7103e
Nick Sieger Get Windows build clean again 56dfda4
Nick Klauer fix test for windows line terminating chars `\r\n`. 011927b
Nick Klauer"") doesn't return the right error on WinXP. f129a92
Nick Sieger Missed import of JRubyNonExistentFile 4bfd298
Nick Klauer fix test/test_file#test_file_uri_stat on WinXP
The if statement should be broken down into two parts so an else clause
can throw an exception for file not found errors as it does throughout the
rest of the method.

Fixes the following test failures on WinXP:

  2) Failure:
test_file_stat_uri_prefixes(TestFile) [.\test\test_file.rb:556]:
[Errno::ENOENT] exception expected, not
Class: <SystemCallError>
Message: <"Unknown error - Unknown Error (20047) - C:/klauer-jruby/file:">
org/jruby/ `lstat'
.\test\test_file.rb:557:in `test_file_stat_uri_prefixes'

  3) Failure:
test_file_time_uri_prefixes(TestFile) [.\test\test_file.rb:573]:
[Errno::ENOENT] exception expected, not
Class: <SystemCallError>
Message: <"Unknown error - Unknown Error (20047) - C:/klauer-jruby/file:">
org/jruby/ `atime'
.\test\test_file.rb:574:in `test_file_time_uri_prefixes'
Charles Oliver Nutter Update to JRuby fork of RubyGems 1.8.12. 59c1509
Deepak Giridharagopal Comparing a RubyFileStat object with an object which is not a RubyFil…
…eStat should return 'nil'.

Otherwise, we get a ClassCastException when we attempt to cast "other" to a RubyFileStat.
Thomas E Enebo Placeholder for next upcoming version of jnr-posix for 1.6.6 until it…
… is really released
Charles Oliver Nutter Add coro-mock jar to eliminate java.dyn package in our repo. bc8ece7
Charles Oliver Nutter Remove java.dyn classes. 8a4efc7
Charles Oliver Nutter Update to RubyGems 1.8.13 (JRuby fork). 76bcfdc
Hiro Asari Invert the priority for setting the default directory for Dir.chdir w…
…hen directory is not given. This partially addresses JRUBY-6295. (This commit corresponds to 5dfa654 on master.)
Charles Oliver Nutter Reinstate 1.9 logic in compiler for splatting nil.

Charles Oliver Nutter Proper fix for DRegexp and mixed encodings in 1.9 mode.

Charles Oliver Nutter Additional tweaks and fixes for dregexp fix from master.
* Tom's code-range scanning line
* Missing imports
* Wrong param type in RuntimeCache for Bignum method
Thomas E Enebo Allow proper 1.9 splatting for interpreter (JIT to come) ef43a18
Thomas E Enebo Fixes to_ary behavior of 1.9 in interp only 3e25b55
Charles Oliver Nutter Fix JRUBY-6171: Enumerable does not splat
Turned out it was simpler than I thought...1.9 splats a bit differently,
and we weren't calling that path.
Hiroshi Nakamura [1.9] One-off fix for read_nonblock CPU 100% issue
Replace "read_nonblock + timeout" in 1.9 stdlib with
"Timeout.timeout + sysread" in 1.8's one.  With current JRuby,[io], nil, nil, timeout) could return promptly even if io is
not readable. (I'm not sure the condition when it happens at this

Because of this behavior, rbuf_fill in 1.9/net/protocol.rb
fails to busy loop of io.read_nonblock and  As a workaround,
this commit replaces rbuf_fill of 1.9 stdlib with 1.8's one which uses
Timeout + sysread instead.

sysread_nonblock + is introduced from perf concern.  JRuby has
a better Timeout logic so this change should not affect users.

I apply this change only for jruby-1_6 branch.  For 1.7, I'll try to
solve this issue by fixing nonblocking IO at master.
Thomas E Enebo No pipe on windows to test 0ebdad2
Charles Oliver Nutter Partial fix for JRUBY-6200: [1.9] Loading some Unicode characters res…
…ults in non-printable characters on Windows

The InputStreamReader we wrapped around the "IO like" object did not
specify an encoding. For now, we force UTF-8, since that likely
covers 99.9% of all YAML out there, and fixes the original reported
Charles Oliver Nutter Lost import of RubyEncoding somehow. b924cef
Hiroshi Nakamura [SECURITY] Random String#hash to avoid DoS attack
This is the fix for CVE-2011-4838.

Randomize String#hash (in Ruby world) and internal RubyString#hashCode()
(in Java world) for 'Denial of Service via Algorithmic Complexity
Attacks' explained in [1].  Introduce the runtime-local seed for hash
randomization which is set at runtime initialization and use it as the
seed for MurmurHash 2.0 [2].  MurmurHash is used in CRuby 1.9 and it
should make the attacks difficult. (Assuming that no reverse function
has been found for MurmurHash 2.0)

Credit to Alexander Klink <> and
Julian Waelde <> for reporting
this issue.

Hiro Asari Fix JRUBY-6307. Under some circumstances, the test "xz /x != z" can g…
…ive a wrong result because x*x overflows the "long" range and the overflow ends up in just the right spot. We fix this problem by introducing BigInteger here. This is a tiny performance hit; if there is a better way while retaining correctness, I would be curious to learn the trick.
Hiro Asari spec for JRUBY-6307. I do not know if it is really a regression, but …
…I will put the spec here.
Hiroshi Nakamura Hide hash value test which expects deterministic hash value 2fc3a13
Charles Oliver Nutter Add .idea files so we can switch to/from jruby-1_6 without warnings. 87c7bed
Lelon Stoldt Move 'to_i' so it gets picked up by DefaultTypePopulator
Signed-off-by: Hiro Asari <>
Hiro Asari In the eyes of RubyGems, equate YAML::Yecht with Syck, so that Defaul…
…tKey in Dependency resolves to "=". This fixes the issue described in
Charles Oliver Nutter Update to latest 1.9.2 stdlib. be3f90f
Charles Oliver Nutter Update 1.9.2 stdlib list to not copy thread.rb. e06dc50
Charles Oliver Nutter Update patchlevel and revision for 1.9.2 support. 7b34774
Charles Oliver Nutter Set English.rb aliases immediately, and make it a no-op.
Because we rely on the presence of $~ and $_ global variables to
know we must allocate space for them, we need to define their
English.rb aliases right away and disallow further aliasing. Since
we must define those aliases, we might as well define all aliases
and make English.rb a no-op.
Charles Oliver Nutter Add missing global alias $MATCH from English.rb. 3a83bb7
Charles Oliver Nutter Update to latest 1.8.7 stdlib. 29bae86
Charles Oliver Nutter Update 1.8.7 patchlevel. ef36279
Charles Oliver Nutter Fix JRUBY-6284: Calls to Kernel#exit result in an exception printed o…
…n stderr

Allow SystemExit propagated to an embedded container's "run" or "eval"
call to simply make the script return the exit's status.
Charles Oliver Nutter Fix JRUBY-6281: [1.9] Applet does not work in the 1.9 mode
For 1.9 mode we canonicalize loaded paths to make sure we are not
double-loading files that are required in different ways, and so we
can properly use per-file locking around requires. However, in a
restricted environment we may not be able to canonicalize. My fix
falls back on just using the literal require name in such cases.

I also split the test-security-manager task into 1.8 and 1.9 versions.


Charles Oliver Nutter Fix JRUBY-6280: Fails to open fifo for writing.
It turns out that in glibc, fopen operations that would seek in
the resulting file descriptor do actually check for ESPIPE to know
that a failed seek is due to the file being a pipe or FIFO. We do
not have direct access to the actual ESPIPE, but we can check the
IOException message to know if it's the same problem.

I don't think there's any real risk in this change, since it will
only quietly fail to seek on a file when it's impossible to seek
on that file, which is what we want. Other error cases and open
failures should propagate as before.

Hiro Asari Fix Complex#coerce spec when other is a Complex. f83e347
Hiro Asari Fix Complex#rationalize spec. bdaf760
Yoko Harada Adds more predefined global variable names to avoid unexpected errors. 12f02ae
Charles Oliver Nutter Use JRuby's parent classloader rather than JRubyClassLoader for startup. 4dc6d33
Yoko Harada $ARGV and $* should not be readonly to meet with JSR223 spec. 80b7d22
Charles Oliver Nutter Update jnr-posix.jar to latest, for JRUBY-6286 patch. 6a85dd0
larvacea JRUBY-3944: process :binmode option
The :binmode option, when set to TRUE, is ORed in with flags from the mode string or
:mode option, as it is in MRI 1.9.2. Tested in rubyspec; both MRI and this code pass
new tests for :binmode, and the existing jruby 1.6.5 code fails as expected.

Signed-off-by: Hiro Asari <>
Charles Oliver Nutter Refactor parsing of options for encodings and modes. 3233fcf
Hiro Asari Fix JRUBY-6318: Tempfile#open does not return the value of the block …
…given to it

This happens only for the 1.9 mode.
Charles Oliver Nutter 1.9 fixes for popen.
* Process modes and encodings into the resulting IO object
* Use the target class for the resulting IO object


Charles Oliver Nutter Refactor some process-launching logic into ProcessMaker. 729a4e1
Charles Oliver Nutter Fix bad reference to Tempfile, nonexistent on jruby-1_6. ed3d56d
Charles Oliver Nutter Fix JRUBY-6319: 'binding' returns wrong binding
instance_exec was not setting the binding's self along one path.
Charles Oliver Nutter Fix JRUBY-6324: `pollAndGetClass': java.lang.NullPointerException
The problem here was that srand's global seed was not initialized
at boot, resulting in the first call returning null. That null
propagated into Ruby execution, eventually blowing up in a call

My fix is to make an initial call to the srand logic, creating a
first seed.
Hiro Asari Fix JRUBY-5792: Eval error for hashes containing symbols ending with …
…an equals sign

Here, we remove the test for n which prevented us from matching MRI behavior of this corner case of the Ruby grammar.
Hiroshi Nakamura Update Eclipse build configuration
Add coro-mock jar.
Yoko Harada Additional fix for JRUBY-6110. 69c2b7b
Hiroshi Nakamura JRUBY-6324: random seed for srand is not initialized properly
jruby -e 'p srand' returns previous (initial) srand seed.  In 1.8 mode,
it always returns 0 but it's not correct.  In 1.9 mode, it crashes with
NullPointerException because it returns null as RubyObject.  Anyway,
initial seed value is not initialized properly.

This commit includes several fixes for Random.

* Initialize the runtime-local PRNG and seed at Ruby#initCore().

* Keep seed for PRNG as not long but RubyInteger.
  % jruby165 -e 'n = 2**128; srand(n); p [n.object_id, srand.object_id]'
  [2000, 1] => should be the same object

* Introduced Ruby#randomSeedRandom as the runtime-local PRNG for
  generating seed by srand.  Do not use System.currentTimeMillis which
  is not suited for PRNG seed.

* Removed globalRandom in RubyRandom class which is used only in 1.9
  mode.  Use Ruby#getRandom() for global srand as same as 1.8 mode.
Thomas E Enebo'd that get in there 226906c
Hiroshi Nakamura Temporal fix for spec failure
Sorry for breaking release build.  I don't know why 'id1.should == id2'
does not work when I run it as 'jruby -S rake spec:regression' for now.
It runs fine when I run the spec independently.

I'll investigate it later.
Charles Oliver Nutter Add ci_compiled_19 and ci_precompiled_19 targets. d0fca5c
Hiroshi Nakamura [1.9] One-off fix for read_nonblock CPU 100% issue
Replace "read_nonblock + timeout" in 1.9 stdlib with
"Timeout.timeout + sysread" in 1.8's one.  With current JRuby,[io], nil, nil, timeout) could return promptly even if io is
not readable. (I'm not sure the condition when it happens at this

Because of this behavior, rbuf_fill in 1.9/net/protocol.rb
fails to busy loop of io.read_nonblock and  As a workaround,
this commit replaces rbuf_fill of 1.9 stdlib with 1.8's one which uses
Timeout + sysread instead.

sysread_nonblock + is introduced from perf concern.  JRuby has
a better Timeout logic so this change should not affect users.

I apply this change only for jruby-1_6 branch.  For 1.7, I'll try to
solve this issue by fixing nonblocking IO at master.
Hiroshi Nakamura Revert "Temporal fix for spec failure"
This reverts commit f0c769d.
Hiroshi Nakamura Re-fix regression spec about cross runtime Object handling
You cannot do id1.should == id2 here because the Objects are from
different runtime!  Cross runtime comparison confuses rspec and it tries
to raise an expectation exception, but the RaiseException is also
confusing about runtime so it can be thrown.

Cross runtime object passing is evil.  I should implement Channel for
this purpose.
Hiroshi Nakamura Merge branch 'jruby-1_6' of into jruby-1_6 6cdf95c
Charles Oliver Nutter Minor perf improvement and bytecode reduction for interpolated strings.
The 1.6 version omits methods added to RubyString.
Charles Oliver Nutter Fix encoded regexp spec failures.
The compiler was caching identical bytelists but not considering
encoding. As a result, two literal strings/regexps with the same
content bit different encodings would share one bytelist, with
one of them ending up incorrect. Added encoding to the cache key
to ensure differently-encoded strings/regexps don't use the same
Charles Oliver Nutter Fix JRUBY-6323
JRuby does not pay attention to either -U or LANG in determining encoding for ARGV (it is always ASCII-8BIT)

Added and used utility methods for producing internally-encoded
Strings from Java strings that came from an external source like
command-line arguments. This allows ARGV to reflect the proper ruby
internal encoding.


Charles Oliver Nutter Improved error for JRUBY-6317
YAML can't parse some valid unicode characters

* Moved the exception-handling outside the processing of the
incoming YAML string/IO, so it gets the Ruby treatment.
Charles Oliver Nutter Fix JRUBY-4846
1.9: Float#to_s has changed

* Bump up default precision for Float#to_s to ensure all digits
come through. We crop it in 1.8 mode to match 1.8.
Charles Oliver Nutter Fix JRUBY-6182
Marshal.dump yields different value after adding/removing instance variables (and disagrees with MRI)

* Remove the ivar table when it has no values remaining, so that
marshaled output will not reflect a zero-length ivar table.
Charles Oliver Nutter Add tags for newly-failing Float#to_s specs
Because the new behavior does not lose roundtripping like the
issue I fixed, I'm going to tag these. The difference between using
the "e" format or using the full decimal notation is minor compared
to dropping digits.


Charles Oliver Nutter Fix JRUBY-6224
In MRI 1.9 the flag for Module#const_get also controls lookup of toplevel constants but not in JRuby


Thomas E Enebo Better yield 1.9 logic? 8f5dac5
Charles Oliver Nutter Fix JRUBY-5338
1.9 String#% support

This impl comes from Anthony Juckel. Thanks!
Charles Oliver Nutter Fix JRUBY-5947 in compiler. 62586d8
Hiro Asari Redo the commit (de5976b) that didn't quite work. Magic comment shoul…
…d be processed if and only if the comment is on the first line and there are no preceding tokens on that line.
Thomas E Enebo [19]: oh yeah. No more known regexp encoding issues with dregexp a853c83
Thomas E Enebo [19] Remove tags for encoding specs eb65044
Thomas E Enebo [19]: Encoding.find enc_obj should return itself 41984f1
Charles Oliver Nutter Port yield "aryToAry" logic to compiler. 5f98b23
Charles Oliver Nutter Fix JRUBY-4913
FileUtils.cp failed if file source is too big (>= 1GB)

On 32-bit JVMs, FileChannel.transferTo would attempt to mmap a
a larger addressable space than the process could handle. This
caused the error. My fix is to catch that error and then attempt
the copy again in 100MB chunks. 100MB may still fail if we are
close to the process's addressable memory limit, but it's much
more reliable than what we had before.
Thomas E Enebo [19] Several exposed problems with join from mri19 test suite. 1. emp…
…ty [].join should always be USASCII. 2. join of nested arrays should inherit first elements encoding. 3. to_ary never hit because of faulty to_s logic. 4. Nested values in a join should get first elements encoding
Charles Oliver Nutter Remaining fix for JRUBY-5633
String#encode(opts) not properly implemented for --1.9
Thomas E Enebo JRUBY-6338: JRuby does not look for .jrubyrc in home directory on Win…
Thomas E Enebo JRUBY-5809: [1.9] String.inspect produces wrong output on UTF-8 string 7964937
Thomas E Enebo [19]: Fixes String#inspect mutating from default_internal to underlyi…
…ng string impl
Thomas E Enebo [19] JRUBY-6240: java.lang.IllegalArgumentException when running simp…
…le RDoc conversion
Marcin Mielżyński reenable check for coderange of string that's being fed to regexps a6a7fe6
Charles Oliver Nutter Fix JRUBY-6359
Can't convert nil to String building ActiveSupport RDoc in 1.9 mode
Charles Oliver Nutter Fix multiple places that called 1.8 instead of 1.9 regexp methods.
Many places in the codebase unconditionally called the 1.8 versions
of several RubyRegexp methods that have 1.9-specific behavior. This
led to hangs like JRUBY-5808, and very likely is the source of
other encoding-related bugs.

I audited only RubyRegexp methods that have 1.9-specific versions
and fixed all incorrect calls. Tests and specs pass in interpreted
and compiled modes. A similar audit for other core classes is most
definitely warranted.


Charles Oliver Nutter Fix compilation error under Java 5: no String.getBytes(Charset). 2bfc1ce
Hiro Asari Correctly fix Scala-like method name $bslash. Includes spec. This sho…
…uld fix JRUBY-6327.


Thomas E Enebo JRUBY-6370, JRUBY-6366 splat requestions in 1.9 15ebbbe
Charles Oliver Nutter Don't lock inside try for Mutex#synchronize.
If the locking process blocks and is interrupted, or raises an
error for some other reason, the unlock will erroneously produce
errors since the lock is not locked. Found by @davetron5000.


Charles Oliver Nutter Compiler side of fix for JRUBY-6370, JRUBY-6366. e82af9a
Thomas E Enebo Update jcodings to new 1.0.6 b2c3259
Charles Oliver Nutter Fix broken argument logic in trace_var and untrace_var. d0fe58d
Charles Oliver Nutter Fix JRUBY-6367.
--pre command line switch not working in 1.9 runtime

This is actually broken in both 1.8 and 1.9 modes, but only 1.9's
optparse exposed it. We were not properly passing blocks through
procified Method objects. Fixed MethodBlock and RubyMethod.bmcall
to do that.
Charles Oliver Nutter Fix JRUBY-6375
Uninformative YAML parser error

* Added better error message to match 1.9.3.



I also incorporated a number of fixes that had only been applied
to master and which were causing hassles when merging.
Thomas E Enebo JRUBY-6377: rspec .should include() fails in --1.9 20341c0
Thomas E Enebo 19: Make lambdas check arity (interp-only) 4ad5e15
Charles Oliver Nutter Compiler fix for JRUBY-6377 and refactoring.
I moved the shared logic to RuntimeHelpers and made the invariant
"needsSplat" a field on both block types calculated on construct.
Charles Oliver Nutter Fix JRUBY-5967
[1.9] Rails fails to start if any library sets YAML::ENGINE.yamler= 'syck'

I modified our yaml.rb to ignore and warn when setting engine to
anything other than 'psych'.
Charles Oliver Nutter Reinstate engine check. 8348327
Charles Oliver Nutter Update stdlib to 1.9.2p312. 9aed9f2
Charles Oliver Nutter Really fix JRUBY-6361
RbConfig reports wrong OS type on Solaris
zszugyi Calls modify() in select_bang to make sure shared memory is not overw…
wpc JRUBY-6381: java.util.Collection#each should respect to_ary that obje…
…cts defined
Charles Oliver Nutter Fix bad renaming logic for Scala names. 0eaea39
Charles Oliver Nutter Merge in threadsafe autoloading for JRuby 1.6.6.
This has bitten enough people that we're going to try it out on
the jruby-1_6 branch and see how it goes. We really need folks to
test their heavily concurrent + autoloaded applications against
jruby-1_6/ snapshots from
to make sure this all works ok.

The following commits are from nahi/jruby, and probably won't
correlate to commits in JRuby's repository. The command messages
should match the same commits against master.

Squashed commit of the following:

commit 0713375
Author: Hiroshi Nakamura <>
Date:   Thu Jan 19 16:39:03 2012 +0900

    JRUBY-3194: Avoid NameError for concurrent autoload access

    Revert the synchronize change at d7ff5b9.  I wrote 'removing
    unnecessary synchronized block' but I was wrong.

    IAutoloadMethod#load which is defined in removes
    Autoload object from RubyModule#autoloadMap after successful
    autoloading, and it must be done in synchronized block.  If not, other
    Threads could see orphan autoloadMap just between successful loading and
    autoloadMap clean-up by the initial Thread.  This causes NameError for
    constant access.

    PoC project is at [1].  Many thanks to David Kellum who prepared this
    for us!


commit 4531ced
Author: Nick Sieger <>
Date:   Thu Aug 11 16:31:30 2011 -0500

    JRUBY-5987: Fix autoload resolution via IncludedModuleWrapper

commit 93c9bd8
Author: Hiroshi Nakamura <>
Date:   Sat Aug 6 00:32:28 2011 +0900

    2 autoload bug fixes

     * avoid NPE when autoload did not define the constant
     * allow to override autoload with constant definition

    Now it passes CRuby's bootstraptest/test_autoload.rb

commit 17b8177
Author: Hiroshi Nakamura <>
Date:   Mon Aug 1 19:00:20 2011 +0900

    Clean up autoload code.

    Something like refactoring, but it includes some modification such as
    removing unnecessary synchronized block.

    Added comments for Autoload class and related methods.

    In general, autoloadMap must be accessed after checking ConstantMap.
    Checking UNDEF value in constantMap works as a guard. For looking up
    constant, check constantMap first then try to get an Autoload object
    from autoloadMap.  For setting constant, update constantMap first and
    remove an Autoload object from autoloadMap.

    For more details about how we're treating Autoload objects, please see
    comments in this commit.



commit f1b19f0
Author: Hiroshi Nakamura <>
Date:   Fri Jul 29 13:06:49 2011 +0900

    Add specs of threaded autoload.



commit e490ca3
Author: Hiroshi Nakamura <>
Date:   Fri Jul 22 15:13:35 2011 +0900

    Merged autoloadMap at LoadService and autoloadingMap at RubyModule.

    Before CRuby 1.8, autoload only supported toplevel constants. From 1.8,
    it started to support module constants. So there's no need to keep
    autoloadMap in global LoadService.

    I moved the map to RubyModule and merged it with autoloadingMap I added
    for this branch. It helps me adding proper synchronization around
    autoload resources.



commit 67038c6
Author: Hiroshi Nakamura <>
Date:   Tue Jul 19 15:07:47 2011 +0900

    Avoid race condition.

    This sample crashed. Sigh.

    $: << '.'
    loaded_features = $LOADED_FEATURES.dup
    1000.times do
      autoload :C, 'c'
      t1 = { C }
      t2 = { C }
      [t1, t2].each(&:join)
      class Object
        remove_const :C
    puts :OK

    Avoid race condition between looking up autoloadingMap in RubyModule and
    autoloadMap in LoadService. This fix is too ad-hoc and must be refined
    in the future. Moving autoloadMap to RubyModule?



commit e1edbc9
Author: Hiroshi Nakamura <>
Date:   Tue Jul 12 16:20:24 2011 +0900

    Clear autoloading entry in remove_const

    Removing constant while autoloading should behave like overwriting
    constant while autoloading. Of course, it could cause NameError in
    autoloading thread, but it's expected behavior in Ruby.

commit ba1a46b
Author: Hiroshi Nakamura <>
Date:   Tue Jul 12 11:07:38 2011 +0900

    Avoid infinite loop constant lookup

    RubyModule#getConstantFromNoConstMissing() did autoload lookup when the
    defined constant was UNDEF, then tried to detect the defined value at
    the next loop. It caused infinite loop since the constantMap holds UNDEF
    while autoloading in new thread-safe autoloading logic.

    Now resolveUndefConstant() blocks if other thread is autoloading, and
    returns correct value so making it simply return the given value from
    resolveUndefConstant(). I checked all resolveUndefConstant() occurrences
    in JRuby project and found there's no other loops.

    ant test passes!

    ant spec fails with 3 specs but it's from the intended behavir change
    that Module#autoload does not remove the constant from constant table if
    the loaded files does not define it now. The behavior is as same as
    CRuby 1.9, and needed for autoload thread-safety. CRuby 1.8 removes the
    constant, and it's hard to be thread-safe as far as it keeps the current

    I believe this JRuby/CRuby behavior incompatibility on 1.8 mode is OK to
    introduce since the behavior is hard to imagine before trying it so no
    one would depend on the behavior intentionally.



commit c8279206a18e01395be409314cf81f8fdc6cd5b1
Author: Hiroshi Nakamura <>
Date:   Mon Jul 11 13:34:54 2011 +0900

    Make autoload thread-safe (in progress)

    Added autoloadingMap to RubyModule to keep an autoloading state. It
    consists of a RubyThread which invokes autoloading and an Object
    assigned to the autoload constant while autoloading.

    While autoloading, constantMap keeps UNDEF for the constant and
    autoloadingMap keeps the assigned object instead. Constant lookup checks
    if the value in constantMap is UNDEF, and iif it's UNDEF, it checks
    autloadingMap as well.

    It's still in development. For now, it passes
    org.jruby.test.ScriptTestSuite but org.jruby.test.JRubyTestSuite causes
    infinite loop. I'll check later.


Charles Oliver Nutter Fix my idiotic breakage of YAML in 1.9 mode. 234ae03
Charles Oliver Nutter Update to RubyGems 1.8.15. 333c503
Hiro Asari Add a more general-purpose "git run" script. This also takes build fa…
…ilure into account.
Hiro Asari Bring tool/git_bisect_run* scripts up to date with the master branch 7c62c23
Charles Oliver Nutter Fix JRUBY-6384
Seems like either a bad merge or I deleted a line without noticing it.
Charles Oliver Nutter Fix JRUBY-6383
Scala integration breaks with 1.6.6

This has actually been "broken" since 1.6.0, since we were not
defining the symbolic names for any of the $ Scala methods. This
fix adds the symbolic names and leaves the originals intact.
Hiro Asari Fix JRUBY-6386: time.localtime not taking any arguments
Tests will go into RubySpec.
Hiro Asari Merge branch 'jruby-1_6' of into jruby-1_6 4a9e2aa
Hiro Asari Invert branching logic in RubyTime.localtime19() so that branches are…
… narrower in appearance.
Thomas E Enebo Get fallback external from IO if bom| present (note: bom still unimpl…
Hiro Asari Fix JRUBY-6344: Embedded \r should not be treated as end of comment line
Previously, we substituted '\r[^\n]' with '\n', to account for the Classic Mac OS's
newline character. This is year 2012. It seems highly unlikely that anyone would be running JRuby on that OS.
Hiro Asari The change corresponding to efa4931 for ByteArrayLexerSource. ff10454
Charles Oliver Nutter Fix JRUBY-6382
[1.9] Padrino can't generate an app

Looks like another tiny porting bug. Calls to joinAny need to
specify a start index based on the Array's "begin". Fixed for this
case and added an assert.
Thomas E Enebo Update to formal release of jnr-posix 1.1.9 (was temp build before - …
…no functional changes)
Thomas E Enebo Bump for 1.6.6 5673572
Hiro Asari Bumping compile memory. Java 7 u4 seems to run out of heap while comp…
…iling with only 256 MB.

Also bumped jruby.launch.memory and jruby.test.memory.

Hiroshi Nakamura Revert "Avoid circular require caused by rubygems/maven_gemify"
This reverts commit 409c61f.
See JRUBY-6400 and JRUBY-6407.


Hiroshi Nakamura Revert "Revert "Avoid circular require caused by rubygems/maven_gemify""
This reverts commit b3cf679.
See JRUBY-6407.  The correct fix follows.
Hiroshi Nakamura JRUBY-6400, 6407: Fix StackOverflowError under some Gem activation si…

RubyGems seems to expect that we don't invoke custom_require while Gem
spec scanning.  Our JRuby extension in rubygems/defaults/jruby did
'require "jruby/util"' while Gem scanning and it caused circular
custom_require invocation.

Since jruby/util is a small, non invasive library (it defines JRuby
module, JRuby::Util module and some methods of JRuby::Util), this commit
simply moved the 'require "jruby/util"' line at the top of
rubygems/defaults/jruby.rb for loading the library at RubyGems
initialization time.
Charles Oliver Nutter Update 1.9.2 stdlib to pick up URI lazy-init fix. f9c3604
Hiro Asari Attempt to fix JRUBY-6417. Here, we call "to_s" rather than "to_str" …
…on the key value in the option passed to IO.popen
Hiro Asari Bump version to 09e0e17
Hiro Asari Fix JRUBY-6398: java.lang.NullPointerException when executing jruby.exe
When JVM has an unusual default encoding, we fail to boot. Avoid this by falling back on ASCII-8BIT.
David Kellum Avoid warning: statement not reached SecureRandom
The runtime warning here was:

.../ruby/site_ruby/shared/securerandom.rb:61 warning: Statement not reached

and indeed there was a large block of unreachable code.

Signed-off-by: Hiroshi Nakamura <>
Sébastien Le Callonnec Fix for JRUBY-6378
Signed-off-by: Tim Felgentreff <>
Thomas E Enebo JRUBY-6396: Fix strip! for single byte strings passed through mbc cod…
Marcin Mielżyński fix coderange for 1.9 String#sub! eb67481
Thomas E Enebo JRUBY-6433: DRegexp with specific encodings were getting non-strict v…
…ersions in 1.9 mode
Thomas E Enebo JRUBY-6425: StringIO.readline of UTF-8 string will return a ASCII-8BIT d2af6e8
Hiro Asari Spec for JRUBY-6103: allocator undefined for NativeException
Marked pending for now.
Hiro Asari Fix JRUBY-6103: allocator undefined for NativeException by providing …
…a simple allocator for NativeException.
Charles Oliver Nutter Fix classpath: load path entries to properly do a classloader search.

Greg Mefford Resolves Major Bug in Win32OLE in 1.9 mode:… e1da925
Thomas E Enebo Work around non-existent types in ffi (yum win32ole works now) 4195a64
Yoko Harada The same fix as df0de38 in master. Removes path method for 1.9 since …
…path should not be respond_toable on 1.9.
Fix JRUBY-6193 by replacing usage of asprintf() with alloca(3)+snprin…


Charles Oliver Nutter Fix JRUBY-6399
wrong number of arguments (4 for 3) when calling enum_for in 1.9 mode

We were missing the varargs version of Enumerator#initialize in 1.9 mode.
Charles Oliver Nutter Remove unused block args. 423d68d
Charles Oliver Nutter Fix JRUBY-6291: Closing One Stream From IO.popen4 Results in Stream C…
…losed Error When Reading Other Streams

Ben figured this one out. The logic I put in place to ensure the
child process gets nuked for a popen stream was causing it to be
nuked prematurely for popen3/4 streams. I added a "popenSpecial"
boolean to RubyIO, so we know not to do that.
Ben Browning Test for JRUBY-6291: Closing One Stream in IO.popen4 Breaks Reading O…
…ther Streams
Charles Oliver Nutter Fix JRUBY-6434
sprintf does not support name references, like sprintf('%<xyz>s', :xyz => 'abc')

* Added %<foo> support to Sprintf
* Moved %{foo} support from Ruby kernel to Sprintf, since it was
incorrectly matching %<foo> stuff (and was brittle anyway)


Charles Oliver Nutter Additional minor tweaks for JRUBY-6434
* Propagate format string's encoding into key names
* Eliminate useless Ruby-land sprintf def
* Eliminate deprecated call from RubyKernel.printf


Thomas E Enebo 19: dest string was not getting started with proper encoding and code…
Ryan Fowler Might fix JRUBY-5165
Run finishConnect when selecting sockets for write.


Charles Oliver Nutter Additional tweak for JRUBY-5165
* Check isConnectionPending so we don't finishConnect incorrectly.
Charles Oliver Nutter Add backtrace.mask flag to mask .java lines in backtrace. 9f4d431
Revert "Work around non-existent types in ffi (yum win32ole works now)".
This reverts commit d18bbf7.
Thomas E Enebo Add proper values for ffi on 64-bit windows 12f26fe
Thomas E Enebo JRUBY-6404: multiple assignment fails to deconstruct object 21e02d1
Charles Oliver Nutter Remove unnecessary synchronization from RubyModule.calculateName. 6b5478d
Charles Oliver Nutter Fix locale-insensitive test in test_big_decimal. f7e6017
Charles Oliver Nutter Clear RUBYOPT and JRUBY_OPTS env for junit tests, to avoid interference.

Thomas E Enebo Keywords are not valid captures as regexp names c54ba87
Fix JRUBY-6438 by splatting the arrays before passing to the NotFound…
…Error constructor
Charles Oliver Nutter Additional fixes for JRUBY-6434
* Make sprintf pass hash through without wrapping in array
* Fix totally broken KeyError logic
* Handle %<foo><bar> ArgumentError like MRI
* Mask more logic behind is1_9 check
* Remove exclude for MRI TestSprintf#test_named


Felix Rabe

This commit duplicated this section of code - see line R4022 below.

Felix Rabe

This is the duplicate of line R4006. The original was removed in line L4047 below.

Felix Rabe

The original of the duplicated code.

Felix Rabe

You seem to have duplicated a section of code here. See inline comments.

In 1.6.6, this line fails: filename, File::Constants::CREAT | File::Constants::WRONLY, binmode: true

TypeError: can't convert Hash into Integer
    from org/jruby/ `initialize'
    from org/jruby/ `new'

I just found out that the "wb" mode would be exactly equivalent to File::Constants::CREAT | File::Constants::TRUNC | File::Constants::WRONLY, binmode: true anyway (I somehow missed the TRUNC, thus only overwriting beginnings of files on subsequent open/write cycles), and this is an acceptable workaround in my case.


I'd be happy to accept a patch/pull request for any additional cleanup you would like to suggest. This is an ongoing process targeting JRuby 1.7, and I want to finally put our IO/Socket logic in a happy place. I'd definitely like help.

and others added some commits February 15, 2012
Thomas E Enebo JRUBY-6416: JRuby 1.6.6(1.9-mode) freezing in Rails application witho…
…ut any error, when manipulating a String with special characters
Charles Oliver Nutter Fix JRUBY-6456
ThreadLocal Leak in 1.9 Mode w/ Internal Recursive Map

Our code was a direct port of MRI's, and they seem to have the
same issue: no logic clears out the threadlocal map once the
recursive walk is complete. I added an outermost method called
recursiveListOperation that should always be used to wrap the
execRecursive* calls.


Charles Oliver Nutter Additional tweaks for JRUBY-6456
* execRecursiveOuter is always outermost, so add finally logic there
* Add explicit check for recursiveListOperation in execRecursive


Charles Oliver Nutter Avoid calling "expensive" RubyModule.getName just for backtraces. e189467
Thomas E Enebo Be green damn you 2a40e35
Thomas E Enebo Be green damn you 0296e6b
Charles Oliver Nutter Port GzipReader commits from master for JRUBY-6415.
commit 773a155
Author: Charles Oliver Nutter <>
Date:   Mon Jan 9 02:40:33 2012 -0600

    Actually set new bytelists to external encoding in GzipReader.

commit 84e3e3f
Author: Hiroshi Nakamura <>
Date:   Wed Feb 1 13:37:00 2012 +0900

    Fix GzipReader encoding on 1.9 mode (produced encoding == null String)

    It's a fix for "-J-ea pointed out we were creating a bad ByteList with
    no encoding in 1.9 mode..." reported by Tom.

    The actual bug is from 1 line, that I forgot to set default
    externalEncoding to runtime.getDefaultExternalEncoding()
    But the problem is from name confusion.  Use proper names, readEncoding
    and writeEncoding for enc, enc2 in Ruby's IO subsystem.
Thomas E Enebo A CI job tries to use this obvious missing ant target 8581cf3
Thomas E Enebo ci uses this target from ant c26cb4f
Thomas E Enebo More undefined targets 3e9b769
Charles Oliver Nutter Partial fix for JRUBY-6442
TCPSocket#write_nonblock blocks

Only selectable Java channels can be set nonblocking, so this
patch only improves situations for selectable channels. Others
will still just do a blocking write, as before. This patch does at
least get sockets and other selectables to actually do write_nonblock
close to how it's supposed to be done.

Better fix will come with 1.7 IO refactoring, though the non-
selectable channels will still be an issue.
Fix JRUBY-6164. Problem was multiple cleaners on the same data object. 8905123
Charles Oliver Nutter Fix JRUBY-6238
Issues with eval - wrong arguments

module_exec with no args was allowing self to be passed as the sole argument.
Marcin Mielżyński class_variable_get, class_variable_set, remove_class_variable are pub…
…lic in 1.9
Charles Oliver Nutter Fix typo in 1.9-mode class_variable_set binding. 9847379
Charles Oliver Nutter Fix bad expectation in that module_exec passes self.

Thomas E Enebo update pom and use release bytelist-1.0.10.jar b3f8727
Thomas E Enebo Whoops pom update to match new bytelist 43331ce
Thomas E Enebo Update to jcoding 1.0.7 48f2d25
Thomas E Enebo Update to joni 1.1.7 63ca88e
Thomas E Enebo Generic boxed version of squeeze! should still work with no-arg list c43ba85
Tim Felgentreff add explicit endianess format support to Pack util 8231346
Charles Oliver Nutter Damn the torpedos...merge master's zlib to 1.6.
Process followed:

* Refactor RubyZlib into ext.zlib package
* Copy ext.zlib package contents from master
* Copy jzlib from master
* Fix up project/build files
* Fix up imports and 1.6 encoding calls
* Move library from org.jruby.libraries to ext.zlib
* Fix up test_zlib.rb from master
* Fix up spec tags from master

Represents a couple dozen commits from master relating to zlib
fixes, jzlib integration, and encoding work.
Charles Oliver Nutter Use RuntimeMXBean rather than custom propertes for mem/stack errs. 2ce71d5
Thomas E Enebo JRUBY-6463:'foo').strip Leaves Trailing Newline Under 1.9 8879729
Charles Oliver Nutter Raise the WaitWritable version of EAGAIN for write_nonblock.

Charles Oliver Nutter Reduce contention and overhead in object_id allocation. a9e0ec1
Remove synchronization on getObjectIdAccessorForWrite() or getNativeH…
…andleAccessorForWrite(), and defer it to allocateObjectIdAccessor and allocateNativeHandleAccesor, to eliminate contention on the RubyClass in the optimal case where the VariableAccessor has already been allocated.
Add benchmark for multi-threaded 40079f1
Hiroshi Nakamura Refix JRUBY-6208: GzipWriter#write should honor writeEncoding, not re…

Title says all.  The regression spec I added before wrongly used
GzipReader#read() without size parameter.  GzipReader#read() uses the
specified read encoding (it is Encoding.default_external if not
specified) and it hides this bug.
Charles Oliver Nutter Fix JRUBY-928: Java arrays don't inherit from java.lang.Object in Rub…
…ified Java class hierarchy

* After JI has initialized, rewire ArrayJavaProxy superclass to be < (Enumerable) < java.lang.Object.


Conrad Irwin Ignore Binding's line when file is passed to eval
Before this change eval("__LINE__", binding, "file") would return the
current line of the binding; after this change it will return 1.

Spec at jruby/rubyspec@88f3dff#L1R24

Signed-off-by: Charles Oliver Nutter <>
Marcin Mielżyński holy shmoly, why ? 9f3f488
Regen x86_64-windows FFI types.conf 2d41d99
Thomas E Enebo Bump for 1.6.7 3e82bc8
Jeremy Evans

On my machine with 1G of RAM, this commit means I can no longer compile jruby. Switching jruby.launch.memory back to 512M fixes the issue. There is no justification in the commit message for bumping jruby.launch.memory, and jruby builds fine with a value of 512M, so it might be better to revert that part, unless 1G is actually required on some java versions (I'm using 1.7.0b147 on OpenBSD, as that is the latest version in ports).


I'm rather disappointed that compiling jruby base now takes this much memory in Java 8's javac, but that was the reason for this change. I'll poke around and see if I can find any way we can reduce memory use during compile.

dontfidget dontfidget closed this September 03, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.