Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4496398

MarshalledObject fails with objects loaded from file urls with spaces

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.3.1
    • core-libs
    • generic
    • generic

      Name: bsC130419 Date: 08/24/2001


      Space Here 1168>java -version
      java version "1.3.1"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1-b24)
      Java HotSpot(TM) Client VM (build 1.3.1-b24, mixed mode)

      If the URLClassLoader for a class that is serialized using a MarshalledObject
      is made of a files that contain spaces in their path, unmarshalling the object
      fails because the space is seen a seperator between urls by the
      sun.rmi.server.LoaderHandler.pathToURLs method. This is may be another
      problem related to bugID 4273532?

      Here is a trival example that demonstrates the problem:

      Space Here 1162>ls
      ASerializable.java ser.jar tstMO.class tstMO.java
      Space Here 1163>pwd
      /tmp/Space Here
      Space Here 1164>java tstMO
      cwd = file:/tmp/Space Here/./
      serializable class = class java.lang.Class
      serializable codesource = null
      Exception in thread "main" java.net.MalformedURLException: no protocol:
      Here/./ser.jar
              at java.net.URL.<init>(URL.java:473)
              at java.net.URL.<init>(URL.java:376)
              at java.net.URL.<init>(URL.java:330)
              at sun.rmi.server.LoaderHandler.pathToURLs(LoaderHandler.java:387)
              at sun.rmi.server.LoaderHandler.loadClass(LoaderHandler.java:132)
              at sun.rmi.server.MarshalInputStream.resolveClass
      (MarshalInputStream.java:143)
              at java.io.ObjectInputStream.inputClassDescriptor
      (ObjectInputStream.java:918)
              at java.io.ObjectInputStream.readObject(ObjectInputStream.java:366)
              at java.io.ObjectInputStream.readObject(ObjectInputStream.java:350)
              at java.io.ObjectInputStream.readObject(ObjectInputStream.java:236)
              at java.rmi.MarshalledObject.get(MarshalledObject.java:138)
              at tstMO.main(tstMO.java:21)
      Space Here 1165>cat tstMO.java
      import java.io.*;
      import java.net.*;
      import java.rmi.*;
      import java.security.*;

      class tstMO
      {
         public static void main(String[] args) throws Exception
         {
            File cwd = new File(".");
            File jarFile = new File(cwd, "ser.jar");
            System.out.println("cwd = "+cwd.toURL());
            URL[] urls = {jarFile.toURL()};
            URLClassLoader cl = new URLClassLoader(urls);
            Object serializable = cl.loadClass("ASerializable");
            Class sc = serializable.getClass();
            System.out.println("serializable class = "+sc);
            CodeSource cs = sc.getProtectionDomain().getCodeSource();
            System.out.println("serializable codesource = "+cs);
            MarshalledObject mo = new MarshalledObject(serializable);
            System.out.println("mo.get() ->"+mo.get());
         }
      }

      Space Here 1166>cat ASerializable.java

      public class ASerializable implements java.io.Serializable
      {
      }
      Space Here 1167>jar -tf ser.jar
      META-INF/
      META-INF/MANIFEST.MF
      ASerializable.class
      Space Here 1168>
      (Review ID: 130662)
      ======================================================================
      ###@###.### 10/15/04 17:21 GMT

            peterjones Peter Jones (Inactive)
            bstrathesunw Bill Strathearn (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: