2220 {
2221 s.defaultWriteObject();
2222 s.writeChar(separatorChar); // Add the separator character
2223 }
2224
2225 /**
2226 * readObject is called to restore this filename.
2227 * The original separator character is read. If it is different
2228 * than the separator character on this system, then the old separator
2229 * is replaced by the local separator.
2230 */
2231 private synchronized void readObject(java.io.ObjectInputStream s)
2232 throws IOException, ClassNotFoundException
2233 {
2234 ObjectInputStream.GetField fields = s.readFields();
2235 String pathField = (String)fields.get("path", null);
2236 char sep = s.readChar(); // read the previous separator char
2237 if (sep != separatorChar)
2238 pathField = pathField.replace(sep, separatorChar);
2239 String path = fs.normalize(pathField);
2240 UNSAFE.putObject(this, PATH_OFFSET, path);
2241 UNSAFE.putIntVolatile(this, PREFIX_LENGTH_OFFSET, fs.prefixLength(path));
2242 }
2243
2244 private static final jdk.internal.misc.Unsafe UNSAFE
2245 = jdk.internal.misc.Unsafe.getUnsafe();
2246 private static final long PATH_OFFSET
2247 = UNSAFE.objectFieldOffset(File.class, "path");
2248 private static final long PREFIX_LENGTH_OFFSET
2249 = UNSAFE.objectFieldOffset(File.class, "prefixLength");
2250
2251 /** use serialVersionUID from JDK 1.0.2 for interoperability */
2252 private static final long serialVersionUID = 301077366599181567L;
2253
2254 // -- Integration with java.nio.file --
2255
2256 private transient volatile Path filePath;
2257
2258 /**
2259 * Returns a {@link Path java.nio.file.Path} object constructed from
2260 * this abstract path. The resulting {@code Path} is associated with the
|
2220 {
2221 s.defaultWriteObject();
2222 s.writeChar(separatorChar); // Add the separator character
2223 }
2224
2225 /**
2226 * readObject is called to restore this filename.
2227 * The original separator character is read. If it is different
2228 * than the separator character on this system, then the old separator
2229 * is replaced by the local separator.
2230 */
2231 private synchronized void readObject(java.io.ObjectInputStream s)
2232 throws IOException, ClassNotFoundException
2233 {
2234 ObjectInputStream.GetField fields = s.readFields();
2235 String pathField = (String)fields.get("path", null);
2236 char sep = s.readChar(); // read the previous separator char
2237 if (sep != separatorChar)
2238 pathField = pathField.replace(sep, separatorChar);
2239 String path = fs.normalize(pathField);
2240 UNSAFE.putReference(this, PATH_OFFSET, path);
2241 UNSAFE.putIntVolatile(this, PREFIX_LENGTH_OFFSET, fs.prefixLength(path));
2242 }
2243
2244 private static final jdk.internal.misc.Unsafe UNSAFE
2245 = jdk.internal.misc.Unsafe.getUnsafe();
2246 private static final long PATH_OFFSET
2247 = UNSAFE.objectFieldOffset(File.class, "path");
2248 private static final long PREFIX_LENGTH_OFFSET
2249 = UNSAFE.objectFieldOffset(File.class, "prefixLength");
2250
2251 /** use serialVersionUID from JDK 1.0.2 for interoperability */
2252 private static final long serialVersionUID = 301077366599181567L;
2253
2254 // -- Integration with java.nio.file --
2255
2256 private transient volatile Path filePath;
2257
2258 /**
2259 * Returns a {@link Path java.nio.file.Path} object constructed from
2260 * this abstract path. The resulting {@code Path} is associated with the
|