Skip to content

Commit

Permalink
Merge branch 'jruby-9.1'
Browse files Browse the repository at this point in the history
* jruby-9.1:
  [ji] avoid NPE when Java collection is not clone-able (the "usual" way)
  Alias must pass its name, not given name.
  further align DynamicMethod.name now being final and not-null
  upgrade jruby-readline version
  upgrade jar-dependencies version
  Exclude `#test_windows_1255` from our tests
kares committed Feb 8, 2018

Verified

This commit was signed with the committer’s verified signature. The key has expired.
nomadium Miguel Landaeta
2 parents bc08d1d + edd18dd commit 8bd3256
Showing 24 changed files with 59 additions and 58 deletions.
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/Ruby.java
Original file line number Diff line number Diff line change
@@ -1353,7 +1353,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) {
kernel.addMethod("gsub", new JavaMethod(kernel, Visibility.PRIVATE, "gsub") {

@Override
public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject[] args, Block block) {
4 changes: 2 additions & 2 deletions core/src/main/java/org/jruby/RubyKernel.java
Original file line number Diff line number Diff line change
@@ -103,8 +103,8 @@ public static class MethodMissingMethod extends JavaMethodNBlock {
private final Visibility visibility;
private final CallType callType;

public MethodMissingMethod(RubyModule implementationClass, Visibility visibility, CallType callType) {
super(implementationClass, Visibility.PRIVATE);
MethodMissingMethod(RubyModule implementationClass, Visibility visibility, CallType callType) {
super(implementationClass, Visibility.PRIVATE, "method_missing");

this.callType = callType;
this.visibility = visibility;
4 changes: 2 additions & 2 deletions core/src/main/java/org/jruby/RubyModule.java
Original file line number Diff line number Diff line change
@@ -1889,8 +1889,8 @@ public final IRubyObject newMethod(IRubyObject receiver, final String methodName

public static class RespondToMissingMethod extends JavaMethod.JavaMethodNBlock {
final CallSite site;
public RespondToMissingMethod(RubyModule implClass, Visibility vis, String methodName) {
super(implClass, vis);
public RespondToMissingMethod(RubyModule implClass, Visibility visibility, String methodName) {
super(implClass, visibility, methodName);

setParameterList(REST);
site = new FunctionalCachingCallSite(methodName);
3 changes: 1 addition & 2 deletions core/src/main/java/org/jruby/ext/pathname/RubyPathname.java
Original file line number Diff line number Diff line change
@@ -136,8 +136,7 @@ public IRubyObject[] addArg(IRubyObject[] args, RubyString path) {
private static void defineDelegateMethodsGeneric(RubyClass cPathname, final RubyModule klass,
final ReturnValueMapper mapper, final AddArg addArg, String... methods) {
for (String method : methods) {
cPathname.addMethod(method, new JavaMethod.JavaMethodNBlock(cPathname,
Visibility.PUBLIC) {
cPathname.addMethod(method, new JavaMethod.JavaMethodNBlock(cPathname, Visibility.PUBLIC, method) {
@Override
public IRubyObject call(ThreadContext context, IRubyObject _self, RubyModule clazz,
String name, IRubyObject[] args, Block block) {
Original file line number Diff line number Diff line change
@@ -276,13 +276,14 @@ protected static void checkArgumentCount(JavaMethod method, ThreadContext contex

// promise to implement N with block
public static abstract class JavaMethodNBlock extends JavaMethod {
public JavaMethodNBlock(RubyModule implementationClass, Visibility visibility) {
super(implementationClass, visibility);
}
public JavaMethodNBlock(RubyModule implementationClass, Visibility visibility, String name) {
super(implementationClass, visibility, name);
}
@Deprecated
public JavaMethodNBlock(RubyModule implementationClass, Visibility visibility) {
super(implementationClass, visibility);
}
@Deprecated
public JavaMethodNBlock(RubyModule implementationClass, Visibility visibility, CallConfiguration callConfig) {
super(implementationClass, visibility);
}
Original file line number Diff line number Diff line change
@@ -17,8 +17,10 @@

public final class ConstructorInvoker extends RubyToJavaInvoker {

public ConstructorInvoker(RubyModule host, List<Constructor> ctors) {
super(host, setAccessible( ctors.toArray(new Constructor[ctors.size()]) ) );
private static final Constructor[] EMPTY_ARRAY = new Constructor[0];

public ConstructorInvoker(RubyModule host, List<Constructor> ctors, String name) {
super(host, setAccessible(ctors.toArray(EMPTY_ARRAY)), name);
}

@Override
Original file line number Diff line number Diff line change
@@ -13,12 +13,12 @@
import org.jruby.util.ArraySupport;

public final class InstanceMethodInvoker extends MethodInvoker {
public InstanceMethodInvoker(RubyModule host, List<Method> methods) {
super(host, methods);
public InstanceMethodInvoker(RubyModule host, List<Method> methods, String name) {
super(host, methods, name);
}

public InstanceMethodInvoker(RubyModule host, Method method) {
super(host, method);
public InstanceMethodInvoker(RubyModule host, Method method, String name) {
super(host, method, name);
}

@Override
10 changes: 6 additions & 4 deletions core/src/main/java/org/jruby/java/invokers/MethodInvoker.java
Original file line number Diff line number Diff line change
@@ -10,12 +10,14 @@

public abstract class MethodInvoker extends RubyToJavaInvoker {

MethodInvoker(RubyModule host, List<Method> methods) {
super(host, setAccessible( methods.toArray(new Method[methods.size()]) ) );
private static final Method[] EMPTY_ARRAY = new Method[0];

MethodInvoker(RubyModule host, List<Method> methods, String name) {
super(host, setAccessible(methods.toArray(EMPTY_ARRAY)), name);
}

MethodInvoker(RubyModule host, Method method) {
super(host, setAccessible(method));
MethodInvoker(RubyModule host, Method method, String name) {
super(host, setAccessible(method), name);
}

@Override
Original file line number Diff line number Diff line change
@@ -71,8 +71,8 @@ public abstract class RubyToJavaInvoker<T extends JavaCallable> extends JavaMeth
private final Ruby runtime;

@SuppressWarnings("unchecked") // NULL_CACHE
RubyToJavaInvoker(RubyModule host, Member member) {
super(host, Visibility.PUBLIC);
RubyToJavaInvoker(RubyModule host, Member member, String name) {
super(host, Visibility.PUBLIC, name);
this.runtime = host.getRuntime();

final T callable;
@@ -97,8 +97,8 @@ public abstract class RubyToJavaInvoker<T extends JavaCallable> extends JavaMeth
}

@SuppressWarnings("unchecked") // NULL_CACHE
RubyToJavaInvoker(RubyModule host, Member[] members) {
super(host, Visibility.PUBLIC);
RubyToJavaInvoker(RubyModule host, Member[] members, String name) {
super(host, Visibility.PUBLIC, name);
this.runtime = host.getRuntime();

// initialize all the callables for this method
Original file line number Diff line number Diff line change
@@ -15,13 +15,13 @@ public final class SingletonMethodInvoker extends MethodInvoker {

private final Object singleton;

public SingletonMethodInvoker(Object singleton, RubyClass host, List<Method> methods) {
super(host, methods);
public SingletonMethodInvoker(Object singleton, RubyClass host, List<Method> methods, String name) {
super(host, methods, name);
this.singleton = singleton;
}

public SingletonMethodInvoker(Object singleton, RubyClass host, Method method) {
super(host, method);
public SingletonMethodInvoker(Object singleton, RubyClass host, Method method, String name) {
super(host, method, name);
this.singleton = singleton;
}

Original file line number Diff line number Diff line change
@@ -14,16 +14,12 @@

public final class StaticMethodInvoker extends MethodInvoker {

public StaticMethodInvoker(RubyClass host, List<Method> methods) {
super(host, methods);
public StaticMethodInvoker(RubyClass host, List<Method> methods, String name) {
super(host, methods, name);
}

public StaticMethodInvoker(RubyClass host, Method method) {
super(host, method);
}

public StaticMethodInvoker(RubyModule host, Method method) {
super(host, method);
public StaticMethodInvoker(RubyModule host, Method method, String name) {
super(host, method, name);
}

@Override
Original file line number Diff line number Diff line change
@@ -41,7 +41,7 @@ private static final class InitializeMethod extends org.jruby.internal.runtime.m

private final CallSite jcreateSite = MethodIndex.getFunctionalCallSite("__jcreate!");

InitializeMethod(final RubyClass clazz) { super(clazz, Visibility.PRIVATE); }
InitializeMethod(final RubyClass clazz) { super(clazz, Visibility.PRIVATE, "initialize"); }

@Override
public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject[] args, Block block) {
@@ -92,7 +92,7 @@ private static final class NewMethod extends org.jruby.internal.runtime.methods.
final DynamicMethod newMethod;

NewMethod(final RubyClass clazz) {
super(clazz, Visibility.PUBLIC);
super(clazz, Visibility.PUBLIC, "new");
newMethod = clazz.searchMethod("new");
}

Original file line number Diff line number Diff line change
@@ -78,7 +78,7 @@ public static IRubyObject implement(ThreadContext context, IRubyObject self, IRu
private static class DummyMethodImpl extends org.jruby.internal.runtime.methods.JavaMethod {

DummyMethodImpl(RubyModule targetModule) {
super(targetModule, Visibility.PUBLIC);
super(targetModule, Visibility.PUBLIC, ""); // NOTE: maybe dummy method should not be shared
}

@Override
12 changes: 6 additions & 6 deletions core/src/main/java/org/jruby/java/proxies/JavaProxy.java
Original file line number Diff line number Diff line change
@@ -445,9 +445,9 @@ private Method getMethod(ThreadContext context, String name, Class... argTypes)

private MethodInvoker getMethodInvoker(Method method) {
if (Modifier.isStatic(method.getModifiers())) {
return new StaticMethodInvoker(metaClass.getMetaClass(), method);
return new StaticMethodInvoker(metaClass.getMetaClass(), method, method.getName());
} else {
return new InstanceMethodInvoker(metaClass, method);
return new InstanceMethodInvoker(metaClass, method, method.getName());
}
}

@@ -623,12 +623,12 @@ public static IRubyObject java_alias(ThreadContext context, IRubyObject clazz, I
final MethodInvoker invoker;

if ( Modifier.isStatic( method.getModifiers() ) ) {
invoker = new StaticMethodInvoker(proxyClass.getMetaClass(), method);
invoker = new StaticMethodInvoker(proxyClass.getMetaClass(), method, newNameStr);
// add alias to meta
proxyClass.getSingletonClass().addMethod(newNameStr, invoker);
}
else {
invoker = new InstanceMethodInvoker(proxyClass, method);
invoker = new InstanceMethodInvoker(proxyClass, method, newNameStr);
proxyClass.addMethod(newNameStr, invoker);
}

@@ -646,11 +646,11 @@ private static AbstractRubyMethod getRubyMethod(ThreadContext context, IRubyObje
final String prettyName = name + CodegenUtils.prettyParams(argTypesClasses);

if ( Modifier.isStatic( method.getModifiers() ) ) {
MethodInvoker invoker = new StaticMethodInvoker(proxyClass, method);
MethodInvoker invoker = new StaticMethodInvoker(proxyClass, method, name);
return RubyMethod.newMethod(proxyClass, prettyName, proxyClass, name, invoker, clazz);
}

MethodInvoker invoker = new InstanceMethodInvoker(proxyClass, method);
MethodInvoker invoker = new InstanceMethodInvoker(proxyClass, method, name);
return RubyUnboundMethod.newUnboundMethod(proxyClass, prettyName, proxyClass, name, invoker);
}

8 changes: 4 additions & 4 deletions core/src/main/java/org/jruby/javasupport/Java.java
Original file line number Diff line number Diff line change
@@ -498,7 +498,7 @@ else if ( clazz == Object.class ) {
// solved here by adding an exception-throwing "inherited"
if ( Modifier.isFinal(clazz.getModifiers()) ) {
final String clazzName = clazz.getCanonicalName();
proxy.getMetaClass().addMethod("inherited", new org.jruby.internal.runtime.methods.JavaMethod(proxy, PUBLIC) {
proxy.getMetaClass().addMethod("inherited", new org.jruby.internal.runtime.methods.JavaMethod(proxy, PUBLIC, "inherited") {
@Override
public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject[] args, Block block) {
throw context.runtime.newTypeError("can not extend final Java class: " + clazzName);
@@ -1052,7 +1052,7 @@ private static boolean bindJavaPackageOrClassMethod(final RubyModule parentPacka
}

final RubyClass singleton = parentPackage.getSingletonClass();
singleton.addMethod(name.intern(), new JavaAccessor(singleton, packageOrClass, parentPackage));
singleton.addMethod(name.intern(), new JavaAccessor(singleton, packageOrClass, parentPackage, name));
return true;
}

@@ -1061,8 +1061,8 @@ private static class JavaAccessor extends org.jruby.internal.runtime.methods.Jav
private final RubyModule packageOrClass;
private final RubyModule parentPackage;

JavaAccessor(final RubyClass singleton, final RubyModule packageOrClass, final RubyModule parentPackage) {
super(singleton, PUBLIC);
JavaAccessor(final RubyClass singleton, final RubyModule packageOrClass, final RubyModule parentPackage, final String name) {
super(singleton, PUBLIC, name);
this.parentPackage = parentPackage; this.packageOrClass = packageOrClass;
}

Original file line number Diff line number Diff line change
@@ -36,10 +36,10 @@ void addConstructor(final Constructor ctor, final Class<?> clazz) {

@Override void install(final RubyModule proxy) {
if ( localConstructor ) {
proxy.addMethod(name, new ConstructorInvoker(proxy, constructors));
proxy.addMethod(name, new ConstructorInvoker(proxy, constructors, name));
}
else { // if there's no constructor, we must prevent construction
proxy.addMethod(name, new org.jruby.internal.runtime.methods.JavaMethod(proxy, PUBLIC) {
proxy.addMethod(name, new org.jruby.internal.runtime.methods.JavaMethod(proxy, PUBLIC, name) {
@Override
public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject[] args, Block block) {
throw context.runtime.newTypeError("no public constructors for " + clazz);
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ public class InstanceMethodInvokerInstaller extends MethodInstaller {

@Override void install(final RubyModule proxy) {
if ( hasLocalMethod() ) {
defineMethods(proxy, new InstanceMethodInvoker(proxy, methods));
defineMethods(proxy, new InstanceMethodInvoker(proxy, methods, name));
}
}
}
Original file line number Diff line number Diff line change
@@ -20,6 +20,6 @@ public SingletonMethodInvokerInstaller(String name, Object singleton) {
// we don't check haveLocalMethod() here because it's not local and we know
// that we always want to go ahead and install it
final RubyClass singletonClass = proxy.getSingletonClass();
defineMethods(singletonClass, new SingletonMethodInvoker(this.singleton, singletonClass, methods), false);
defineMethods(singletonClass, new SingletonMethodInvoker(this.singleton, singletonClass, methods, name), false);
}
}
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@ public class StaticMethodInvokerInstaller extends MethodInstaller {
@Override void install(final RubyModule proxy) {
if ( hasLocalMethod() ) {
final RubyClass singletonClass = proxy.getSingletonClass();
defineMethods(singletonClass, new StaticMethodInvoker(singletonClass, methods), false);
defineMethods(singletonClass, new StaticMethodInvoker(singletonClass, methods, name), false);
}
}
}
2 changes: 1 addition & 1 deletion lib/pom.rb
Original file line number Diff line number Diff line change
@@ -27,7 +27,7 @@ def initialize( name, version, default_spec = true )
default_gems =
[
ImportedGem.new( 'jruby-openssl', '0.9.21' ),
ImportedGem.new( 'jruby-readline', '1.2.0' ),
ImportedGem.new( 'jruby-readline', '1.2.1' ),
ImportedGem.new( 'rake', '${rake.version}' ),
ImportedGem.new( 'rdoc', '${rdoc.version}' ),
ImportedGem.new( 'minitest', '${minitest.version}' ),
2 changes: 1 addition & 1 deletion lib/pom.xml
Original file line number Diff line number Diff line change
@@ -47,7 +47,7 @@ DO NOT MODIFIY - GENERATED CODE
<dependency>
<groupId>rubygems</groupId>
<artifactId>jruby-readline</artifactId>
<version>1.2.0</version>
<version>1.2.1</version>
<type>gem</type>
<scope>provided</scope>
<exclusions>
2 changes: 1 addition & 1 deletion pom.rb
Original file line number Diff line number Diff line change
@@ -79,7 +79,7 @@
# used in ./lib/pom.rb and ./maven/jruby-stdlib/pom.rb
'rdoc.version' => '5.0.0',
'rake.version' => '10.4.2',
'jar-dependencies.version' => '0.3.10',
'jar-dependencies.version' => '0.3.12',

'jruby-launcher.version' => '1.1.1',
'ant.version' => '1.9.2',
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
@@ -127,7 +127,7 @@ DO NOT MODIFIY - GENERATED CODE
<jruby.plugins.version>1.0.10</jruby.plugins.version>
<invoker.skip>true</invoker.skip>
<json.version>1.8.3</json.version>
<jar-dependencies.version>0.3.10</jar-dependencies.version>
<jar-dependencies.version>0.3.12</jar-dependencies.version>
<power_assert.version>0.2.3</power_assert.version>
<version.jruby>${project.version}</version.jruby>
<main.basedir>${project.basedir}</main.basedir>
1 change: 1 addition & 0 deletions test/mri/excludes/TestTranscode.rb
Original file line number Diff line number Diff line change
@@ -3,3 +3,4 @@
exclude :test_to_cp50221, "needs investigation"
exclude :test_unicode_public_review_issue_121, "broken via charset replacement"
exclude :test_utf8_mac, "needs investigation"
exclude :test_windows_1255, "jcodings 1.0.27 maps windows-1255 0xCA to UTF-8 U+05BA which was not supported in CRuby 2.3."

0 comments on commit 8bd3256

Please sign in to comment.