JDK-4261416 : '#' in path breaks the search algorith for classes
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.net
  • Affected Version: 1.2.0,1.2.1,1.2.2
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic,solaris_2.6,windows_nt
  • CPU: generic,x86
  • Submitted: 1999-08-10
  • Updated: 1999-09-21
  • Resolved: 1999-09-21
Related Reports
Duplicate :  
Duplicate :  
Relates :  
Description

Name: krT82822			Date: 08/10/99


When I save .class files in a directory which
has a '#' in its name, the classloader doesn't
find the classes. This works with every java programm.
Here is a script of a CMD.EXE session. It shows
a java programm which runs perfect ... but when
you rename the directory the class file is stored
in to something containing a '#' the program stops
running. BTW: Classpath variable is not set, test class
is in the default package.

------------------------------------------------------
D:\chris\java\src>set CLASSPATH
Die Umgebungsvariable CLASSPATH ist nicht definiert.

D:\chris\java\src>java -version
java version "1.2.2"
Classic VM (build JDK-1.2.2-W, native threads, symcjit)

D:\chris\java\src>dir /B TT.*
TT.class
TT.java

D:\chris\java\src>java TT
Hello World, I am TT


D:\chris\java\src>cd ..

D:\chris\java>rename src src#ddd

D:\chris\java>cd src#ddd

D:\chris\java\src#ddd>java TT
java.lang.NoClassDefFoundError: TT
Exception in thread "main" 
D:\chris\java\src#ddd>type TT.java

public class TT {
  public static void main(String args[]) {
    System.out.println("Hello World, I am TT\n");
  }
}
-----------------------------------------------------------
(Review ID: 93389) 
======================================================================

Comments
WORK AROUND Name: krT82822 Date: 08/10/99 Rename the directory the classes are stored in ====================================================================== thomas.lenz@Germany 1999-08-13 ------------------------------ W/A1: The only workaround at the moment is, copying the complete source tree and renaming all directories. Clearly, this is not acceptible for the customer, as this has to done for every test. Adding symbolic links did not help. W/A2: Probably the use of lofs is another workaround: lab156:/home/thomas/Calls/JAVA/6537147 76 % ls src#a lab156:/home/thomas/Calls/JAVA/6537147 77 % mkdir src lab156:/home/thomas/Calls/JAVA/6537147 78 % ls src src#a lab156:/home/thomas/Calls/JAVA/6537147 79 % su Password: # mount -F lofs /home/thomas/Calls/JAVA/6537147/src#a /home/thomas/Calls/JAVA/6537147/src # ls src TT.class TT.java # ^D lab156:/home/thomas/Calls/JAVA/6537147 80 % cd src#a lab156:/home/thomas/Calls/JAVA/6537147/src#a 81 % ls TT.class TT.java lab156:/home/thomas/Calls/JAVA/6537147/src#a 82 % setenv CLASSPATH /home/thomas/Calls/JAVA/6537147/src lab156:/home/thomas/Calls/JAVA/6537147/src#a 83 % /usr/java1.2/bin/java TT Hello World, I am TT lab156:/home/thomas/Calls/JAVA/6537147/src#a 84 %
11-06-2004

EVALUATION I reproduce the bug. Need further investigation. ###@###.### 1999-08-17 This problem is caused by url parsing, because '#' conflict with HTML section id. For example, the following url: file:/home/foo/public_html/hello.html#first will be translated into file path "/home/foo/public_html/hello.html". However if the path name does contain the '#' character, we are out of luck. My suggestion is not to fix this problem. ###@###.### 1999-09-10 Does java.io.File's toURL() method comes into play here? I don't remember offhand if this is how classpath elements are converted into URLs as part of the class loading implementation. If so, this may be an underlying bug in the File class since toURL() does not escape any of the illegal URL characters like it should such as the space character or the '#' character. See also 4273532. jeff.nisewanger@Eng 1999-09-20 It IS a dup of 4273532. URLClassLoader does convert everything on the classpath to a list of URLs. If a file directory contains reserved characters like '#', the current File.toURL cannot handle it. ###@###.### 1999-09-21
21-09-1999