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

Commits on Apr 22, 2015

  1. Add java_method, java_alias, and java_send to interface modules.

    Part of improvements to support #2857. Specs pending.
    headius committed Apr 22, 2015
    Copy the full SHA
    f8c4bcd View commit details
  2. Eliminate "base" java class proxy initialization.

    All it did was define the long-defunct __jsend! method, which is
    superceded for many years by java_send.
    headius committed Apr 22, 2015
    2
    Copy the full SHA
    a54f099 View commit details
Original file line number Diff line number Diff line change
@@ -21,6 +21,10 @@ public StaticMethodInvoker(RubyClass host, Method method) {
super(host, method);
}

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

@Override
public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject[] args) {
JavaMethod method = (JavaMethod) findCallable(self, name, args, args.length);
Original file line number Diff line number Diff line change
@@ -37,6 +37,8 @@ public static RubyModule createJavaInterfaceTemplateModule(ThreadContext context
singleton.addReadAttribute(context, "java_class");
singleton.defineAnnotatedMethods(JavaInterfaceTemplate.class);

JavaInterfaceTemplate.defineAnnotatedMethods(Java.JavaProxyClassMethods.class);

return JavaInterfaceTemplate;
}

4 changes: 2 additions & 2 deletions core/src/main/java/org/jruby/javasupport/Java.java
Original file line number Diff line number Diff line change
@@ -677,10 +677,10 @@ public static IRubyObject java_alias(ThreadContext context, IRubyObject clazz, I

private static IRubyObject getRubyMethod(ThreadContext context, IRubyObject clazz, String name, Class... argTypesClasses) {
final Ruby runtime = context.runtime;
if ( ! ( clazz instanceof RubyClass ) ) {
if ( ! ( clazz instanceof RubyModule ) ) {
throw runtime.newTypeError(clazz, runtime.getModule());
}
final RubyClass proxyClass = (RubyClass) clazz;
final RubyModule proxyClass = (RubyModule) clazz;

final Method method = getMethodFromClass(context, clazz, name, argTypesClasses);
final String prettyName = name + CodegenUtils.prettyParams(argTypesClasses);
Original file line number Diff line number Diff line change
@@ -28,8 +28,6 @@ public RubyModule initialize(RubyModule proxy) {

final State state = new State(runtime, superclass);

super.initializeBase(proxy);

proxyClass.setReifiedClass(javaClass);

runtime.getJavaSupport().getUnfinishedProxyClassCache().get(javaClass).set(proxyClass);
22 changes: 0 additions & 22 deletions core/src/main/java/org/jruby/javasupport/binding/Initializer.java
Original file line number Diff line number Diff line change
@@ -381,28 +381,6 @@ private static void setJavaClassFor(final Class<?> javaClass, final RubyModule p

public abstract RubyModule initialize(RubyModule proxy);

public void initializeBase(RubyModule proxy) {
proxy.addMethod("__jsend!", new org.jruby.internal.runtime.methods.JavaMethod.JavaMethodNBlock(proxy, PUBLIC) {
@Override
public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject[] args, Block block) {
String callName = args[0].asJavaString();

DynamicMethod method = self.getMetaClass().searchMethod(callName);
int v = method.getArity().getValue();

IRubyObject[] newArgs = new IRubyObject[args.length - 1];
System.arraycopy(args, 1, newArgs, 0, newArgs.length);

if(v < 0 || v == (newArgs.length)) {
return Helpers.invoke(context, self, callName, newArgs, Block.NULL_BLOCK);
} else {
RubyClass superClass = self.getMetaClass().getSuperClass();
return Helpers.invokeAs(context, superClass, self, callName, newArgs, Block.NULL_BLOCK);
}
}
});
}

public static class State {

final Map<String, AssignedName> staticNames;
Original file line number Diff line number Diff line change
@@ -23,8 +23,6 @@ public InterfaceInitializer(Ruby runtime, Class<?> javaClass) {
public RubyModule initialize(RubyModule proxy) {
final State state = new State(runtime, null);

super.initializeBase(proxy);

runtime.getJavaSupport().getUnfinishedProxyClassCache().get(javaClass).set(proxy);

Field[] fields = JavaClass.getDeclaredFields(javaClass);
Original file line number Diff line number Diff line change
@@ -568,7 +568,6 @@ public static RubyObject get(IRubyObject self, IRubyObject obj) {
EXCLUDE_METHODS.add("java_class");
EXCLUDE_METHODS.add("java_object");
EXCLUDE_METHODS.add("__jcreate!");
EXCLUDE_METHODS.add("__jsend!");
}

@JRubyMethod(meta = true)