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

Commits on Aug 15, 2017

  1. [ji] move JRuby.runtime retrieval into native

    ... since we do not want to initialize nil's Java proxy class 
    (otherwise ObjectSpace might have weird classes such as UNDEF's)
    kares committed Aug 15, 2017
    Copy the full SHA
    bedab97 View commit details
  2. [ji] JRuby.reference0 was meant to not use the proxy-cache at all

    ... JRuby.runtime is supposed to be doing `reference0(runtime)`
    kares committed Aug 15, 2017
    Copy the full SHA
    c234958 View commit details
Showing with 15 additions and 22 deletions.
  1. +9 −15 core/src/main/java/org/jruby/ext/jruby/JRubyLibrary.java
  2. +6 −7 core/src/main/ruby/jruby/jruby.rb
24 changes: 9 additions & 15 deletions core/src/main/java/org/jruby/ext/jruby/JRubyLibrary.java
Original file line number Diff line number Diff line change
@@ -30,18 +30,15 @@
***** END LICENSE BLOCK *****/
package org.jruby.ext.jruby;

import org.jruby.AbstractRubyMethod;
import org.jruby.Ruby;
import org.jruby.RubyClass;
import org.jruby.RubyModule;
import org.jruby.anno.JRubyMethod;
import org.jruby.anno.JRubyModule;
import org.jruby.internal.runtime.methods.DynamicMethod;
import org.jruby.java.proxies.JavaProxy;
import org.jruby.javasupport.Java;
import org.jruby.javasupport.JavaObject;
import org.jruby.javasupport.JavaUtil;
import org.jruby.runtime.Helpers;
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.runtime.load.Library;
@@ -78,8 +75,7 @@ public void load(Ruby runtime, boolean wrap) {
public static class JRubyConfig {
@JRubyMethod(name = "rubygems_disabled?")
public static IRubyObject rubygems_disabled_p(ThreadContext context, IRubyObject self) {
return context.runtime.newBoolean(
context.runtime.getInstanceConfig().isDisableGems());
return context.runtime.newBoolean(context.runtime.getInstanceConfig().isDisableGems());
}
}

@@ -90,20 +86,21 @@ public static IRubyObject rubygems_disabled_p(ThreadContext context, IRubyObject
*/
@JRubyMethod(module = true)
public static IRubyObject reference(ThreadContext context, IRubyObject recv, IRubyObject obj) {
Ruby runtime = context.runtime;

return Java.getInstance(runtime, obj, false);
return Java.getInstance(context.runtime, obj, false);
}

/**
* Wrap the given object as in Java integration and return the wrapper. This
* version does not use ObjectProxyCache.
* Wrap the given object as in Java integration and return the wrapper.
* This version does not use ObjectProxyCache.
*/
@JRubyMethod(module = true)
public static IRubyObject reference0(ThreadContext context, IRubyObject recv, IRubyObject obj) {
Ruby runtime = context.runtime;
return Java.wrapJavaObject(context.runtime, obj);
}

return Java.getInstance(runtime, obj);
@JRubyMethod(module = true)
public static IRubyObject runtime(ThreadContext context, IRubyObject recv) {
return Java.wrapJavaObject(context.runtime, context.runtime); // context.nil.getRuntime()
}

/**
@@ -140,8 +137,5 @@ public static IRubyObject dereference(ThreadContext context, IRubyObject recv, I
public static IRubyObject identity_hash(ThreadContext context, IRubyObject recv, IRubyObject obj) {
return context.runtime.newFixnum(System.identityHashCode(obj));
}

public static class MethodExtensions {

}
}
13 changes: 6 additions & 7 deletions core/src/main/ruby/jruby/jruby.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
module JRuby
class << self
# Get a Java integration reference to the given object
# Get a Java integration reference to the given (Ruby) object.
# @note implemented in *org.jruby.ext.jruby.JRubyLibrary*
def reference(obj); end

# Turn a Java integration reference to a Ruby object back into a normal Ruby
# object reference.
# Turn a Java integration reference (to a Ruby object) back into a normal Ruby object reference.
# @note implemented in *org.jruby.ext.jruby.JRubyLibrary*
def dereference(obj); end

# Get the current JRuby runtime.
def runtime
# reference nil, since it is guaranteed to be a normal object
reference0(nil).runtime
end
# @note implemented in *org.jruby.ext.jruby.JRubyLibrary*
def runtime; end

# Run the provided (required) block with the "global runtime" set to the
# current runtime, for libraries that expect to operate against the global