langtools/src/share/classes/com/sun/tools/sjavac/server/PortFile.java
changeset 26098 32588700060b
parent 24067 76e7b6bbbd85
child 26104 34de7e01b3c1
equal deleted inserted replaced
26097:4a16592140fa 26098:32588700060b
    39  * The PortFile class mediates access to a short binary file containing the tcp/ip port (for the localhost)
    39  * The PortFile class mediates access to a short binary file containing the tcp/ip port (for the localhost)
    40  * and a cookie necessary for the server answering on that port. The file can be locked using file system
    40  * and a cookie necessary for the server answering on that port. The file can be locked using file system
    41  * primitives to avoid race conditions when several javac clients are started at the same. Note that file
    41  * primitives to avoid race conditions when several javac clients are started at the same. Note that file
    42  * system locking is not always supported on a all operating systems and/or file systems.
    42  * system locking is not always supported on a all operating systems and/or file systems.
    43  *
    43  *
    44  * <p><b>This is NOT part of any supported API.
    44  *  <p><b>This is NOT part of any supported API.
    45  * If you write code that depends on this, you do so at your own
    45  *  If you write code that depends on this, you do so at your own risk.
    46  * risk.  This code and its internal interfaces are subject to change
    46  *  This code and its internal interfaces are subject to change or
    47  * or deletion without notice.</b></p>
    47  *  deletion without notice.</b>
    48  */
    48  */
    49 class PortFile {
    49 public class PortFile {
    50 
    50 
    51     // Port file format:
    51     // Port file format:
    52     // byte ordering: high byte first = big endian
    52     // byte ordering: high byte first = big endian
    53     // Magic nr, 4 byte int, first in file.
    53     // Magic nr, 4 byte int, first in file.
    54     private final static int magicNr = 0x1174;
    54     private final static int magicNr = 0x1174;
    70 
    70 
    71     /**
    71     /**
    72      * Create a new portfile.
    72      * Create a new portfile.
    73      * @param filename is the path to the file.
    73      * @param filename is the path to the file.
    74      */
    74      */
    75     public PortFile(String fn) throws FileNotFoundException
    75     public PortFile(String fn) throws FileNotFoundException {
    76     {
       
    77         filename = fn;
    76         filename = fn;
    78         file = new File(filename);
    77         file = new File(filename);
    79         stopFile = new File(filename+".stop");
    78         stopFile = new File(filename+".stop");
    80         rwfile = new RandomAccessFile(file, "rw");
    79         rwfile = new RandomAccessFile(file, "rw");
    81         // The rwfile should only be readable by the owner of the process
    80         // The rwfile should only be readable by the owner of the process
    86     }
    85     }
    87 
    86 
    88     /**
    87     /**
    89      * Lock the port file.
    88      * Lock the port file.
    90      */
    89      */
    91     void lock() throws IOException {
    90     public void lock() throws IOException {
    92         lock = channel.lock();
    91         lock = channel.lock();
    93     }
    92     }
    94 
    93 
    95     /**
    94     /**
    96      * Read the values from the port file in the file system.
    95      * Read the values from the port file in the file system.
   113                     containsPortInfo = true;
   112                     containsPortInfo = true;
   114                 } else {
   113                 } else {
   115                     containsPortInfo = false;
   114                     containsPortInfo = false;
   116                 }
   115                 }
   117             }
   116             }
   118         } catch (Exception e) {
   117         } catch (IOException e) {
   119             containsPortInfo = false;
   118             containsPortInfo = false;
   120         }
   119         }
   121     }
   120     }
   122 
   121 
   123     /**
   122     /**