Top Description Inners Fields Constructors Methods
org.jruby.javasupport.proxy

public Class JavaProxyClass

extends JavaProxyReflectionObject
Class Inheritance
Annotations
@JRubyClass
name:Java::JavaProxyClass
Imports
org.jruby.Ruby, .RubyArray, .RubyBasicObject, .RubyClass, .RubyFixnum, .RubyModule, .RubyObject, .RubyString, org.jruby.anno.JRubyClass, .JRubyMethod, org.jruby.api.Access, org.jruby.internal.runtime.AbstractIRMethod, org.jruby.internal.runtime.methods.DynamicMethod, org.jruby.java.proxies.ConcreteJavaProxy.NewMethodReified, .ConcreteJavaProxy.StaticJCreateMethod, .JavaProxy, org.jruby.java.util.ClassUtils, org.jruby.javasupport.Java, .JavaUtil, org.jruby.runtime.ThreadContext, org.jruby.runtime.builtin.IRubyObject, org.jruby.util.JavaNameMangler, java.lang.reflect.Array, .Constructor, .InvocationTargetException, .Method, java.security.AccessController, .PrivilegedActionException, .PrivilegedExceptionAction, java.util.ArrayList, .Arrays, .HashMap, .HashSet, .List

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}.
Author
[email protected]
See Also
java.lang.reflect.Proxy

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class

Field Summary

Modifier and TypeField and Description
private transient JavaProxyConstructor[]
private static final HashSet<String>
private static final ThreadLocal<Object[]>
lookup

These objects are to allow static initializers in reified code.

private final HashMap<String, ArrayList<JavaProxyMethod>>
private final ArrayList<JavaProxyMethod>
private final Class<T>

Constructor Summary

AccessConstructor and Description
private
JavaProxyClass(ThreadContext context, final Class<?> proxyClass)

Method Summary

Modifier and TypeMethod and Description
public static int
public final RubyArray<T extends IRubyObject>
constructors()
Deprecated since 10.0.

public final RubyArray<T extends IRubyObject>
public static RubyClass
public static void
public static void
public boolean
equals(Object
object to compare
other
)

Overrides org.jruby.javasupport.proxy.JavaProxyReflectionObject.equals.

This override does not do a "checked" dispatch.

public static String

Returns:

a unique stub method name for the given proxy class and super method
generateSuperName
(String
the proxy class name
className
,
String
the super method name
superName
)

Generate a "super" stub for the given proxy class name and super method name.

public static RubyObject
get_with_class(final IRubyObject self, IRubyObject obj)
Deprecated since 10.0.

public static RubyObject
public JavaProxyConstructor
getConstructor(final Class<T>[] args)
Deprecated since 10.0.

public JavaProxyConstructor[]
getConstructors()
Deprecated since 10.0.

public JavaProxyConstructor[]
public Class<T>[]
public final Class<T>
getJavaClass()

Overrides org.jruby.RubyBasicObject.getJavaClass.

Implements org.jruby.runtime.builtin.IRubyObject.getJavaClass.

Will return the Java interface that most closely can represent this object, when working through Java integration translations.

public JavaProxyMethod
getMethod(String name, Class<T>[] parameterTypes)

public JavaProxyMethod[]
public static JavaProxyClass
getProxyClass(final Ruby runtime, final RubyClass clazz)
Deprecated since 10.0.

public static JavaProxyClass
getProxyClass(ThreadContext context, final RubyClass clazz)

public static Object[]
getStaticInitLookup(final int id)

public Class<T>
public Object
public int
hashCode()

Overrides org.jruby.javasupport.proxy.JavaProxyReflectionObject.hashCode.

This override does not do "checked" dispatch since Object usually has #hash defined.

public void
initMethod(ThreadContext context, final String name, final String desc, final boolean hasSuper)

public RubyArray<T extends IRubyObject>
interfaces()
Deprecated since 10.0.

public RubyArray<T extends IRubyObject>
public RubyArray<T extends IRubyObject>
methods()
Deprecated since 10.0.

public RubyArray<T extends IRubyObject>
public final String
private static Class<T>[]
parse(final ClassLoader loader, String desc)

