src/share/classes/sun/rmi/server/Util.java

Print this page

        

*** 117,132 **** * @throws IllegalArgumentException if implClass implements illegal * remote interfaces * @throws StubNotFoundException if problem locating/creating stub or * creating the dynamic proxy instance **/ ! public static Remote createProxy(Class implClass, RemoteRef clientRef, boolean forceStubUse) throws StubNotFoundException { ! Class remoteClass; try { remoteClass = getRemoteClass(implClass); } catch (ClassNotFoundException ex ) { throw new StubNotFoundException( --- 117,132 ---- * @throws IllegalArgumentException if implClass implements illegal * remote interfaces * @throws StubNotFoundException if problem locating/creating stub or * creating the dynamic proxy instance **/ ! public static Remote createProxy(Class<?> implClass, RemoteRef clientRef, boolean forceStubUse) throws StubNotFoundException { ! Class<?> remoteClass; try { remoteClass = getRemoteClass(implClass); } catch (ClassNotFoundException ex ) { throw new StubNotFoundException(
*** 160,170 **** * Returns true if a stub class for the given impl class can be loaded, * otherwise returns false. * * @param remoteClass the class to obtain remote interfaces from */ ! private static boolean stubClassExists(Class remoteClass) { if (!withoutStubs.containsKey(remoteClass)) { try { Class.forName(remoteClass.getName() + "_Stub", false, remoteClass.getClassLoader()); --- 160,170 ---- * Returns true if a stub class for the given impl class can be loaded, * otherwise returns false. * * @param remoteClass the class to obtain remote interfaces from */ ! private static boolean stubClassExists(Class<?> remoteClass) { if (!withoutStubs.containsKey(remoteClass)) { try { Class.forName(remoteClass.getName() + "_Stub", false, remoteClass.getClassLoader());
*** 180,194 **** /* * Returns the class/superclass that implements the remote interface. * @throws ClassNotFoundException if no class is found to have a * remote interface */ ! private static Class getRemoteClass(Class cl) throws ClassNotFoundException { while (cl != null) { ! Class[] interfaces = cl.getInterfaces(); for (int i = interfaces.length -1; i >= 0; i--) { if (Remote.class.isAssignableFrom(interfaces[i])) return cl; // this class implements remote object } cl = cl.getSuperclass(); --- 180,194 ---- /* * Returns the class/superclass that implements the remote interface. * @throws ClassNotFoundException if no class is found to have a * remote interface */ ! private static Class<?> getRemoteClass(Class<?> cl) throws ClassNotFoundException { while (cl != null) { ! Class<?>[] interfaces = cl.getInterfaces(); for (int i = interfaces.length -1; i >= 0; i--) { if (Remote.class.isAssignableFrom(interfaces[i])) return cl; // this class implements remote object } cl = cl.getSuperclass();
*** 204,215 **** * @param remoteClass the class to obtain remote interfaces from * @throws IllegalArgumentException if remoteClass implements * any illegal remote interfaces * @throws NullPointerException if remoteClass is null */ ! private static Class[] getRemoteInterfaces(Class remoteClass) { ! ArrayList<Class<?>> list = new ArrayList<Class<?>>(); getRemoteInterfaces(list, remoteClass); return list.toArray(new Class<?>[list.size()]); } /** --- 204,215 ---- * @param remoteClass the class to obtain remote interfaces from * @throws IllegalArgumentException if remoteClass implements * any illegal remote interfaces * @throws NullPointerException if remoteClass is null */ ! private static Class<?>[] getRemoteInterfaces(Class<?> remoteClass) { ! ArrayList<Class<?>> list = new ArrayList<>(); getRemoteInterfaces(list, remoteClass); return list.toArray(new Class<?>[list.size()]); } /**
*** 218,236 **** * * @throws IllegalArgumentException if the specified class implements * any illegal remote interfaces * @throws NullPointerException if the specified class or list is null */ ! private static void getRemoteInterfaces(ArrayList<Class<?>> list, Class cl) { ! Class superclass = cl.getSuperclass(); if (superclass != null) { getRemoteInterfaces(list, superclass); } ! Class[] interfaces = cl.getInterfaces(); for (int i = 0; i < interfaces.length; i++) { ! Class intf = interfaces[i]; /* * If it is a remote interface (if it extends from * java.rmi.Remote) and is not already in the list, * then add the interface to the list. */ --- 218,236 ---- * * @throws IllegalArgumentException if the specified class implements * any illegal remote interfaces * @throws NullPointerException if the specified class or list is null */ ! private static void getRemoteInterfaces(ArrayList<Class<?>> list, Class<?> cl) { ! Class<?> superclass = cl.getSuperclass(); if (superclass != null) { getRemoteInterfaces(list, superclass); } ! Class<?>[] interfaces = cl.getInterfaces(); for (int i = 0; i < interfaces.length; i++) { ! Class<?> intf = interfaces[i]; /* * If it is a remote interface (if it extends from * java.rmi.Remote) and is not already in the list, * then add the interface to the list. */
*** 270,280 **** * implements a remote interface. The stub class name is the name of * the specified remoteClass with the suffix "_Stub". The loading of * the stub class is initiated from class loader of the specified class * (which may be the bootstrap class loader). **/ ! private static RemoteStub createStub(Class remoteClass, RemoteRef ref) throws StubNotFoundException { String stubname = remoteClass.getName() + "_Stub"; /* Make sure to use the local stub loader for the stub classes. --- 270,280 ---- * implements a remote interface. The stub class name is the name of * the specified remoteClass with the suffix "_Stub". The loading of * the stub class is initiated from class loader of the specified class * (which may be the bootstrap class loader). **/ ! private static RemoteStub createStub(Class<?> remoteClass, RemoteRef ref) throws StubNotFoundException { String stubname = remoteClass.getName() + "_Stub"; /* Make sure to use the local stub loader for the stub classes.
*** 283,293 **** * pickle methods */ try { Class<?> stubcl = Class.forName(stubname, false, remoteClass.getClassLoader()); ! Constructor cons = stubcl.getConstructor(stubConsParamTypes); return (RemoteStub) cons.newInstance(new Object[] { ref }); } catch (ClassNotFoundException e) { throw new StubNotFoundException( "Stub class not found: " + stubname, e); --- 283,293 ---- * pickle methods */ try { Class<?> stubcl = Class.forName(stubname, false, remoteClass.getClassLoader()); ! Constructor<?> cons = stubcl.getConstructor(stubConsParamTypes); return (RemoteStub) cons.newInstance(new Object[] { ref }); } catch (ClassNotFoundException e) { throw new StubNotFoundException( "Stub class not found: " + stubname, e);
*** 313,323 **** * Locate and return the Skeleton for the specified remote object */ static Skeleton createSkeleton(Remote object) throws SkeletonNotFoundException { ! Class cl; try { cl = getRemoteClass(object.getClass()); } catch (ClassNotFoundException ex ) { throw new SkeletonNotFoundException( "object does not implement a remote interface: " + --- 313,323 ---- * Locate and return the Skeleton for the specified remote object */ static Skeleton createSkeleton(Remote object) throws SkeletonNotFoundException { ! Class<?> cl; try { cl = getRemoteClass(object.getClass()); } catch (ClassNotFoundException ex ) { throw new SkeletonNotFoundException( "object does not implement a remote interface: " +
*** 325,335 **** } // now try to load the skeleton based ont he name of the class String skelname = cl.getName() + "_Skel"; try { ! Class skelcl = Class.forName(skelname, false, cl.getClassLoader()); return (Skeleton)skelcl.newInstance(); } catch (ClassNotFoundException ex) { throw new SkeletonNotFoundException("Skeleton class not found: " + skelname, ex); --- 325,335 ---- } // now try to load the skeleton based ont he name of the class String skelname = cl.getName() + "_Skel"; try { ! Class<?> skelcl = Class.forName(skelname, false, cl.getClassLoader()); return (Skeleton)skelcl.newInstance(); } catch (ClassNotFoundException ex) { throw new SkeletonNotFoundException("Skeleton class not found: " + skelname, ex);
*** 389,404 **** * the definition of a "method descriptor". */ private static String getMethodNameAndDescriptor(Method m) { StringBuffer desc = new StringBuffer(m.getName()); desc.append('('); ! Class[] paramTypes = m.getParameterTypes(); for (int i = 0; i < paramTypes.length; i++) { desc.append(getTypeDescriptor(paramTypes[i])); } desc.append(')'); ! Class returnType = m.getReturnType(); if (returnType == void.class) { // optimization: handle void here desc.append('V'); } else { desc.append(getTypeDescriptor(returnType)); } --- 389,404 ---- * the definition of a "method descriptor". */ private static String getMethodNameAndDescriptor(Method m) { StringBuffer desc = new StringBuffer(m.getName()); desc.append('('); ! Class<?>[] paramTypes = m.getParameterTypes(); for (int i = 0; i < paramTypes.length; i++) { desc.append(getTypeDescriptor(paramTypes[i])); } desc.append(')'); ! Class<?> returnType = m.getReturnType(); if (returnType == void.class) { // optimization: handle void here desc.append('V'); } else { desc.append(getTypeDescriptor(returnType)); }
*** 407,417 **** /** * Get the descriptor of a particular type, as appropriate for either * a parameter or return type in a method descriptor. */ ! private static String getTypeDescriptor(Class type) { if (type.isPrimitive()) { if (type == int.class) { return "I"; } else if (type == boolean.class) { return "Z"; --- 407,417 ---- /** * Get the descriptor of a particular type, as appropriate for either * a parameter or return type in a method descriptor. */ ! private static String getTypeDescriptor(Class<?> type) { if (type.isPrimitive()) { if (type == int.class) { return "I"; } else if (type == boolean.class) { return "Z";
*** 452,461 **** * top-level types, so for a nested type, the returned name will * still be qualified with the simple name of its enclosing * top-level type (and perhaps other enclosing types), the * separator will be '$', etc. **/ ! public static String getUnqualifiedName(Class c) { String binaryName = c.getName(); return binaryName.substring(binaryName.lastIndexOf('.') + 1); } } --- 452,461 ---- * top-level types, so for a nested type, the returned name will * still be qualified with the simple name of its enclosing * top-level type (and perhaps other enclosing types), the * separator will be '$', etc. **/ ! public static String getUnqualifiedName(Class<?> c) { String binaryName = c.getName(); return binaryName.substring(binaryName.lastIndexOf('.') + 1); } }