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()); 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()); 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); }