public static JavaProxyClass
setProxyClassReified(ThreadContext context, final RubyClass clazz, final Class<? extends ReifiedJavaProxy> reified, final boolean allocator)

public IRubyObject
superclass()
Deprecated since 10.0.

public IRubyObject
Inherited from org.jruby.javasupport.proxy.JavaProxyReflectionObject:
arefarefasetasethashis_java_proxyis_java_proxyjava_classjava_classjava_typejava_typelengthlengthop_eqqop_equalop_equalregisterRubyMethodssameto_stoClassArraytoRubyArraytoString

Field Detail

constructorsback to summary
private transient JavaProxyConstructor[] constructors
EXCLUDE_MODULESback to summary
private static final HashSet<String> EXCLUDE_MODULES
lookupback to summary
private static final ThreadLocal<Object[]> lookup

These objects are to allow static initializers in reified code. See RubyClass.BaseReifier for details

methodMapback to summary
private final HashMap<String, ArrayList<JavaProxyMethod>> methodMap
methodsback to summary
private final ArrayList<JavaProxyMethod> methods
proxyClassback to summary
private final Class<T> proxyClass

Constructor Detail

JavaProxyClassback to summary
private JavaProxyClass(ThreadContext context, final Class<?> proxyClass)

Method Detail

addStaticInitLookupback to summary
public static int addStaticInitLookup(Object... objects)
constructorsback to summary
public final RubyArray<T extends IRubyObject> constructors()

Deprecated

since 10.0.

Annotations
@Deprecated
since:10.0
constructorsback to summary
public final RubyArray<T extends IRubyObject> constructors(ThreadContext context)
Annotations
@JRubyMethod
createJavaProxyClassClassback to summary
public static RubyClass createJavaProxyClassClass(ThreadContext context, RubyClass Object, final RubyModule Java)
createJavaProxyClassesback to summary
public static void createJavaProxyClasses(ThreadContext context, final RubyModule Java, RubyClass Object)
ensureStaticIntConsumedback to summary
public static void ensureStaticIntConsumed()
equalsback to summary
public boolean equals(Object other)

Overrides org.jruby.javasupport.proxy.JavaProxyReflectionObject.equals.

Doc from org.jruby.RubyObject.equals.

This override does not do a "checked" dispatch.

Parameters
other:Object

Doc from org.jruby.RubyBasicObject.equals.

object to compare

Returns:boolean

Doc from org.jruby.RubyBasicObject.equals.

true if equals

Annotations
@Override
generateSuperNameback to summary
public static String generateSuperName(String className, String superName)

Generate a "super" stub for the given proxy class name and super method name. This name is intended to be unique to this class and method in order to allow jumping into the super chain at any point in the hierarchy, bypassing the default behavior of virtual and reflective calls.

Parameters
className:String

the proxy class name

superName:String

the super method name

Returns:String

a unique stub method name for the given proxy class and super method

get_with_classback to summary
public static RubyObject get_with_class(final IRubyObject self, IRubyObject obj)

Deprecated

since 10.0.

Annotations
@Deprecated
since:10.0
get_with_classback to summary
public static RubyObject get_with_class(ThreadContext context, final IRubyObject self, IRubyObject obj)
Annotations
@JRubyMethod
meta:true
getConstructorback to summary
public JavaProxyConstructor getConstructor(final Class<T>[] args) throws SecurityException, NoSuchMethodException

Deprecated

since 10.0.

Annotations
@Deprecated
since:10.0
getConstructorsback to summary
public JavaProxyConstructor[] getConstructors()

Deprecated

since 10.0.

Annotations
@Deprecated
since:10.0
getConstructorsback to summary
public JavaProxyConstructor[] getConstructors(ThreadContext context)
getInterfacesback to summary
public Class<T>[] getInterfaces()
getJavaClassback to summary
public final Class<T> getJavaClass()

Overrides org.jruby.RubyBasicObject.getJavaClass.

Implements org.jruby.runtime.builtin.IRubyObject.getJavaClass.

Doc from org.jruby.RubyBasicObject.getJavaClass.

Will return the Java interface that most closely can represent this object, when working through Java integration translations.

Returns:Class<T>

the true Java class of this (Ruby) object

