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

URLClassLoader.getResourceAsStream locks jar files

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P2
    • Resolution: Won't Fix
    • Affects Version/s: 1.4.2, 1.4.2_04
    • Fix Version/s: 7
    • Component/s: core-libs
    • Subcomponent:
    • CPU:
      x86
    • OS:
      windows_xp

      Description

      To reproduce the problem, on a Windows machine, create a test.jar, and run the following test case in jdb. Stop at the first println, "test.jar" is now locked and cannot be deleted.

      Note that the test is only trying to get a non-existant resource. Note also that this is only a problem for the Windows platform.

      This bug breaks an important functionality in AppServer, because it makes undeployment of a web applications impossible (in Windows), because jar files in it cannot be deleted. See bug 5004315. There does not seems to be any workarounds.

      % cat Test.java
      import java.io.*;
      import java.net.*;

      class Test {
          public static void main(String args[]) {

              try {
                  File jarf = (new File("test.jar")).getCanonicalFile();
                  URL urls[] = { jarf.toURL() };
                  URLClassLoader loader =
                      new URLClassLoader(urls, Test.class.getClassLoader());
                  InputStream is = loader.getResourceAsStream("BadName");
                  System.out.println("stream is " + is);
              } catch (Exception ex) {
                  System.out.println("Error: " + ex);
              }
          }
      }


      ###@###.### 2004-04-30

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                michaelm Michael McMahon
                Reporter:
                kichung Kinman Chung (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: