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 |