Annotations
@Override
getMethodback to summary
public JavaProxyMethod getMethod(String name, Class<T>[] parameterTypes)
getMethodsback to summary
public JavaProxyMethod[] getMethods()
getProxyClassback to summary
public static JavaProxyClass getProxyClass(final Ruby runtime, final RubyClass clazz)

Deprecated

since 10.0.

Annotations
@Deprecated
since:10.0
getProxyClassback to summary
public static JavaProxyClass getProxyClass(ThreadContext context, final RubyClass clazz)
getStaticInitLookupback to summary
public static Object[] getStaticInitLookup(final int id)
getSuperclassback to summary
public Class<T> getSuperclass()
getValueback to summary
public Object getValue()
hashCodeback to summary
public int hashCode()

Overrides org.jruby.javasupport.proxy.JavaProxyReflectionObject.hashCode.

Doc from org.jruby.RubyObject.hashCode.

This override does not do "checked" dispatch since Object usually has #hash defined.

Returns:int

the hash code

Annotations
@Override
initMethodback to summary
public void initMethod(ThreadContext context, final String name, final String desc, final boolean hasSuper)
Annotations
@SuppressWarnings:unchecked
interfacesback to summary
public RubyArray<T extends IRubyObject> interfaces()

Deprecated

since 10.0.

Annotations
@Deprecated
since:10.0
interfacesback to summary
public RubyArray<T extends IRubyObject> interfaces(ThreadContext context)
Annotations
@JRubyMethod
methodsback to summary
public RubyArray<T extends IRubyObject> methods()

Deprecated

since 10.0.

Annotations
@Deprecated
since:10.0
methodsback to summary
public RubyArray<T extends IRubyObject> methods(ThreadContext context)
Annotations
@JRubyMethod
nameOnInspectionback to summary
public final String nameOnInspection()
parseback to summary
private static Class<T>[] parse(final ClassLoader loader, String desc) throws ClassNotFoundException
setProxyClassReifiedback to summary
public static JavaProxyClass setProxyClassReified(ThreadContext context, final RubyClass clazz, final Class<? extends ReifiedJavaProxy> reified, final boolean allocator)
superclassback to summary
public IRubyObject superclass()

Deprecated

since 10.0.

Annotations
@Deprecated
since:10.0
superclassback to summary
public IRubyObject superclass(ThreadContext context)
Annotations
@JRubyMethod
org.jruby.javasupport.proxy back to summary

public Class JavaProxyClass.ProxyMethodImpl

extends JavaProxyReflectionObject
implements JavaProxyMethod
Class Inheritance
All Implemented Interfaces
org.jruby.javasupport.proxy.JavaProxyMethod, org.jruby.javasupport.ParameterTypes, org.jruby.runtime.builtin.IRubyObject
Annotations
@JRubyClass
name:Java::JavaProxyMethod

Field Summary

Modifier and TypeField and Description
private final Method
private final Class<T>[]
private final JavaProxyClass
private Object
private final Method

Constructor Summary

AccessConstructor and Description
public
ProxyMethodImpl(Ruby runtime, final JavaProxyClass clazz, final Method method, final Method superMethod)

Method Summary

Modifier and TypeMethod and Description
public RubyArray<T extends IRubyObject>
argument_types()
Deprecated since 10.0.

public RubyArray<T extends IRubyObject>
public RubyFixnum
arity()
Deprecated since 10.0.

public RubyFixnum
public static RubyClass
public Object
public IRubyObject
do_invoke(final IRubyObject[] args)
Deprecated since 10.0. Use ProxyMethodImpl#do_invoke(ThreadContext, IRubyObject[]) instead.

public IRubyObject
do_invoke(ThreadContext context, final IRubyObject[] args)

public boolean
equals(Object
object to compare
other
)

Overrides org.jruby.javasupport.proxy.JavaProxyReflectionObject.equals.

This override does not do a "checked" dispatch.

public final int
public final JavaProxyClass
public final Class<?>[]
private static RubyClass
public Method
public int
public String
public final Class<?>[]
public final Class<?>
public Object
getState()

Implements org.jruby.javasupport.proxy.JavaProxyMethod.getState.

