public synchronized DynamicMethodMarshaller getDynamicMethodMarshaller(Method method) { if (method == null) return null; DynamicMethodMarshaller result = methodToDMM.get(method); if (result == null) { result = new DynamicMethodMarshallerImpl(method); methodToDMM.put(method, result); } return result; }
private static boolean isAbstractInterface(Class<?> cls) { // Either cls is an interface that extends IDLEntity, or else cls does not extend java.rmi.Remote and all of its // methods throw RemoteException. if (IDLEntity.class.isAssignableFrom(cls)) return cls.isInterface(); else return cls.isInterface() && allMethodsThrowRemoteException(cls); }
private static boolean allMethodsThrowRemoteException(Class<?> cls) { Method[] methods = cls.getMethods(); // Check that all methods (other than those declared in java.lang.Object) throw an exception that is a subclass // of RemoteException. for (int ctr = 0; ctr < methods.length; ctr++) { Method method = methods[ctr]; if (method.getDeclaringClass() != Object.class) if (!throwsRemote(method)) return false; } return true; }
else if (isAnyClass(cls)) return anyRW; else if (isAbstractInterface(cls)) return abstractInterfaceRW;
public DynamicMethodMarshallerImpl(Method method) { this.method = method; ehandler = new ExceptionHandlerImpl(method.getExceptionTypes()); needsArgumentCopy = false; Class<?>[] argTypes = method.getParameterTypes(); hasArguments = argTypes.length > 0; if (hasArguments) { argRWs = new ReaderWriter[argTypes.length]; for (int ctr = 0; ctr < argTypes.length; ctr++) { // This could be further optimized to avoid copying if argTypes contains at most one immutable object // type. if (!argTypes[ctr].isPrimitive()) needsArgumentCopy = true; argRWs[ctr] = makeReaderWriter(argTypes[ctr]); } } Class<?> resultType = method.getReturnType(); needsResultCopy = false; hasVoidResult = resultType.equals(void.class); if (!hasVoidResult) { needsResultCopy = !resultType.isPrimitive(); resultRW = makeReaderWriter(resultType); } }
else if (isAnyClass(cls)) return anyRW; else if (isAbstractInterface(cls)) return abstractInterfaceRW;
public DynamicMethodMarshallerImpl(Method method) { this.method = method; ehandler = new ExceptionHandlerImpl(method.getExceptionTypes()); needsArgumentCopy = false; Class<?>[] argTypes = method.getParameterTypes(); hasArguments = argTypes.length > 0; if (hasArguments) { argRWs = new ReaderWriter[argTypes.length]; for (int ctr = 0; ctr < argTypes.length; ctr++) { // This could be further optimized to avoid copying if argTypes contains at most one immutable object // type. if (!argTypes[ctr].isPrimitive()) needsArgumentCopy = true; argRWs[ctr] = makeReaderWriter(argTypes[ctr]); } } Class<?> resultType = method.getReturnType(); needsResultCopy = false; hasVoidResult = resultType.equals(void.class); if (!hasVoidResult) { needsResultCopy = !resultType.isPrimitive(); resultRW = makeReaderWriter(resultType); } }
private static boolean isAbstractInterface(Class<?> cls) { // Either cls is an interface that extends IDLEntity, or else cls does not extend java.rmi.Remote and all of its // methods throw RemoteException. if (IDLEntity.class.isAssignableFrom(cls)) return cls.isInterface(); else return cls.isInterface() && allMethodsThrowRemoteException(cls); }
public synchronized DynamicMethodMarshaller getDynamicMethodMarshaller(Method method) { if (method == null) return null; DynamicMethodMarshaller result = methodToDMM.get(method); if (result == null) { result = new DynamicMethodMarshallerImpl(method); methodToDMM.put(method, result); } return result; }
private static boolean allMethodsThrowRemoteException(Class<?> cls) { Method[] methods = cls.getMethods(); // Check that all methods (other than those declared in java.lang.Object) throw an exception that is a subclass // of RemoteException. for (int ctr = 0; ctr < methods.length; ctr++) { Method method = methods[ctr]; if (method.getDeclaringClass() != Object.class) if (!throwsRemote(method)) return false; } return true; }