public boolean match(final Class<?> type, final IRubyObject arg) { final Class<?> argClass = getJavaClass(arg); return type == argClass || (type.isPrimitive() && getBoxType(type) == argClass); } @Override public String toString() { return "EXACT"; } // for debugging
public boolean match(final Class<?> type, final IRubyObject arg) { final Class<?> argClass = getJavaClass(arg); return type == argClass || (type.isPrimitive() && getBoxType(type) == argClass); } @Override public String toString() { return "EXACT"; } // for debugging
public static Class<?> primitiveToWrapper(Class<?> type) { if (type.isPrimitive()) { return CodegenUtils.getBoxType(type); } return type; }
public static Class<?> primitiveToWrapper(Class<?> type) { if (type.isPrimitive()) { return CodegenUtils.getBoxType(type); } return type; }
public static Class<?> primitiveToWrapper(final Class<?> type) { return type.isPrimitive() ? CodegenUtils.getBoxType(type) : type; }
public static Class<?> primitiveToWrapper(final Class<?> type) { return type.isPrimitive() ? CodegenUtils.getBoxType(type) : type; }
public boolean match(Class type, IRubyObject arg) { return type.equals(argClass(arg)) || (type.isPrimitive() && CodegenUtils.getBoxType(type) == argClass(arg)); } };
public boolean match(Class type, IRubyObject arg) { return type.equals(argClass(arg)) || (type.isPrimitive() && CodegenUtils.getBoxType(type) == argClass(arg)); } };
public static boolean assignable(Class<?> target, Class<?> from) { if ( target.isPrimitive() ) target = CodegenUtils.getBoxType(target); else if ( from == Void.TYPE || target.isAssignableFrom(from) ) { return true; } if ( from.isPrimitive() ) from = CodegenUtils.getBoxType(from); if ( target.isAssignableFrom(from) ) return true; if ( Number.class.isAssignableFrom(target) ) { if ( Number.class.isAssignableFrom(from) ) { return true; } if ( from == Character.class ) { return true; } } else if ( target == Character.class ) { if ( Number.class.isAssignableFrom(from) ) { return true; } } return false; }
public static boolean assignable(Class<?> target, Class<?> from) { if ( target.isPrimitive() ) target = CodegenUtils.getBoxType(target); else if ( from == Void.TYPE || target.isAssignableFrom(from) ) { return true; } if ( from.isPrimitive() ) from = CodegenUtils.getBoxType(from); if ( target.isAssignableFrom(from) ) return true; if ( Number.class.isAssignableFrom(target) ) { if ( Number.class.isAssignableFrom(from) ) { return true; } if ( from == Character.class ) { return true; } } else if ( target == Character.class ) { if ( Number.class.isAssignableFrom(from) ) { return true; } } return false; }
private static int calcTypePreference(Class<?> type, final IRubyObject arg) { final boolean primitive = type.isPrimitive(); if ( primitive ) type = getBoxType(type);
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 JavaMethod(Ruby runtime, Method method) { super(runtime, runtime.getJavaSupport().getJavaMethodClass(), method.getParameterTypes()); this.method = method; this.isFinal = Modifier.isFinal(method.getModifiers()); if (method.getReturnType().isPrimitive() && method.getReturnType() != void.class) { this.boxedReturnType = CodegenUtils.getBoxType(method.getReturnType()); } else { this.boxedReturnType = method.getReturnType(); } boolean methodIsPublic = Modifier.isPublic(method.getModifiers()); boolean classIsPublic = Modifier.isPublic(method.getDeclaringClass().getModifiers()); // 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 (JavaClass.CAN_SET_ACCESSIBLE) { // we should be able to setAccessible ok... try { if (methodIsPublic && !Modifier.isPublic(method.getDeclaringClass().getModifiers())) { accessibleObject().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: " + accessibleObject() + ", exception follows: " + se.getMessage()); } } returnConverter = JavaUtil.getJavaConverter(method.getReturnType()); }
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 JavaMethod(Ruby runtime, Method method) { super(runtime, runtime.getJavaSupport().getJavaMethodClass(), method.getParameterTypes()); this.method = method; this.isFinal = Modifier.isFinal(method.getModifiers()); if (method.getReturnType().isPrimitive() && method.getReturnType() != void.class) { this.boxedReturnType = CodegenUtils.getBoxType(method.getReturnType()); } else { this.boxedReturnType = method.getReturnType(); } boolean methodIsPublic = Modifier.isPublic(method.getModifiers()); boolean classIsPublic = Modifier.isPublic(method.getDeclaringClass().getModifiers()); // 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 (JavaClass.CAN_SET_ACCESSIBLE) { // we should be able to setAccessible ok... try { if (methodIsPublic && !Modifier.isPublic(method.getDeclaringClass().getModifiers())) { accessibleObject().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: " + accessibleObject() + ", exception follows: " + se.getMessage()); } } returnConverter = JavaUtil.getJavaConverter(method.getReturnType()); }
public static void unboxAndCast(SkinnyMethodAdapter m, Class paramClass) { if (paramClass.isPrimitive()) { Class boxType = getBoxType(paramClass); m.checkcast(p(boxType)); m.invokevirtual(p(boxType), paramClass.toString() + "Value", sig(paramClass)); } else if (paramClass != Object.class) { m.checkcast(p(paramClass)); } }
public static void unboxAndCast(SkinnyMethodAdapter m, Class paramClass) { if (paramClass.isPrimitive()) { Class boxType = getBoxType(paramClass); m.checkcast(p(boxType)); m.invokevirtual(p(boxType), paramClass.toString() + "Value", sig(paramClass)); } else if (paramClass != Object.class) { m.checkcast(p(paramClass)); } }
public static void unboxAndCast(SkinnyMethodAdapter m, Class paramClass) { if (paramClass.isPrimitive()) { Class boxType = getBoxType(paramClass); m.checkcast(p(boxType)); m.invokevirtual(p(boxType), paramClass.toString() + "Value", sig(paramClass)); } else if (paramClass != Object.class) { m.checkcast(p(paramClass)); } }
public static void unboxAndCast(SkinnyMethodAdapter m, Class paramClass) { if (paramClass.isPrimitive()) { Class boxType = getBoxType(paramClass); m.checkcast(p(boxType)); m.invokevirtual(p(boxType), paramClass.toString() + "Value", sig(paramClass)); } else if (paramClass != Object.class) { m.checkcast(p(paramClass)); } }
mv.ireturn(); } else { mv.getstatic(p(getBoxType(returnType)), "TYPE", ci(Class.class)); mv.invokeinterface(p(IRubyObject.class), "toJava", sig(Object.class, Class.class)); if (returnType == byte.class) {