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: e4ea16addfb5
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 94df350d6e55
Choose a head ref

Commits on Jul 10, 2015

  1. Copy the full SHA
    07987e5 View commit details
  2. Copy the full SHA
    0aad2b4 View commit details

Commits on Jul 16, 2015

  1. Copy the full SHA
    1c3cdaa View commit details
  2. Improvements to MapJavaProxy for rehash and shift. #3142

    * Make the default rehash impl no-op. If the map supports rehash,
      the correct Java method will be bound instead.
    * Make the default shift have a better error explaining that Java
      Map does not generally preserve insertion order.
    headius committed Jul 16, 2015
    Copy the full SHA
    01bc92c View commit details
  3. Mark default java.util.Map rehash and shift as not implemented.

    Allows using respond_to? to check if they do anything. #3142
    headius committed Jul 16, 2015
    Copy the full SHA
    8e87c09 View commit details
  4. Copy the full SHA
    a5dc5b2 View commit details

Commits on Jul 17, 2015

  1. Merge pull request #3127 from jkutner/jruby-1_7

    Added uri to path when using file protocol to chdir
    mkristian committed Jul 17, 2015
    Copy the full SHA
    26d0b20 View commit details

Commits on Jul 21, 2015

  1. Add specs for Date#{<<,prev_year,next_year} around calendar reforms.

    * See #2867.
    Ranjeet Singh authored and eregon committed Jul 21, 2015
    Copy the full SHA
    ec80a32 View commit details
  2. [#2867] modified Date#>> to take calendar reforms under consideration

    - added tests for next month with calendar reform
    - uses solution provided in #1769 comments
    - also fixes issues #1769
    Ranjeet Singh authored and eregon committed Jul 21, 2015
    Copy the full SHA
    40e9140 View commit details
  3. Copy the full SHA
    a8ee690 View commit details
  4. Use iteration count for final size in map. Fixes #3155.

    When the block passed to map makes modifications to the array
    under iteration, we may prematurely finish the map loop due to the
    size changing. However our logic for creating the mapped array
    assumed the new array's size would always be the same as the
    original array's size, leading to an array with null elements.
    This fix uses the iteration count as the final size, so we at
    least know how many elements in the new array were populated.
    
    Note that this behavior is officially undefined; modifying the
    array while performing internal iteration can cause peculiar
    effects across runtimes and potentially across the different
    versions of the same runtime. We add a regression spec here to
    at least make sure we don't produce an invalid array.
    headius committed Jul 21, 2015
    Copy the full SHA
    59fe0bf View commit details
  5. Copy the full SHA
    ff53331 View commit details
  6. Copy the full SHA
    b0dcd91 View commit details
  7. tune proc-to-iface callable matching to do less work

    ... and handle proc's with arity >
    
    than the functional-interface methods parameter count
    kares committed Jul 21, 2015
    Copy the full SHA
    581a815 View commit details
  8. re-arrange proc arity matching

    avoids incorrect ambiguous warning e.g. in case of :
    `java.io.File.new('.').listFiles { |pathname| ... }`
    kares committed Jul 21, 2015
    Copy the full SHA
    7d24ec4 View commit details
  9. Copy the full SHA
    e7fcfd6 View commit details
  10. [ji] fix missing local assing + do not match duckables when primitiva…

    …ble/assignable found
    
    this avoids an incorrect ambiguous warning when matching proc-to-iface methods e.g. : 
    `executor_spec.rb:22 warning: ambiguous Java methods found, using submit(java.util.concurrent.Callable)`
    
    ... also exploded the 3 level nested for loop to be only 2 levels
    kares committed Jul 21, 2015
    Copy the full SHA
    9599674 View commit details
  11. forgot to initialize the mostSpecificArity for the first list element…

    … (thus not matching)
    kares committed Jul 21, 2015
    Copy the full SHA
    120e0ab View commit details
  12. a unit test since we can not influence getMethods order (closer to fa…

    …ilure at travis-ci)
    kares committed Jul 21, 2015
    Copy the full SHA
    623a6f1 View commit details
  13. [ji] travis showcased negative proc-to-iface arity (still) dependent …

    …on getMethods order
    kares committed Jul 21, 2015
    Copy the full SHA
    3d7ac8f View commit details
  14. travis showcased we did not handle all negative proc-to-iface arity c…

    …ases correctly
    
    ... they were still dependent on getMethods order (travis-ci failures in **spec:ji**)
    kares committed Jul 21, 2015
    Copy the full SHA
    e20d6c7 View commit details
  15. Copy the full SHA
    a1a99aa View commit details

Commits on Jul 22, 2015

  1. Fix RubyRange#initialize_copy mistakenly erroring on #dup'ing a range.

    …Closes #3163
    
    MRI checks if the EXCL flag is Qnil to see if the range has been initalized. This doesn't work
    in Java because we use a boolean which can't have a nil value. Instead, introduce a new isInited
    flag which is used to track the initialization state of the Range, which corrently permits #dup
    while not permitting reinitialization of a Range.
    cheald committed Jul 22, 2015
    Copy the full SHA
    ede3cf6 View commit details

Commits on Jul 23, 2015

  1. Copy the full SHA
    0590488 View commit details
  2. [Truffle] No need to pass the Ruby thread in SafepointManager.

    * The currentThread ThreadLocal will tell us anyway.
    eregon committed Jul 23, 2015
    Copy the full SHA
    be414cf View commit details
  3. Copy the full SHA
    a766ce8 View commit details
  4. Copy the full SHA
    eb332f2 View commit details
  5. [Truffle] Full Kernel#inspect.

    * Just use #to_s if you need to print an object before bootstrap/kernel.rb is loaded.
    eregon committed Jul 23, 2015
    Copy the full SHA
    c83de9b View commit details
  6. Copy the full SHA
    5afcafa View commit details
  7. Merge pull request #3165 from cheald/fix_range

    Fix RubyRange#initialize_copy mistakenly erroring on #dup'ing a range
    enebo committed Jul 23, 2015
    Copy the full SHA
    a3cd23d View commit details
  8. [Truffle] 2**63-1 ms is more than enough.

    * It is about 292 471 208 years.
    eregon committed Jul 23, 2015
    Copy the full SHA
    c7acd56 View commit details
  9. Make sure the thread is actually waiting in ConditionVariable specs

    * The thread can also have the status "sleep" very shortly when calling Mutex#lock.
    eregon committed Jul 23, 2015
    Copy the full SHA
    acb9129 View commit details
  10. Make sure threads are actually waiting in other ConditionVariable specs

    * The thread can also have the status "sleep" very shortly when calling Mutex#lock.
    eregon committed Jul 23, 2015
    Copy the full SHA
    8c884c0 View commit details
  11. Copy the full SHA
    31d5310 View commit details
  12. Copy the full SHA
    7d8c779 View commit details
  13. [Truffle] remove broken case from pack-pack Hash merge

    It was giving bad rusults for cases like:
    {a:1, b:2}.merge(b:3) # => {:a=>1, :b=>2}
    pitr-ch committed Jul 23, 2015
    Copy the full SHA
    90aede3 View commit details
  14. [Truffle] Add printableBacktrace to DebugOperations

    * to be able to get the backtrace in debuger
    pitr-ch committed Jul 23, 2015
    Copy the full SHA
    01c1e58 View commit details
  15. Copy the full SHA
    9f1e745 View commit details
  16. Copy the full SHA
    41a8a10 View commit details
  17. Copy the full SHA
    afc6ef2 View commit details
  18. Copy the full SHA
    f7107f7 View commit details
  19. Copy the full SHA
    9db38b9 View commit details
  20. Copy the full SHA
    8930cdd View commit details
  21. Copy the full SHA
    03ec251 View commit details
  22. [Truffle] code formatting

    pitr-ch committed Jul 23, 2015
    Copy the full SHA
    a4394db View commit details
  23. [Truffle] move our Thread#raise implementation

    from core/rubinius/boostrap/thread to core/rubinius/api/shims/thread
    pitr-ch committed Jul 23, 2015
    Copy the full SHA
    2fb0d1c View commit details
  24. Copy the full SHA
    d5271b3 View commit details
  25. Copy the full SHA
    486aa2d View commit details
  26. Copy the full SHA
    3155ce1 View commit details
  27. [Truffle] Fix license years

    pitr-ch committed Jul 23, 2015
    Copy the full SHA
    e6abeaa View commit details
Showing 806 changed files with 14,428 additions and 16,732 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -7,6 +7,8 @@ sudo: false
# - $HOME/.m2

before_script:
- export MAVEN_SKIP_RC=true
- export MAVEN_OPTS="-Xmx512m -XX:MaxPermSize=192m"
- unset GEM_PATH GEM_HOME IRBRC JRUBY_OPTS
- "export PATH=`pwd`/bin:$PATH"
- echo $HOME
@@ -77,7 +79,6 @@ matrix:
fast_finish: true
allow_failures:
- env: COMMAND=test/truffle/run.sh
- env: COMMAND=tool/truffle-findbugs.sh


branches:
22 changes: 22 additions & 0 deletions BSDL
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Copyright (C) 1993-2013 Yukihiro Matsumoto. All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
80 changes: 18 additions & 62 deletions COPYING
Original file line number Diff line number Diff line change
@@ -3,17 +3,18 @@ under a tri EPL/GPL/LGPL license. You can use it, redistribute it
and/or modify it under the terms of the:

Eclipse Public License version 1.0
OR
GNU General Public License version 2
OR
GNU Lesser General Public License version 2.1

build_lib/bytelist.jar (http://github.com/jruby/bytelist),
build_lib/yydebug.jar (http://svn.codehaus.org/jruby/trunk/jay/yydebug)
bytelist (http://github.com/jruby/bytelist),
yydebug (http://svn.codehaus.org/jruby/trunk/jay/yydebug)
are released under the same copyright/license.

Some additional libraries distributed with JRuby are not covered by
JRuby's licence. Most of these libraries and their licenses are listed
below. Also see LICENSE.RUBY for most files found in lib/ruby/1.8,
lib/ruby/1.9, and lib/ruby/site_ruby/1.8/rubygems*.
below. Also see LICENSE.RUBY for most files found in lib/ruby/stdlib.

bench/rails/public/javascripts/* are distributed under the MIT
license, and have the following copyrights:
@@ -36,75 +37,30 @@ lib/ruby/1.9, and lib/ruby/site_ruby/1.8/rubygems*.

Copyright (c) 2003, 2004 Jim Weirich

build_lib/*asm*jar (http://asm.objectweb.org) are distributed under the BSD license.
asm (http://asm.objectweb.org) is distributed under the BSD license.

build_lib/apt-mirror-api.jar, build_lib/bnd-0.0.249.jar,
build_lib/commons-logging-1.1.1.jar, build_lib/joda-time-1.6.2.jar,
BSF and ant are distributed under the Apache Software License,
Version 1.1 (license file inside the jars).

build_lib/jcodings.jar (http://github.com/jruby/jcodings) and
build_lib/joni.jar (http://github.com/jruby/joni) are distributed
jcodings (http://github.com/jruby/jcodings) and
joni (http://github.com/jruby/joni) are distributed
under the MIT license.

build_lib/jnr-constants.jar (http://github.com/jnr/jnr-constants),
build_lib/jarjar-1.0rc8.jar (http://code.google.com/p/jarjar),
build_lib/joda-time-1.6.2.jar (http://joda-time.sourceforge.net),
build_lib/jffi*jar (https://github.com/jnr/jffi),
build_lib/jnr-ffi.jar (https://github.com/jnr/jnr-jffi),
build_lib/jnr-netdb.jar (http://github.com/jnr/jnr-netdb),
build_lib/dynalang-0.3.jar (http://dynalang.sourceforge.net),
build_lib/nailgun-0.7.1.jar and tool/nailgun/ng.exe
(http://martiansoftware.com/nailgun) are distributed under the
ant (http://ant.apache.org/),
jnr-constants (http://github.com/jnr/jnr-constants),
joda-time (http://joda-time.sourceforge.net),
jffi (https://github.com/jnr/jffi),
jnr-ffi (https://github.com/jnr/jnr-jffi),
jnr-enxio (https://github.com/jnr/jnr-enxio),
jnr-unixsocket (https://github.com/jnr/jnr-unixsocket),
jnr-netdb (http://github.com/jnr/jnr-netdb), and
nailgun (http://martiansoftware.com/nailgun) are distributed under the
Apache License version 2.0.

build_lib/emma*jar (http://emma.sourceforge.net) and
build_lib/junit.jar (http://www.junit.org) are distributed under the
Common Public License v1.0.

build_lib/jline-* (http://jline.sourceforge.net) is distributed
under the following license:

Redistribution and use in source and binary forms, with or
without modification, are permitted provided that the following
conditions are met:

Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.

Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with
the distribution.

Neither the name of JLine nor the names of its contributors
may be used to endorse or promote products derived from this
software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
OF THE POSSIBILITY OF SUCH DAMAGE.

build_lib/jsr292-mock.jar (http://code.google.com/p/jvm-language-runtime)
jsr292-mock (http://code.google.com/p/jvm-language-runtime)
distributed under the LGPL license. It is only used as a compile-time mock
for Java 7-only features.

Bouncycastle is released under the MIT license, and is Copyright (c)
2000 - 2006 The Legion Of The Bouncy Castle.

The "yecht" library is Copyright (c) 2009-2011 Ola Bini, and released
under the MIT license.

The Rubinius API implementation in truffle/src/main/ruby/core/rubinius/api
is copyright (c) 2011, Evan Phoenix, and released under the 3-clause BSD license.

8 changes: 4 additions & 4 deletions LICENSE.RUBY
Original file line number Diff line number Diff line change
@@ -2,8 +2,8 @@ JRuby distributes some ruby modules which are distributed under Ruby
license:

Ruby is copyrighted free software by Yukihiro Matsumoto <matz@netlab.jp>.
You can redistribute it and/or modify it under either the terms of the GPL
(see the file GPL), or the conditions below:
You can redistribute it and/or modify it under either the terms of the
2-clause BSDL (see the file BSDL), or the conditions below:

1. You may make and give away verbatim copies of the source form of the
software without restriction, provided that you duplicate all of the
@@ -47,9 +47,9 @@ You can redistribute it and/or modify it under either the terms of the GPL
For the list of those files and their copying conditions, see the
file LEGAL.

5. The scripts and library files supplied as input to or produced as
5. The scripts and library files supplied as input to or produced as
output from the software do not automatically fall under the
copyright of the software, but belong to whomever generated them,
copyright of the software, but belong to whomever generated them,
and may be sold commercially, and may be aggregated with this
software.

2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
9.0.0.0-SNAPSHOT
9.0.1.0-SNAPSHOT
2 changes: 1 addition & 1 deletion core/pom.xml
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ DO NOT MODIFIY - GENERATED CODE
<parent>
<groupId>org.jruby</groupId>
<artifactId>jruby-parent</artifactId>
<version>9.0.0.0-SNAPSHOT</version>
<version>9.0.1.0-SNAPSHOT</version>
</parent>
<artifactId>jruby-core</artifactId>
<name>JRuby Core</name>
32 changes: 19 additions & 13 deletions core/src/main/java/org/jruby/Ruby.java
Original file line number Diff line number Diff line change
@@ -93,7 +93,6 @@
import org.jruby.internal.runtime.GlobalVariables;
import org.jruby.internal.runtime.ThreadService;
import org.jruby.internal.runtime.ValueAccessor;
import org.jruby.internal.runtime.methods.CallConfiguration;
import org.jruby.internal.runtime.methods.DynamicMethod;
import org.jruby.internal.runtime.methods.JavaMethod;
import org.jruby.ir.Compiler;
@@ -177,6 +176,7 @@
import java.security.SecureRandom;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.EnumMap;
import java.util.EnumSet;
import java.util.HashMap;
@@ -1381,7 +1381,7 @@ private void initRoot() {

// In 1.9 and later, Kernel.gsub is defined only when '-p' or '-n' is given on the command line
if (config.getKernelGsubDefined()) {
kernel.addMethod("gsub", new JavaMethod(kernel, Visibility.PRIVATE, CallConfiguration.FrameFullScopeNone) {
kernel.addMethod("gsub", new JavaMethod(kernel, Visibility.PRIVATE) {

@Override
public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject[] args, Block block) {
@@ -2930,8 +2930,6 @@ public void compileAndLoadFile(String filename, InputStream in, boolean wrap) {
InputStream readStream = in;

Script script = null;
ScriptAndCode scriptAndCode = null;
String className = null;

try {
// read full contents of file, hash it, and try to load that class first
@@ -2943,12 +2941,12 @@ public void compileAndLoadFile(String filename, InputStream in, boolean wrap) {
}
buffer = baos.toByteArray();
String hash = JITCompiler.getHashForBytes(buffer);
className = JITCompiler.RUBY_JIT_PREFIX + ".FILE_" + hash;
final String className = JITCompiler.RUBY_JIT_PREFIX + ".FILE_" + hash;

// FIXME: duplicated from ClassCache
Class contents;
try {
contents = jrubyClassLoader.loadClass(className);
contents = getJRubyClassLoader().loadClass(className);
if (RubyInstanceConfig.JIT_LOADING_DEBUG) {
LOG.info("found jitted code for " + filename + " at class: " + className);
}
@@ -2974,7 +2972,9 @@ public void compileAndLoadFile(String filename, InputStream in, boolean wrap) {
// script was not found in cache above, so proceed to compile
RootNode scriptNode = (RootNode) parseFile(readStream, filename, null);
if (script == null) {
scriptAndCode = tryCompile(scriptNode, new ClassDefiningJRubyClassLoader(jrubyClassLoader));
ScriptAndCode scriptAndCode = tryCompile(scriptNode,
new ClassDefiningJRubyClassLoader(getJRubyClassLoader())
);
if (scriptAndCode != null) script = scriptAndCode.script();
}

@@ -3307,7 +3307,7 @@ public void tearDown(boolean systemExit) {

getSelectorPool().cleanup();

tearDownClassLoader();
// NOTE: its intentional that we're not doing releaseClassLoader();

if (config.isProfilingEntireRun()) {
// not using logging because it's formatted
@@ -3332,10 +3332,16 @@ public void tearDown(boolean systemExit) {
}
}

private void tearDownClassLoader() {
if (getJRubyClassLoader() != null) {
getJRubyClassLoader().tearDown(isDebug());
}
/**
* By default {@link #tearDown(boolean)} does not release the class-loader's
* resources as threads might be still running accessing the classes/packages
* even after the runtime has been torn down.
*
* This method exists to handle such cases, e.g. with embedded uses we always
* release the runtime loader but not otherwise - you should do that manually.
*/
public void releaseClassLoader() {
if ( jrubyClassLoader != null ) getJRubyClassLoader().close();
}

/**
@@ -5105,7 +5111,7 @@ public void addToObjectSpace(boolean useObjectSpace, IRubyObject object) {
*
* Access must be synchronized.
*/
private WeakHashMap<RubyString, WeakReference<RubyString>> dedupMap = new WeakHashMap<RubyString, WeakReference<RubyString>>();
private Map<RubyString, WeakReference<RubyString>> dedupMap = Collections.synchronizedMap(new WeakHashMap<RubyString, WeakReference<RubyString>>());

private static final AtomicInteger RUNTIME_NUMBER = new AtomicInteger(0);
private final int runtimeNumber = RUNTIME_NUMBER.getAndIncrement();
42 changes: 42 additions & 0 deletions core/src/main/java/org/jruby/RubyBasicObject.java
Original file line number Diff line number Diff line change
@@ -56,6 +56,7 @@
import org.jruby.runtime.Visibility;

import static org.jruby.anno.FrameField.*;
import static org.jruby.runtime.Helpers.invokeChecked;
import static org.jruby.runtime.Visibility.*;
import org.jruby.exceptions.RaiseException;
import org.jruby.runtime.Arity;
@@ -73,6 +74,7 @@
import org.jruby.util.unsafe.UnsafeHolder;

import static org.jruby.runtime.Helpers.invokedynamic;
import static org.jruby.runtime.invokedynamic.MethodNames.HASH;
import static org.jruby.runtime.invokedynamic.MethodNames.OP_EQUAL;
import static org.jruby.runtime.invokedynamic.MethodNames.OP_CMP;
import static org.jruby.runtime.invokedynamic.MethodNames.EQL;
@@ -2822,6 +2824,46 @@ public RubyArray instance_variables19(ThreadContext context) {
return array;
}

/**
* This method is just a wrapper around the Ruby "==" method,
* provided so that RubyObjects can be used as keys in the Java
* HashMap object underlying RubyHash.
*/
@Override
public boolean equals(Object other) {
if (other == this) return true;

if (other instanceof IRubyObject) {
IRubyObject equals = invokeChecked(getRuntime().getCurrentContext(), this, "==", (IRubyObject)other);
if (equals == null) return false;
return equals.isTrue();
}

return false;
}

/**
* Override the Object#hashCode method to make sure that the Ruby
* hash is actually used as the hashcode for Ruby objects. If the
* Ruby "hash" method doesn't return a number, the Object#hashCode
* implementation will be used instead.
*/
@Override
public int hashCode() {
IRubyObject hashValue = invokeChecked(getRuntime().getCurrentContext(), this, "hash");
if (hashValue == null) return super.hashCode();
if (hashValue instanceof RubyFixnum) return (int) RubyNumeric.fix2long(hashValue);
return nonFixnumHashCode(hashValue);
}

protected static int nonFixnumHashCode(IRubyObject hashValue) {
RubyInteger integer = hashValue.convertToInteger();
if (integer instanceof RubyBignum) {
return integer.getBigIntegerValue().intValue();
}
return (int) integer.getLongValue();
}

/**
* Checks if the name parameter represents a legal instance variable name, and otherwise throws a Ruby NameError
*/
Loading