Skip to content

Commit

Permalink
Showing 3 changed files with 16 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -124,10 +124,6 @@ public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule claz
ensureTargets();
try {
return (IRubyObject) target4.invokeExact(context, self, args, block);
} catch (NullPointerException npe) {
npe.printStackTrace();
System.out.println("handles: " + Arrays.toString(targets));
throw npe;
} catch (Throwable t) {
Helpers.throwException(t);
return null;
Original file line number Diff line number Diff line change
@@ -140,14 +140,24 @@ public MethodHandle[] call() throws Exception {
org.jruby.runtime.Signature.OPTIONAL,
true,
notImplemented,
null);
info.getParameterDesc());
}

private MethodHandle[] buildAnnotatedMethodHandles(Ruby runtime, List<JavaMethodDescriptor> descs, RubyModule implementationClass) {
MethodHandle[] targets = new MethodHandle[5];

int min = Integer.MAX_VALUE;
int max = 0;

JavaMethodDescriptor desc1 = descs.get(0);
String rubyName;

if (desc1.anno.name() != null && desc1.anno.name().length > 0) {
// FIXME: Using this for super may super up the wrong name
rubyName = desc1.anno.name()[0];
} else {
rubyName = desc1.name;
}

for (JavaMethodDescriptor desc: descs) {
int specificArity = -1;
@@ -171,14 +181,6 @@ private MethodHandle[] buildAnnotatedMethodHandles(Ruby runtime, List<JavaMethod
}

String javaMethodName = desc.name;
String rubyName;

if (desc.anno.name() != null && desc.anno.name().length > 0) {
// FIXME: Using this for super may super up the wrong name
rubyName = desc.anno.name()[0];
} else {
rubyName = javaMethodName;
}

SmartBinder targetBinder;
SmartHandle target;
@@ -312,7 +314,7 @@ private MethodHandle[] buildAnnotatedMethodHandles(Ruby runtime, List<JavaMethod
.foldVoid(SmartBinder
.from(VARIABLE_ARITY_SIGNATURE.changeReturn(int.class))
.permute("context", "args")
.append(arrayOf("min", "max"), arrayOf(int.class, int.class), min, max)
.append(arrayOf("min", "max", "name"), arrayOf(int.class, int.class, String.class), min, max, rubyName)
.invokeStaticQuiet(LOOKUP, Arity.class, "checkArgumentCount")
.handle())
.invoke(targets[4])
4 changes: 4 additions & 0 deletions core/src/main/java/org/jruby/runtime/Arity.java
Original file line number Diff line number Diff line change
@@ -202,6 +202,10 @@ public static int checkArgumentCount(ThreadContext context, IRubyObject[] args,
return checkArgumentCount(context, args.length, min, max);
}

public static int checkArgumentCount(ThreadContext context, IRubyObject[] args, int min, int max, String name) {
return checkArgumentCount(context.runtime, name, args.length, min, max);
}

public static int checkArgumentCount(Ruby runtime, String name, IRubyObject[] args, int min, int max) {
return checkArgumentCount(runtime, name, args.length, min, max);
}

0 comments on commit ba22379

Please sign in to comment.