2223 * than the separator character on this system, then the old separator
2224 * is replaced by the local separator.
2225 */
2226 private synchronized void readObject(java.io.ObjectInputStream s)
2227 throws IOException, ClassNotFoundException
2228 {
2229 ObjectInputStream.GetField fields = s.readFields();
2230 String pathField = (String)fields.get("path", null);
2231 char sep = s.readChar(); // read the previous separator char
2232 if (sep != separatorChar)
2233 pathField = pathField.replace(sep, separatorChar);
2234 String path = fs.normalize(pathField);
2235 UNSAFE.putObject(this, PATH_OFFSET, path);
2236 UNSAFE.putIntVolatile(this, PREFIX_LENGTH_OFFSET, fs.prefixLength(path));
2237 }
2238
2239 private static final long PATH_OFFSET;
2240 private static final long PREFIX_LENGTH_OFFSET;
2241 private static final jdk.internal.misc.Unsafe UNSAFE;
2242 static {
2243 try {
2244 jdk.internal.misc.Unsafe unsafe = jdk.internal.misc.Unsafe.getUnsafe();
2245 PATH_OFFSET = unsafe.objectFieldOffset(
2246 File.class.getDeclaredField("path"));
2247 PREFIX_LENGTH_OFFSET = unsafe.objectFieldOffset(
2248 File.class.getDeclaredField("prefixLength"));
2249 UNSAFE = unsafe;
2250 } catch (ReflectiveOperationException e) {
2251 throw new Error(e);
2252 }
2253 }
2254
2255
2256 /** use serialVersionUID from JDK 1.0.2 for interoperability */
2257 private static final long serialVersionUID = 301077366599181567L;
2258
2259 // -- Integration with java.nio.file --
2260
2261 private transient volatile Path filePath;
2262
2263 /**
2264 * Returns a {@link Path java.nio.file.Path} object constructed from the
2265 * this abstract path. The resulting {@code Path} is associated with the
2266 * {@link java.nio.file.FileSystems#getDefault default-filesystem}.
2267 *
2268 * <p> The first invocation of this method works as if invoking it were
2269 * equivalent to evaluating the expression:
2270 * <blockquote><pre>
2271 * {@link java.nio.file.FileSystems#getDefault FileSystems.getDefault}().{@link
2272 * java.nio.file.FileSystem#getPath getPath}(this.{@link #getPath getPath}());
|
2223 * than the separator character on this system, then the old separator
2224 * is replaced by the local separator.
2225 */
2226 private synchronized void readObject(java.io.ObjectInputStream s)
2227 throws IOException, ClassNotFoundException
2228 {
2229 ObjectInputStream.GetField fields = s.readFields();
2230 String pathField = (String)fields.get("path", null);
2231 char sep = s.readChar(); // read the previous separator char
2232 if (sep != separatorChar)
2233 pathField = pathField.replace(sep, separatorChar);
2234 String path = fs.normalize(pathField);
2235 UNSAFE.putObject(this, PATH_OFFSET, path);
2236 UNSAFE.putIntVolatile(this, PREFIX_LENGTH_OFFSET, fs.prefixLength(path));
2237 }
2238
2239 private static final long PATH_OFFSET;
2240 private static final long PREFIX_LENGTH_OFFSET;
2241 private static final jdk.internal.misc.Unsafe UNSAFE;
2242 static {
2243 jdk.internal.misc.Unsafe unsafe = jdk.internal.misc.Unsafe.getUnsafe();
2244 PATH_OFFSET = unsafe.objectFieldOffset(
2245 File.class, "path");
2246 PREFIX_LENGTH_OFFSET = unsafe.objectFieldOffset(
2247 File.class, "prefixLength");
2248 UNSAFE = unsafe;
2249 }
2250
2251
2252 /** use serialVersionUID from JDK 1.0.2 for interoperability */
2253 private static final long serialVersionUID = 301077366599181567L;
2254
2255 // -- Integration with java.nio.file --
2256
2257 private transient volatile Path filePath;
2258
2259 /**
2260 * Returns a {@link Path java.nio.file.Path} object constructed from the
2261 * this abstract path. The resulting {@code Path} is associated with the
2262 * {@link java.nio.file.FileSystems#getDefault default-filesystem}.
2263 *
2264 * <p> The first invocation of this method works as if invoking it were
2265 * equivalent to evaluating the expression:
2266 * <blockquote><pre>
2267 * {@link java.nio.file.FileSystems#getDefault FileSystems.getDefault}().{@link
2268 * java.nio.file.FileSystem#getPath getPath}(this.{@link #getPath getPath}());
|