get state (cache target callable?) in the proxy method

public Method
public int
hashCode()

Overrides org.jruby.javasupport.proxy.JavaProxyReflectionObject.hashCode.

This override does not do "checked" dispatch since Object usually has #hash defined.

public boolean
public RubyString
inspect()

Overrides org.jruby.RubyBasicObject.inspect.

Implements org.jruby.runtime.builtin.IRubyObject.inspect.

Deprecated since 10.0.

RubyMethod inspect.

public RubyString
inspect(ThreadContext context)

Overrides org.jruby.RubyBasicObject.inspect.

Overrides default org.jruby.runtime.builtin.IRubyObject.inspect.

Returns a string containing a human-readable representation of obj.

public Object
public final boolean
public final boolean
matches(final String name, final Class<?>[] parameterTypes)

public RubyObject
name()
Deprecated since 10.0.

public void
setState(Object state)

Implements org.jruby.javasupport.proxy.JavaProxyMethod.setState.

store state (cache target callable?) in the proxy method

public IRubyObject
super_p()
Deprecated since 10.0.

public IRubyObject
public String
toString()

Overrides org.jruby.javasupport.proxy.JavaProxyReflectionObject.toString.

The default toString method is just a wrapper that calls the Ruby "to_s" method.

Inherited from org.jruby.javasupport.proxy.JavaProxyReflectionObject:
arefarefasetasethashis_java_proxyis_java_proxyjava_classjava_classjava_typejava_typelengthlengthop_eqqop_equalop_equalregisterRubyMethodssameto_stoClassArraytoRubyArray

Field Detail

methodback to summary
private final Method method
parameterTypesback to summary
private final Class<T>[] parameterTypes
proxyClassback to summary
private final JavaProxyClass proxyClass
stateback to summary
private Object state
superMethodback to summary
private final Method superMethod

Constructor Detail

ProxyMethodImplback to summary
public ProxyMethodImpl(Ruby runtime, final JavaProxyClass clazz, final Method method, final Method superMethod)

Method Detail

argument_typesback to summary
public RubyArray<T extends IRubyObject> argument_types()

Deprecated

since 10.0.

Annotations
@Deprecated
since:10.0
argument_typesback to summary
public RubyArray<T extends IRubyObject> argument_types(ThreadContext context)
Annotations
@JRubyMethod
arityback to summary
public RubyFixnum arity()

Deprecated

since 10.0.

Annotations
@Deprecated
since:10.0
arityback to summary
public RubyFixnum arity(ThreadContext context)
Annotations
@JRubyMethod
createJavaProxyMethodClassback to summary
public static RubyClass createJavaProxyMethodClass(ThreadContext context, RubyClass Object, RubyModule Java)
defaultResultback to summary
public Object defaultResult()

Implements org.jruby.javasupport.proxy.JavaProxyMethod.defaultResult.

Deprecated

Annotations
@Deprecated
do_invokeback to summary
public IRubyObject do_invoke(final IRubyObject[] args)
Annotations
@Deprecated
since:10.0
do_invokeback to summary
public IRubyObject do_invoke(ThreadContext context, final IRubyObject[] args)
Annotations
@JRubyMethod
name:invoke
rest:true
equalsback to summary
public boolean equals(Object other)

Overrides org.jruby.javasupport.proxy.JavaProxyReflectionObject.equals.

Doc from org.jruby.RubyObject.equals.

This override does not do a "checked" dispatch.

Parameters
other:Object

Doc from org.jruby.RubyBasicObject.equals.

object to compare

Returns:boolean

Doc from org.jruby.RubyBasicObject.equals.

true if equals

Annotations
@Override
getArityback to summary
public final int getArity()

Implements org.jruby.javasupport.ParameterTypes.getArity.

getDeclaringClassback to summary
public final JavaProxyClass getDeclaringClass()

Implements org.jruby.javasupport.proxy.JavaProxyMethod.getDeclaringClass.

Annotations
@JRubyMethod
name:declaring_class
getExceptionTypesback to summary
public final Class<?>[] getExceptionTypes()

Implements org.jruby.javasupport.ParameterTypes.getExceptionTypes.

