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

Commits on Aug 25, 2015

  1. Copy the full SHA
    cb85ace View commit details
  2. Copy the full SHA
    b8c12ff View commit details
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@
* rights and limitations under the License.
*
* Copyright (C) 2006 Kresten Krab Thorup <krab@gnu.org>
*
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
@@ -27,7 +27,11 @@
***** END LICENSE BLOCK *****/
package org.jruby.javasupport.proxy;

/** this interface is implemented by proxies generated from a JavaProxyClass */
/**
* Interface is implemented by proxies generated from a JavaProxyClass.
*
* @see JavaProxyClassFactory
*/
public interface InternalJavaProxy {

/**
@@ -40,6 +44,8 @@ public interface InternalJavaProxy {
*/
JavaProxyInvocationHandler ___getInvocationHandler();

final Object[] NO_ARGS = new Object[0];
// NOTE: used in JavaProxyClassFactory indirectly
// ... getStatic(JAVA_PROXY_TYPE, "NO_ARGS", ...)
static final Object[] NO_ARGS = new Object[0];

}
Original file line number Diff line number Diff line change
@@ -197,7 +197,8 @@ private JavaProxyClass generate(ClassLoader loader, String targetClassName,
Field proxy_class = clazz.getDeclaredField(PROXY_CLASS_FIELD_NAME);
proxy_class.setAccessible(true);
return (JavaProxyClass) proxy_class.get(clazz);
} catch (Exception ex) {
}
catch (Exception ex) {
InternalError ie = new InternalError();
ie.initCause(ex);
throw ie;
@@ -266,12 +267,17 @@ private ClassWriter beginProxyClass(final String className,
toInternalClassName(superClass),
interfaceNamesForProxyClass(interfaces));

cw.visitField(Opcodes.ACC_PRIVATE, INVOCATION_HANDLER_FIELD_NAME,
INVOCATION_HANDLER_TYPE.getDescriptor(), null, null).visitEnd();
// private final JavaProxyInvocationHandler __handler;
cw.visitField(Opcodes.ACC_PRIVATE | Opcodes.ACC_FINAL,
INVOCATION_HANDLER_FIELD_NAME,
INVOCATION_HANDLER_TYPE.getDescriptor(), null, null
).visitEnd();

cw.visitField(Opcodes.ACC_PRIVATE | Opcodes.ACC_STATIC,
PROXY_CLASS_FIELD_NAME, PROXY_CLASS_TYPE.getDescriptor(), null,
null).visitEnd();
// private static JavaProxyClass __proxy_class;
cw.visitField(Opcodes.ACC_PRIVATE | Opcodes.ACC_STATIC | Opcodes.ACC_FINAL,
PROXY_CLASS_FIELD_NAME,
PROXY_CLASS_TYPE.getDescriptor(), null, null
).visitEnd();

return cw;
}
@@ -282,6 +288,7 @@ private String[] interfaceNamesForProxyClass(final Class[] interfaces) {
for (int i = 0; i < interfaces.length; i++) {
interfaceNames[i] = toInternalClassName(interfaces[i]);
}
// all proxies implement our InternalJavaProxy interface :
interfaceNames[interfaces.length] = toInternalClassName(InternalJavaProxy.class);

return interfaceNames;
@@ -296,8 +303,11 @@ private void generateProxyMethods(Class superClass,
}
}

/**
* @see InternalJavaProxy
*/
private void generateGetInvocationHandler(Type selfType, ClassVisitor cw) {
// make getter for handler
// make getter for handler (due implements InternalJavaProxy)
GeneratorAdapter gh = new GeneratorAdapter(Opcodes.ACC_PUBLIC,
new org.objectweb.asm.commons.Method("___getInvocationHandler",
INVOCATION_HANDLER_TYPE, EMPTY_TYPE_ARRAY), null,
@@ -309,8 +319,11 @@ private void generateGetInvocationHandler(Type selfType, ClassVisitor cw) {
gh.endMethod();
}

/**
* @see InternalJavaProxy
*/
private void generateGetProxyClass(Type selfType, ClassVisitor cw) {
// make getter for proxy class
// make getter for proxy class (due implements InternalJavaProxy)
GeneratorAdapter gpc = new GeneratorAdapter(Opcodes.ACC_PUBLIC,
new org.objectweb.asm.commons.Method("___getProxyClass",
PROXY_CLASS_TYPE, EMPTY_TYPE_ARRAY), null,
@@ -486,6 +499,7 @@ private Class[] generateConstructor(Type selfType, Constructor constructor, Clas

ga.loadThis();
ga.loadArg(superConstructorParameterTypes.length);

ga.putField(selfType, INVOCATION_HANDLER_FIELD_NAME, INVOCATION_HANDLER_TYPE);

// do a void return
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@
* rights and limitations under the License.
*
* Copyright (C) 2006 Kresten Krab Thorup <krab@gnu.org>
*
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
@@ -28,17 +28,20 @@

package org.jruby.javasupport.proxy;

import java.lang.reflect.InvocationHandler;

import org.jruby.runtime.builtin.IRubyObject;

/**
* A proxy invocation handler for JRuby.
*
* @see java.lang.reflect.InvocationHandler
*/
public interface JavaProxyInvocationHandler {

IRubyObject getOrig();

/**
* Similar to java.lang.reflect.InvocationHandler
*
* Similar to {@link java.lang.reflect.InvocationHandler}
*
* @param receiver
* @param method
* @param args