private ArrayJavaProxyCreator(final Ruby runtime, Class<?> elementType) { super(runtime, runtime.getJavaSupport().getArrayJavaProxyCreatorClass()); this.elementType = elementType; }
RubyClass superClass = null; if (clazz.isInterface()) { proxy = (RubyModule) runtime.getJavaSupport().getJavaInterfaceTemplate().dup(); } else { if (clazz.isArray()) { superClass = javaSupport.getArrayProxyClass(); } else if (clazz.isPrimitive()) { superClass = javaSupport.getConcreteProxyClass(); superClass = javaSupport.getConcreteProxyClass(); } else { javaSupport.beginProxy(clazz, proxy); try { if (clazz.isInterface()) { javaSupport.endProxy(clazz);
public JavaArray(Ruby runtime, Object array) { super(runtime, runtime.getJavaSupport().getJavaArrayClass(), array); assert array.getClass().isArray(); javaConverter = JavaUtil.getJavaConverter(array.getClass().getComponentType()); }
public JavaClass(final Ruby runtime, final Class<?> klass) { this(runtime, runtime.getJavaSupport().getJavaClassClass(), klass); }
public static RubyModule createProxyClassForClass(Ruby runtime, final Class c) { RubyModule proxyClass; JavaClass javaClass = runtime.getJavaSupport().getJavaClassFromCache(c); runtime.getJavaSupport().getArrayProxyClass(), javaClass, true); runtime.getJavaSupport().getConcreteProxyClass(), javaClass, true); runtime.getJavaSupport().getConcreteProxyClass(), javaClass, true); if (NEW_STYLE_EXTENSION) {
@JRubyMethod(module = true) public static IRubyObject java_to_ruby(ThreadContext context, IRubyObject recv, IRubyObject ary) { if (!(ary instanceof ArrayJavaProxy)) { throw context.runtime.newTypeError(ary, context.runtime.getJavaSupport().getArrayProxyClass()); } return ((ArrayJavaProxy)ary).to_a(context); }
public static JavaClass get(final Ruby runtime, final Class<?> klass) { return runtime.getJavaSupport().getJavaClassFromCache(klass); }
public static RubyClass createMapJavaProxy(final Ruby runtime) { RubyClass MapJavaProxy = runtime.defineClass( "MapJavaProxy", runtime.getJavaSupport().getConcreteProxyClass(), ALLOCATOR ); // this is done while proxy class is created. // See org.jruby.javasuppoer.java.createProxyClass() // MapJavaProxy.defineAnnotatedMethods(MapJavaProxy.class); ConcreteJavaProxy.initialize(MapJavaProxy); return MapJavaProxy; }
public JavaConstructor(Ruby runtime, Constructor<?> constructor) { super(runtime, runtime.getJavaSupport().getJavaConstructorClass(), constructor.getParameterTypes()); this.constructor = constructor; //this.objectConverter = JavaUtil.getJavaConverter(constructor.getDeclaringClass()); }
public JavaField(Ruby runtime, Field field) { super(runtime, runtime.getJavaSupport().getJavaFieldClass()); this.field = field; }
public JavaMethod(Ruby runtime, Method method) { super(runtime, runtime.getJavaSupport().getJavaMethodClass(), method.getParameterTypes()); this.method = method; this.isFinal = Modifier.isFinal(method.getModifiers()); final Class<?> returnType = method.getReturnType(); if (returnType.isPrimitive() && returnType != void.class) { this.boxedReturnType = getBoxType(returnType); } else { this.boxedReturnType = returnType; } // Special classes like Collections.EMPTY_LIST are inner classes that are private but // implement public interfaces. Their methods are all public methods for the public // interface. Let these public methods execute via setAccessible(true). if (JavaUtil.CAN_SET_ACCESSIBLE) { // we should be able to setAccessible ok... try { if ( Modifier.isPublic(method.getModifiers()) && ! Modifier.isPublic(method.getDeclaringClass().getModifiers()) ) { method.setAccessible(true); } } catch (SecurityException se) { // we shouldn't get here if JavaClass.CAN_SET_ACCESSIBLE is doing // what it should, so we warn. runtime.getWarnings().warn("failed to setAccessible: " + method + ", exception follows: " + se.getMessage()); } } returnConverter = JavaUtil.getJavaConverter(returnType); }
public static RubyModule getInterfaceModule(Ruby runtime, JavaClass javaClass) { if (!javaClass.javaClass().isInterface()) { throw runtime.newArgumentError(javaClass.toString() + " is not an interface"); } RubyModule interfaceModule; if ((interfaceModule = javaClass.getProxyModule()) != null) { return interfaceModule; } javaClass.lockProxy(); try { if ((interfaceModule = javaClass.getProxyModule()) == null) { interfaceModule = (RubyModule) runtime.getJavaSupport().getJavaInterfaceTemplate().dup(); interfaceModule.setInstanceVariable("@java_class", javaClass); javaClass.setupInterfaceModule(interfaceModule); // include any interfaces we extend Class<?>[] extended = javaClass.javaClass().getInterfaces(); for (int i = extended.length; --i >= 0;) { JavaClass extendedClass = JavaClass.get(runtime, extended[i]); RubyModule extModule = getInterfaceModule(runtime, extendedClass); interfaceModule.includeModule(extModule); } addToJavaPackageModule(interfaceModule, javaClass); } } finally { javaClass.unlockProxy(); } return interfaceModule; }
public JavaClass(final Ruby runtime, final Class<?> klass) { this(runtime, runtime.getJavaSupport().getJavaClassClass(), klass); }
public static RubyModule createProxyClassForClass(Ruby runtime, final Class c) { RubyModule proxyClass; JavaClass javaClass = runtime.getJavaSupport().getJavaClassFromCache(c); runtime.getJavaSupport().getArrayProxyClass(), javaClass, true); runtime.getJavaSupport().getConcreteProxyClass(), javaClass, true); runtime.getJavaSupport().getConcreteProxyClass(), javaClass, true); if (NEW_STYLE_EXTENSION) {
@JRubyMethod(module = true) public static IRubyObject java_to_ruby(ThreadContext context, IRubyObject recv, IRubyObject ary) { if (!(ary instanceof ArrayJavaProxy)) { throw context.runtime.newTypeError(ary, context.runtime.getJavaSupport().getArrayProxyClass()); } return ((ArrayJavaProxy)ary).to_a(context); }
public static JavaClass get(Ruby runtime, Class<?> klass) { return runtime.getJavaSupport().getJavaClassFromCache(klass); }
public static RubyClass createMapJavaProxy(final Ruby runtime) { RubyClass MapJavaProxy = runtime.defineClass( "MapJavaProxy", runtime.getJavaSupport().getConcreteProxyClass(), ALLOCATOR ); // this is done while proxy class is created. // See org.jruby.javasuppoer.java.createProxyClass() // MapJavaProxy.defineAnnotatedMethods(MapJavaProxy.class); ConcreteJavaProxy.initialize(MapJavaProxy); return MapJavaProxy; }
public JavaConstructor(Ruby runtime, Constructor<?> constructor) { super(runtime, runtime.getJavaSupport().getJavaConstructorClass(), constructor.getParameterTypes()); this.constructor = constructor; //this.objectConverter = JavaUtil.getJavaConverter(constructor.getDeclaringClass()); }
public JavaField(Ruby runtime, Field field) { super(runtime, runtime.getJavaSupport().getJavaFieldClass()); this.field = field; }
public JavaMethod(Ruby runtime, Method method) { super(runtime, runtime.getJavaSupport().getJavaMethodClass(), method.getParameterTypes()); this.method = method; this.isFinal = Modifier.isFinal(method.getModifiers()); final Class<?> returnType = method.getReturnType(); if (returnType.isPrimitive() && returnType != void.class) { this.boxedReturnType = getBoxType(returnType); } else { this.boxedReturnType = returnType; } // Special classes like Collections.EMPTY_LIST are inner classes that are private but // implement public interfaces. Their methods are all public methods for the public // interface. Let these public methods execute via setAccessible(true). if (JavaUtil.CAN_SET_ACCESSIBLE) { // we should be able to setAccessible ok... try { if ( Modifier.isPublic(method.getModifiers()) && ! Modifier.isPublic(method.getDeclaringClass().getModifiers()) ) { method.setAccessible(true); } } catch (SecurityException se) { // we shouldn't get here if JavaClass.CAN_SET_ACCESSIBLE is doing // what it should, so we warn. runtime.getWarnings().warn("failed to setAccessible: " + method + ", exception follows: " + se.getMessage()); } } returnConverter = JavaUtil.getJavaConverter(returnType); }