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

Class.forName() on Windows is case-insensitive (excluding zips)

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      1.1.4
    • CPU:
      x86
    • OS:
      generic, windows_nt
    • Verification:
      Not verified

      Description

      I thought that an invariant of a successful Class.forName() was

      Class.forName(X).getName().equals(X);

      We rarely (before finding this bug to workaround) ever check the
      name of a Class returned by Class.forName().

      On Windows 95 (at least, haven't verified on NT)

      If there is a file XyZ.class containing class XyZ, then I would
      have expected Class.forName("xyz") or Class.forName("XYZ") to fail,
      as they do on Solaris.

      However, this is not the case. Any capitalization of the class name will
      return the same result, class XyZ.

      First, this is a compatibility issue. Second, I thought Java was a case-sensitive language.

      Simplest test code:

      public class CfN {

        public static void main(String[] args) throws Throwable {
          Class c = Class.forName(args[0]);
          System.err.println(c);
          System.err.println("correct name? "+(c.getName().equals(args[0])));
        }

      }

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              dconnellsunw David Connelly (Inactive)
              Reporter:
              duke J. Duke (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: