Skip to content

Commit f5871df

Browse files
author
Andrey Turbanov
committed
8336675: Remove UnixFileSystemProvider.checkPath in favor of UnixPath.toUnixPath
Reviewed-by: jpai, alanb, bpb
1 parent 902bada commit f5871df

File tree

1 file changed

+4
-21
lines changed

1 file changed

+4
-21
lines changed

src/java.base/unix/classes/sun/nio/fs/UnixFileSystemProvider.java

+4-21
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2008, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2008, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -45,7 +45,6 @@
4545
import java.nio.file.NotLinkException;
4646
import java.nio.file.OpenOption;
4747
import java.nio.file.Path;
48-
import java.nio.file.ProviderMismatchException;
4948
import java.nio.file.attribute.BasicFileAttributes;
5049
import java.nio.file.attribute.BasicFileAttributeView;
5150
import java.nio.file.attribute.FileAttribute;
@@ -126,14 +125,6 @@ public Path getPath(URI uri) {
126125
return UnixUriUtils.fromUri(theFileSystem, uri);
127126
}
128127

129-
UnixPath checkPath(Path obj) {
130-
if (obj == null)
131-
throw new NullPointerException();
132-
if (!(obj instanceof UnixPath))
133-
throw new ProviderMismatchException();
134-
return (UnixPath)obj;
135-
}
136-
137128
@Override
138129
@SuppressWarnings("unchecked")
139130
public <V extends FileAttributeView> V getFileAttributeView(Path obj,
@@ -216,7 +207,7 @@ public FileChannel newFileChannel(Path obj,
216207
FileAttribute<?>... attrs)
217208
throws IOException
218209
{
219-
UnixPath file = checkPath(obj);
210+
UnixPath file = UnixPath.toUnixPath(obj);
220211
int mode = UnixFileModeAttribute
221212
.toUnixMode(UnixFileModeAttribute.ALL_READWRITE, attrs);
222213
try {
@@ -233,7 +224,7 @@ public AsynchronousFileChannel newAsynchronousFileChannel(Path obj,
233224
ExecutorService executor,
234225
FileAttribute<?>... attrs) throws IOException
235226
{
236-
UnixPath file = checkPath(obj);
227+
UnixPath file = UnixPath.toUnixPath(obj);
237228
int mode = UnixFileModeAttribute
238229
.toUnixMode(UnixFileModeAttribute.ALL_READWRITE, attrs);
239230
ThreadPool pool = (executor == null) ? null : ThreadPool.wrap(executor, 0);
@@ -253,15 +244,7 @@ public SeekableByteChannel newByteChannel(Path obj,
253244
FileAttribute<?>... attrs)
254245
throws IOException
255246
{
256-
UnixPath file = UnixPath.toUnixPath(obj);
257-
int mode = UnixFileModeAttribute
258-
.toUnixMode(UnixFileModeAttribute.ALL_READWRITE, attrs);
259-
try {
260-
return UnixChannelFactory.newFileChannel(file, options, mode);
261-
} catch (UnixException x) {
262-
x.rethrowAsIOException(file);
263-
return null; // keep compiler happy
264-
}
247+
return newFileChannel(obj, options, attrs);
265248
}
266249

267250
@Override

0 commit comments

Comments
 (0)