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

java compiler never closes any of the ZipFile objects

    Details

    • Subcomponent:
    • CPU:
      x86
    • OS:
      windows_nt

      Description

      On Windows using JDK1.4.0_01 the following occurs.

      The problem is that the compiler will open all of the ZIP / JAR
      files in the classpath and never close them. When you are running
      the compiler standalone, it's not a problem, but when you run the
      compiler in a long-running process it is. If the ZIP / JAR files do
      not get closed then they are locked by the filesystem and cannot be
      replaced.

      In com/sun/tools/javac/v8/code/ClassReader.java, openArchive()
      opens a ZipFile to the archive and stores that ZipFile object. When the
      compilation is finished, the ZipFiles are never close()ed.

      The classic javac compiler does not exhibit this behavior.

      To recreate the problem compile Compiler2.java specifying the tools.jar in the
      classpath and using java from 1.4.0 and run the Compiler2.class. This file will
      compile all the java files from the jar then sleep for about 10 seconds.

      At this point try moving one of the jar files to a different directory and the
      following message will appear:

      C:\Users\atongsch\Support\SilverStream\792653>\j2sdk1.4.0\bin\java
      -classpath \j 2sdk1.4.0\lib\tools.jar;. Compiler2
      Ready to Compile 2...
      Status = 0
      Done Compiling.
      Going to Sleep.
      Done Sleeping.

      C:\Users\atongsch\Support\SilverStream\792653>mv ojdbc14.jar .. mv:
      cannot rename "ojdbc14.jar" to "../ojdbc14.jar": The process cannot
      access the file because it is being used by another process.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                gafter Neal Gafter
                Reporter:
                atongschsunw Albert Tong-schmidt (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: