JDK-6725672 : Two open file handles for every jar in jdk6, but one in jdk 1.5
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util.jar
  • Affected Version: 6u7
  • Priority: P2
  • Status: Closed
  • Resolution: Not an Issue
  • OS: linux
  • CPU: x86
  • Submitted: 2008-07-14
  • Updated: 2010-04-02
  • Resolved: 2008-07-15
Related Reports
Relates :  
Description
Problem description:

With jdk 1.5 we have one handle (memory mapped file handle) opened for every jars but in jdk 6 we have two open file handles for every jars (one handle is the memory mapped handle as in jdk 1.5 and the other one is a handle for (Reg) regular file).

Steps to reproduce:

See comments section how to reproduce at Sun Internal network.

Download JDeveloper 11 Technology Preview 4 from Oracle website (get jdevstudiobase1111.zip) and run it with the command line arguments mentioned below.

http://www.oracle.com/technology/software/products/jdev/htdocs/soft11tp.html

Let's assume jdev is installed under /jdev/jdevtp4 and 1.5 and 6 are available respectively from /java/jdk1.5.0_16 and /java/jdk6_07. 

Use the following command lines and call lsof on the process id after starting up jdeveloper.

sh /jdev/jdevtp4/jdev/bin/jdev -su -J-Dide.jarcache.disabled=true --setjavahome=/java/jdk1.5.0_16
sh /jdev/jdevtp4/jdev/bin/jdev -su -J-Dide.jarcache.disabled=true --setjavahome=/java/jdk6_07


Essentially all jars that we have opened while starting jdeveloper appears as a single handle under 1.5 and two handles under 1.6

1.5 :

java      13012  user  mem       REG      253,0   749921 39813272 bc4jtester.jar

6 :

java       6284  user  289r      REG      253,0   749921 39813272  bc4jtester.jar
java       6284  user  mem       REG      253,0   749921 39813272  bc4jtester.jar

Comments
EVALUATION In JDK 5 the entire JAR file is mmap'd. In JDK 6, the JAR file's central directory is mmap'd, but the entries themselves are read. These show up in lsof as 2 separate entries. See 6280693. The attached JarHandles.java can be used to demonstrate the issue, and is likely to be simpler than downloading and installing JDeveloper 11 Technology Preview 4 from Oracle.
15-07-2008