getJavaProxyMethodback to summary
private static RubyClass getJavaProxyMethod(ThreadContext context)
getMethodback to summary
public Method getMethod()
getModifiersback to summary
public int getModifiers()

Implements org.jruby.javasupport.proxy.JavaProxyMethod.getModifiers.

getNameback to summary
public String getName()

Implements org.jruby.javasupport.proxy.JavaProxyMethod.getName.

getParameterTypesback to summary
public final Class<?>[] getParameterTypes()

Implements org.jruby.javasupport.ParameterTypes.getParameterTypes.

getReturnTypeback to summary
public final Class<?> getReturnType()

Implements org.jruby.javasupport.proxy.JavaProxyMethod.getReturnType.

getStateback to summary
public Object getState()

Implements org.jruby.javasupport.proxy.JavaProxyMethod.getState.

Doc from org.jruby.javasupport.proxy.JavaProxyMethod.getState.

get state (cache target callable?) in the proxy method

getSuperMethodback to summary
public Method getSuperMethod()

Implements org.jruby.javasupport.proxy.JavaProxyMethod.getSuperMethod.

hashCodeback to summary
public int hashCode()

Overrides org.jruby.javasupport.proxy.JavaProxyReflectionObject.hashCode.

Doc from org.jruby.RubyObject.hashCode.

This override does not do "checked" dispatch since Object usually has #hash defined.

Returns:int

the hash code

Annotations
@Override
hasSuperImplementationback to summary
public boolean hasSuperImplementation()

Implements org.jruby.javasupport.proxy.JavaProxyMethod.hasSuperImplementation.

Doc from org.jruby.javasupport.proxy.JavaProxyMethod.hasSuperImplementation.

is it possible to call the super method?

inspectback to summary
public RubyString inspect()

Overrides org.jruby.RubyBasicObject.inspect.

Implements org.jruby.runtime.builtin.IRubyObject.inspect.

Doc from org.jruby.runtime.builtin.IRubyObject.inspect.

Deprecated

since 10.0.

RubyMethod inspect.

Returns:RubyString

String

Annotations
@Deprecated
since:10.0
inspectback to summary
public RubyString inspect(ThreadContext context)

Overrides org.jruby.RubyBasicObject.inspect.

Overrides default org.jruby.runtime.builtin.IRubyObject.inspect.

Doc from org.jruby.RubyBasicObject.inspect.

Returns a string containing a human-readable representation of obj. If not overridden, uses the to_s method to generate the string. [ 1, 2, 3..4, 'five' ].inspect #=> "[1, 2, 3..4, \"five\"]" Time.new.inspect #=> "Wed Apr 09 08:54:39 CDT 2003"

Annotations
@Override
@JRubyMethod
invokeback to summary
public Object invoke(Object proxy, Object[] args) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException, NoSuchMethodException

Implements org.jruby.javasupport.proxy.JavaProxyMethod.invoke.

Exceptions
NoSuchMethodException:

Doc from org.jruby.javasupport.proxy.JavaProxyMethod.invoke.

if this ProxyMethod has no super implementation

isVarArgsback to summary
public final boolean isVarArgs()

Implements org.jruby.javasupport.ParameterTypes.isVarArgs.

matchesback to summary
public final boolean matches(final String name, final Class<?>[] parameterTypes)
nameback to summary
public RubyObject name()

Deprecated

since 10.0.

Annotations
@Deprecated
since:10.0
setStateback to summary
public void setState(Object state)

Implements org.jruby.javasupport.proxy.JavaProxyMethod.setState.

Doc from org.jruby.javasupport.proxy.JavaProxyMethod.setState.

store state (cache target callable?) in the proxy method

super_pback to summary
public IRubyObject super_p()

Deprecated

since 10.0.

Annotations
@Deprecated
since:10.0
super_pback to summary
public IRubyObject super_p(ThreadContext context)
Annotations
@JRubyMethod
name:super?
toStringback to summary
public String toString()

Overrides org.jruby.javasupport.proxy.JavaProxyReflectionObject.toString.

Doc from org.jruby.RubyObject.toString.

The default toString method is just a wrapper that calls the Ruby "to_s" method.

Returns:String

string representation

Annotations
@Override