package org.jruby.javasupport.proxy;
Generalized proxy for classes and interfaces.
API looks a lot like java.lang.reflect.Proxy, except that you can specify a
super class in addition to a set of interfaces.
The main implication for users of this class is to handle the case where a
proxy method overrides an existing method, because in this case the
invocation handler should "default" to calling the super implementation
{JavaProxyMethod.invokeSuper}.
Class[] constructorParameters, Object[] constructorArgs,
new Class[0] : constructorParameters);
for (int i = 0; i < ifaces.length; i++) {
result[pos++] = ifaces[i];
for (int i = 0; i < cons.length; i++) {
System.arraycopy(args, 0, realArgs, 0, args.length);
for (int i = methods.size(); --i >= 0; ) {
if (jpm.matches(name, parameterTypes)) return jpm;
return the class of instances of this proxy class
for (int i = 0; i < parameterTypes.length; i++) {
if (i < parameterTypes.length - 1) {
System.arraycopy(nargs, 1, arguments, 0, arguments.length);
for (int i = 0; i < arguments.length; i++) {
if (methodsWithName == null) {
methodsWithName.add(jpm);
while (desc.charAt(idx) != ')') {
while (desc.charAt(idx) == '[') {
throw new InternalError("cannot parse " + desc + "[" + idx + "]");
boolean skipRemainingClasses = false;
if (skipRemainingClasses) continue;
skipRemainingClasses = true;
"no java_class defined for proxy (or ancestor): " + ancestor);
"invalid java_class defined for proxy (or ancestor): " +
} else if (javaClass != var) {
"java_class defined for " + clazz + " (" + javaClass +
") does not match java_class for ancestor " + ancestor +
if (var != null && !(var instanceof RubyNil)) {
"invalid java_interfaces defined for proxy (or ancestor): " +
int size = ifcArray.size();
for (int i = size; --i >= 0; ) {
"invalid java interface defined for proxy (or ancestor): " +
"invalid java interface defined for proxy (or ancestor): " +
ancestor + ": " + ifc + " (not an interface)");
if (!interfaceList.contains(interfaceClass)) {
interfaceList.add(interfaceClass);
"invalid @__java_ovrd_methods defined for proxy: " +
int size = methodNames.size();
for (int i = size; --i >= 0; ) {
"invalid method name defined for proxy (or ancestor): " +
ancestor + ": " + methodName);
throw runtime.newArgumentError("unable to create proxy class: no java_class defined for " + clazz);
int interfaceCount = interfaceList.size();
Class<?>[] interfaces = new Class<?>[interfaceCount];
for (int i = interfaceCount; --i >= 0; ) {
interfaces[i] = interfaceList.get(i);