From 3773b1a480d069417db913539197a64a797bff70 Mon Sep 17 00:00:00 2001 From: Brian Jones Date: Thu, 21 Mar 2002 05:40:10 +0000 Subject: The following changes are all from patch submissions from Intel's ORP team to get Classpath into a JBOSS compatible state. This is primarily just the non-public API patches. * gnu/java/io/PlatformHelper.java: new file * gnu/java/io/Makefile.am: add new file to EXTRA_DIST * gnu/java/lang/ClassLoaderHelper.java (getSystemResourceAsFile): add support for .zip/.jar archive loading * gnu/java/lang/reflect/TypeSignature.java: additional comments * gnu/java/net/protocol/file/FileURLConnection.java (connect): if file does not exist, throw FileNotFoundException * gnu/java/net/protocol/file/Handler.java (parseURL): override method from URLStreamHandler for parsing file URL * gnu/java/net/protocol/jar/JarURLConnection.java: new file * gnu/java/net/protocol/jar/Handler.java: new file * gnu/java/net/protocol/jar/.cvsignore: new file * gnu/java/net/protocol/jar/Makefile.am: new file * gnu/java/net/protocol/Makefile.am: add jar to SUBDIRS * gnu/java/rmi/RMIMarshalledObjectInputStream.java: new file * gnu/java/rmi/RMIMarshalledObjectOutputStream.java: new file * gnu/java/rmi/Makefile.am: add new file to EXTRA_DIST * gnu/java/rmi/dgc/DGCImpl.java (dirty): partially implemented * gnu/java/rmi/server/Makefile.am: add new file to EXTRA_DIST * gnu/java/rmi/server/ConnectionRunnerPool.java: new file * gnu/java/rmi/server/RMIHashes.java (getMethodHash): conformance to object serialization specification 8.3 * gnu/java/rmi/server/RMIObjectInputStream.java (RMIObjectInputStream): new constructor (resolveClass): try additional method of loading class and catch exception from super.resolveClass (getAnnotation): new method (resolveProxyClass): new method (readValue): new method * gnu/java/rmi/server/RMIObjectOutputStream.java (setAnnotation): new method (annotateClass): use new setAnnotation method (annotateProxyClass): new method (replaceObject): new method (writeValue): new method * gnu/java/rmi/server/UnicastConnection.java (acceptConnection): use buffered streams to improve efficiency (makeConnection): ditto (disconnect): close oout stream if needed * gnu/java/rmi/server/UnicastConnectionManager.java (static): use host address instead of host name (getInstance): ditto (stopServer): new method (run): exit thread if server thread is null * gnu/java/rmi/server/UnicastRef.java (invokeCommon): handle primitive types and null return type (writeExternal): remove write of RETURN_ACK because it confuses Sun's implementation when interoperating (readExternal): similarly read of RETURN_ACK or Sun's value ok * gnu/java/rmi/server/UnicastServer.java (unexportObject): new method (incomingMessageCall): check for primitive type and write it out correctly * gnu/java/rmi/server/UnicastServerRef.java: implements ServerRef (exportObject): call new exportObject method with argument (exportObject): new method, not completely implemented (unexportObject): new method (getHelperClass): remove use of Class.forName (buildMethodHash): boolean argument allows build up or tear down of method hash (getMethodReturnType): new method (incomingMessageCall): handle exceptions from meth.invoke differently * gnu/java/security/provider/DefaultPolicy.java (getPermissions): do not maintain static class variable of Permissions * gnu/java/security/provider/SHA.java (engineUpdate): algorithm change (engineDigest): algorithm change * java/io/ObjectInputStream.java (resolveProxyClass): new method * configure.in: add new Makefiles to AC_OUTPUT --- gnu/java/rmi/server/RMIObjectInputStream.java | 84 +++++++++++++++++++++++---- 1 file changed, 73 insertions(+), 11 deletions(-) (limited to 'gnu/java/rmi/server/RMIObjectInputStream.java') diff --git a/gnu/java/rmi/server/RMIObjectInputStream.java b/gnu/java/rmi/server/RMIObjectInputStream.java index 70b6c53c3..5913e9221 100644 --- a/gnu/java/rmi/server/RMIObjectInputStream.java +++ b/gnu/java/rmi/server/RMIObjectInputStream.java @@ -44,6 +44,8 @@ import java.io.IOException; import java.net.URL; import java.net.MalformedURLException; import java.rmi.server.RMIClassLoader; +import java.lang.ClassNotFoundException; +import java.lang.reflect.Proxy; public class RMIObjectInputStream extends ObjectInputStream { @@ -56,20 +58,80 @@ public RMIObjectInputStream(InputStream strm, UnicastConnectionManager man) thro enableResolveObject(true); } +public RMIObjectInputStream(InputStream strm) throws IOException { + this(strm, UnicastConnectionManager.getInstance(0, null)); +} + protected Class resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException { -//System.out.println("Resolving class: " + desc.getName()); - String annotation = (String)readObject(); - if (annotation == null) { - return (super.resolveClass(desc)); + String annotation = (String)getAnnotation(); + try{ + return super.resolveClass(desc); + }catch(ClassNotFoundException _){}; + + try { + if(annotation == null) + return (RMIClassLoader.loadClass(desc.getName())); + else + return (RMIClassLoader.loadClass(annotation, desc.getName())); } - else { - try { - return (RMIClassLoader.loadClass(new URL(annotation), desc.getName())); - } - catch (MalformedURLException _) { - throw new ClassNotFoundException(desc.getName()); - } + catch (MalformedURLException _) { + throw new ClassNotFoundException(desc.getName()); } } +//Separate it for override by MarshalledObject +protected Object getAnnotation() + throws IOException, ClassNotFoundException +{ + return readObject(); +} + +protected Class resolveProxyClass(String intfs[]) + throws IOException, ClassNotFoundException +{ + String annotation = (String)getAnnotation(); + try{ + return super.resolveProxyClass(intfs); + }catch(ClassNotFoundException _){}; + + Class clss[] = new Class[intfs.length]; + if(annotation == null) + clss[0] = RMIClassLoader.loadClass(intfs[0]); + else + clss[0] = RMIClassLoader.loadClass(annotation, intfs[0]); + //assume all interfaces can be loaded by the same classloader + ClassLoader loader = clss[0].getClassLoader(); + if(loader == null) + for(int i = 1; i < intfs.length; i++) + clss[i] = Class.forName(intfs[i]); + else + for(int i = 1; i < intfs.length; i++) + clss[i] = loader.loadClass(intfs[i]); + return Proxy.getProxyClass(loader, clss); +} + +protected Object readValue(Class valueClass) throws IOException, ClassNotFoundException { + if(valueClass.isPrimitive()){ + if(valueClass == Boolean.TYPE) + return new Boolean(readBoolean()); + if(valueClass == Byte.TYPE) + return new Byte(readByte()); + if(valueClass == Character.TYPE) + return new Character(readChar()); + if(valueClass == Short.TYPE) + return new Short(readShort()); + if(valueClass == Integer.TYPE) + return new Integer(readInt()); + if(valueClass == Long.TYPE) + return new Long(readLong()); + if(valueClass == Float.TYPE) + return new Float(readFloat()); + if(valueClass == Double.TYPE) + return new Double(readDouble()); + else + throw new Error("Unsupported primitive class: " + valueClass); + } else + return readObject(); } + +} \ No newline at end of file -- cgit v1.2.1