8329593: Drop adjustments to target parallelism when virtual threads do I/O on files opened for buffered I/O
Reviewed-by: bpb, jpai
This commit is contained in:
parent
b07e1531b3
commit
412e306d81
src/java.base
linux/classes/sun/nio/ch
macosx/classes/sun/nio
share/classes
java
io
lang
net
nio
jdk/internal/misc
sun/nio/ch
unix/classes
java
sun/nio
windows/classes
test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/bcinstr/BI04/bi04t002/newclass02/java.base/java/lang
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -116,11 +116,11 @@ class EPollSelectorImpl extends SelectorImpl {
|
||||
|
||||
do {
|
||||
long startTime = timedPoll ? System.nanoTime() : 0;
|
||||
long comp = Blocker.begin(blocking);
|
||||
boolean attempted = Blocker.begin(blocking);
|
||||
try {
|
||||
numEntries = EPoll.wait(epfd, pollArrayAddress, NUM_EPOLLEVENTS, to);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
Blocker.end(attempted);
|
||||
}
|
||||
if (numEntries == IOStatus.INTERRUPTED && timedPoll) {
|
||||
// timed poll interrupted so need to adjust timeout
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -120,11 +120,11 @@ class KQueueSelectorImpl extends SelectorImpl {
|
||||
|
||||
do {
|
||||
long startTime = timedPoll ? System.nanoTime() : 0;
|
||||
long comp = Blocker.begin(blocking);
|
||||
boolean attempted = Blocker.begin(blocking);
|
||||
try {
|
||||
numEntries = KQueue.poll(kqfd, pollArrayAddress, MAX_KEVENTS, to);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
Blocker.end(attempted);
|
||||
}
|
||||
if (numEntries == IOStatus.INTERRUPTED && timedPoll) {
|
||||
// timed poll interrupted so need to adjust timeout
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2008, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2008, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,8 +25,6 @@
|
||||
|
||||
package sun.nio.fs;
|
||||
|
||||
import jdk.internal.misc.Blocker;
|
||||
|
||||
/**
|
||||
* Bsd specific system calls.
|
||||
*/
|
||||
@ -69,13 +67,7 @@ class BsdNativeDispatcher extends UnixNativeDispatcher {
|
||||
{
|
||||
try (NativeBuffer srcBuffer = copyToNativeBuffer(src);
|
||||
NativeBuffer dstBuffer = copyToNativeBuffer(dst)) {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
return clonefile0(srcBuffer.address(), dstBuffer.address(),
|
||||
flags);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
return clonefile0(srcBuffer.address(), dstBuffer.address(), flags);
|
||||
}
|
||||
}
|
||||
private static native int clonefile0(long srcAddress, long dstAddress,
|
||||
@ -90,13 +82,8 @@ class BsdNativeDispatcher extends UnixNativeDispatcher {
|
||||
throws UnixException
|
||||
{
|
||||
try (NativeBuffer buffer = copyToNativeBuffer(path)) {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
setattrlist0(buffer.address(), commonattr, modTime, accTime,
|
||||
createTime, options);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
setattrlist0(buffer.address(), commonattr, modTime, accTime,
|
||||
createTime, options);
|
||||
}
|
||||
}
|
||||
private static native void setattrlist0(long pathAddress, int commonattr,
|
||||
@ -112,13 +99,7 @@ class BsdNativeDispatcher extends UnixNativeDispatcher {
|
||||
long accTime, long createTime, long options)
|
||||
throws UnixException
|
||||
{
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
fsetattrlist0(fd, commonattr, modTime, accTime,
|
||||
createTime, options);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
fsetattrlist0(fd, commonattr, modTime, accTime, createTime, options);
|
||||
}
|
||||
private static native void fsetattrlist0(int fd, int commonattr,
|
||||
long modTime, long accTime,
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -207,11 +207,11 @@ public final class FileDescriptor {
|
||||
* @since 1.1
|
||||
*/
|
||||
public void sync() throws SyncFailedException {
|
||||
long comp = Blocker.begin();
|
||||
boolean attempted = Blocker.begin();
|
||||
try {
|
||||
sync0();
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
Blocker.end(attempted);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1994, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1994, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -27,7 +27,6 @@ package java.io;
|
||||
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.util.Arrays;
|
||||
import jdk.internal.misc.Blocker;
|
||||
import jdk.internal.util.ArraysSupport;
|
||||
import sun.nio.ch.FileChannelImpl;
|
||||
|
||||
@ -210,12 +209,7 @@ public class FileInputStream extends InputStream
|
||||
* @param name the name of the file
|
||||
*/
|
||||
private void open(String name) throws FileNotFoundException {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
open0(name);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
open0(name);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -228,12 +222,7 @@ public class FileInputStream extends InputStream
|
||||
*/
|
||||
@Override
|
||||
public int read() throws IOException {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
return read0();
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
return read0();
|
||||
}
|
||||
|
||||
private native int read0() throws IOException;
|
||||
@ -260,12 +249,7 @@ public class FileInputStream extends InputStream
|
||||
*/
|
||||
@Override
|
||||
public int read(byte[] b) throws IOException {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
return readBytes(b, 0, b.length);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
return readBytes(b, 0, b.length);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -284,12 +268,7 @@ public class FileInputStream extends InputStream
|
||||
*/
|
||||
@Override
|
||||
public int read(byte[] b, int off, int len) throws IOException {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
return readBytes(b, off, len);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
return readBytes(b, off, len);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -396,22 +375,12 @@ public class FileInputStream extends InputStream
|
||||
}
|
||||
|
||||
private long length() throws IOException {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
return length0();
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
return length0();
|
||||
}
|
||||
private native long length0() throws IOException;
|
||||
|
||||
private long position() throws IOException {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
return position0();
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
return position0();
|
||||
}
|
||||
private native long position0() throws IOException;
|
||||
|
||||
@ -441,12 +410,7 @@ public class FileInputStream extends InputStream
|
||||
*/
|
||||
@Override
|
||||
public long skip(long n) throws IOException {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
return skip0(n);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
return skip0(n);
|
||||
}
|
||||
|
||||
private native long skip0(long n) throws IOException;
|
||||
@ -470,12 +434,7 @@ public class FileInputStream extends InputStream
|
||||
*/
|
||||
@Override
|
||||
public int available() throws IOException {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
return available0();
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
return available0();
|
||||
}
|
||||
|
||||
private native int available0() throws IOException;
|
||||
@ -566,8 +525,8 @@ public class FileInputStream extends InputStream
|
||||
synchronized (this) {
|
||||
fc = this.channel;
|
||||
if (fc == null) {
|
||||
this.channel = fc = FileChannelImpl.open(fd, path, true,
|
||||
false, false, this);
|
||||
fc = FileChannelImpl.open(fd, path, true, false, false, false, this);
|
||||
this.channel = fc;
|
||||
if (closed) {
|
||||
try {
|
||||
// possible race with close(), benign since
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1994, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1994, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -28,7 +28,6 @@ package java.io;
|
||||
import java.nio.channels.FileChannel;
|
||||
import jdk.internal.access.SharedSecrets;
|
||||
import jdk.internal.access.JavaIOFileDescriptorAccess;
|
||||
import jdk.internal.misc.Blocker;
|
||||
import sun.nio.ch.FileChannelImpl;
|
||||
|
||||
|
||||
@ -286,12 +285,7 @@ public class FileOutputStream extends OutputStream
|
||||
* @param append whether the file is to be opened in append mode
|
||||
*/
|
||||
private void open(String name, boolean append) throws FileNotFoundException {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
open0(name, append);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
open0(name, append);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -313,12 +307,7 @@ public class FileOutputStream extends OutputStream
|
||||
@Override
|
||||
public void write(int b) throws IOException {
|
||||
boolean append = FD_ACCESS.getAppend(fd);
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
write(b, append);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
write(b, append);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -343,12 +332,7 @@ public class FileOutputStream extends OutputStream
|
||||
@Override
|
||||
public void write(byte[] b) throws IOException {
|
||||
boolean append = FD_ACCESS.getAppend(fd);
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
writeBytes(b, 0, b.length, append);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
writeBytes(b, 0, b.length, append);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -364,12 +348,7 @@ public class FileOutputStream extends OutputStream
|
||||
@Override
|
||||
public void write(byte[] b, int off, int len) throws IOException {
|
||||
boolean append = FD_ACCESS.getAppend(fd);
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
writeBytes(b, off, len, append);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
writeBytes(b, off, len, append);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -460,8 +439,8 @@ public class FileOutputStream extends OutputStream
|
||||
synchronized (this) {
|
||||
fc = this.channel;
|
||||
if (fc == null) {
|
||||
this.channel = fc = FileChannelImpl.open(fd, path, false,
|
||||
true, false, this);
|
||||
fc = FileChannelImpl.open(fd, path, false, true, false, false, this);
|
||||
this.channel = fc;
|
||||
if (closed) {
|
||||
try {
|
||||
// possible race with close(), benign since
|
||||
|
@ -71,6 +71,7 @@ public class RandomAccessFile implements DataOutput, DataInput, Closeable {
|
||||
private final FileDescriptor fd;
|
||||
|
||||
private final boolean rw;
|
||||
private final boolean sync; // O_SYNC or O_DSYNC
|
||||
|
||||
/**
|
||||
* The path of the referenced file
|
||||
@ -229,21 +230,25 @@ public class RandomAccessFile implements DataOutput, DataInput, Closeable {
|
||||
int imode = -1;
|
||||
|
||||
boolean rw = false;
|
||||
boolean sync = false;
|
||||
if (mode.equals("r"))
|
||||
imode = O_RDONLY;
|
||||
else if (mode.startsWith("rw")) {
|
||||
imode = O_RDWR;
|
||||
rw = true;
|
||||
if (mode.length() > 2) {
|
||||
if (mode.equals("rws"))
|
||||
if (mode.equals("rws")) {
|
||||
imode |= O_SYNC;
|
||||
else if (mode.equals("rwd"))
|
||||
sync = true;
|
||||
} else if (mode.equals("rwd")) {
|
||||
imode |= O_DSYNC;
|
||||
else
|
||||
sync = true;
|
||||
} else
|
||||
imode = -1;
|
||||
}
|
||||
}
|
||||
this.rw = rw;
|
||||
this.sync = sync;
|
||||
|
||||
if (openAndDelete)
|
||||
imode |= O_TEMPORARY;
|
||||
@ -308,8 +313,8 @@ public class RandomAccessFile implements DataOutput, DataInput, Closeable {
|
||||
synchronized (this) {
|
||||
fc = this.channel;
|
||||
if (fc == null) {
|
||||
this.channel = fc = FileChannelImpl.open(fd, path, true,
|
||||
rw, false, this);
|
||||
fc = FileChannelImpl.open(fd, path, true, rw, sync, false, this);
|
||||
this.channel = fc;
|
||||
if (closed) {
|
||||
try {
|
||||
fc.close();
|
||||
@ -350,12 +355,7 @@ public class RandomAccessFile implements DataOutput, DataInput, Closeable {
|
||||
* defined above
|
||||
*/
|
||||
private void open(String name, int mode) throws FileNotFoundException {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
open0(name, mode);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
open0(name, mode);
|
||||
}
|
||||
|
||||
// 'Read' primitives
|
||||
@ -376,12 +376,7 @@ public class RandomAccessFile implements DataOutput, DataInput, Closeable {
|
||||
* end-of-file has been reached.
|
||||
*/
|
||||
public int read() throws IOException {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
return read0();
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
return read0();
|
||||
}
|
||||
|
||||
private native int read0() throws IOException;
|
||||
@ -394,12 +389,7 @@ public class RandomAccessFile implements DataOutput, DataInput, Closeable {
|
||||
* @throws IOException If an I/O error has occurred.
|
||||
*/
|
||||
private int readBytes(byte[] b, int off, int len) throws IOException {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
return readBytes0(b, off, len);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
return readBytes0(b, off, len);
|
||||
}
|
||||
|
||||
private native int readBytes0(byte[] b, int off, int len) throws IOException;
|
||||
@ -547,11 +537,11 @@ public class RandomAccessFile implements DataOutput, DataInput, Closeable {
|
||||
* @throws IOException if an I/O error occurs.
|
||||
*/
|
||||
public void write(int b) throws IOException {
|
||||
long comp = Blocker.begin();
|
||||
boolean attempted = Blocker.begin(sync);
|
||||
try {
|
||||
write0(b);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
Blocker.end(attempted);
|
||||
}
|
||||
}
|
||||
|
||||
@ -566,11 +556,11 @@ public class RandomAccessFile implements DataOutput, DataInput, Closeable {
|
||||
* @throws IOException If an I/O error has occurred.
|
||||
*/
|
||||
private void writeBytes(byte[] b, int off, int len) throws IOException {
|
||||
long comp = Blocker.begin();
|
||||
boolean attempted = Blocker.begin(sync);
|
||||
try {
|
||||
writeBytes0(b, off, len);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
Blocker.end(attempted);
|
||||
}
|
||||
}
|
||||
|
||||
@ -630,12 +620,7 @@ public class RandomAccessFile implements DataOutput, DataInput, Closeable {
|
||||
if (pos < 0) {
|
||||
throw new IOException("Negative seek offset");
|
||||
}
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
seek0(pos);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
seek0(pos);
|
||||
}
|
||||
|
||||
private native void seek0(long pos) throws IOException;
|
||||
@ -647,12 +632,7 @@ public class RandomAccessFile implements DataOutput, DataInput, Closeable {
|
||||
* @throws IOException if an I/O error occurs.
|
||||
*/
|
||||
public long length() throws IOException {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
return length0();
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
return length0();
|
||||
}
|
||||
|
||||
private native long length0() throws IOException;
|
||||
@ -684,12 +664,7 @@ public class RandomAccessFile implements DataOutput, DataInput, Closeable {
|
||||
* @since 1.2
|
||||
*/
|
||||
public void setLength(long newLength) throws IOException {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
setLength0(newLength);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
setLength0(newLength);
|
||||
}
|
||||
|
||||
private native void setLength0(long newLength) throws IOException;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1994, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1994, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -370,16 +370,21 @@ public class Object {
|
||||
* @see #wait(long, int)
|
||||
*/
|
||||
public final void wait(long timeoutMillis) throws InterruptedException {
|
||||
long comp = Blocker.begin();
|
||||
if (!Thread.currentThread().isVirtual()) {
|
||||
wait0(timeoutMillis);
|
||||
return;
|
||||
}
|
||||
|
||||
// virtual thread waiting
|
||||
boolean attempted = Blocker.begin();
|
||||
try {
|
||||
wait0(timeoutMillis);
|
||||
} catch (InterruptedException e) {
|
||||
Thread thread = Thread.currentThread();
|
||||
if (thread.isVirtual())
|
||||
thread.getAndClearInterrupt();
|
||||
// virtual thread's interrupt status needs to be cleared
|
||||
Thread.currentThread().getAndClearInterrupt();
|
||||
throw e;
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
Blocker.end(attempted);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1995, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1995, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,6 +25,7 @@
|
||||
|
||||
package java.lang;
|
||||
|
||||
import jdk.internal.misc.Blocker;
|
||||
import jdk.internal.util.StaticProperty;
|
||||
|
||||
import java.io.*;
|
||||
@ -839,6 +840,75 @@ public abstract class Process {
|
||||
|
||||
return n - remaining;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int read() throws IOException {
|
||||
boolean attempted = Blocker.begin();
|
||||
try {
|
||||
return super.read();
|
||||
} finally {
|
||||
Blocker.end(attempted);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int read(byte[] b) throws IOException {
|
||||
boolean attempted = Blocker.begin();
|
||||
try {
|
||||
return super.read(b);
|
||||
} finally {
|
||||
Blocker.end(attempted);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int read(byte[] b, int off, int len) throws IOException {
|
||||
boolean attempted = Blocker.begin();
|
||||
try {
|
||||
return super.read(b, off, len);
|
||||
} finally {
|
||||
Blocker.end(attempted);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* An output stream for a subprocess pipe.
|
||||
*/
|
||||
static class PipeOutputStream extends FileOutputStream {
|
||||
PipeOutputStream(FileDescriptor fd) {
|
||||
super(fd);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(int b) throws IOException {
|
||||
boolean attempted = Blocker.begin();
|
||||
try {
|
||||
super.write(b);
|
||||
} finally {
|
||||
Blocker.end(attempted);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(byte[] b) throws IOException {
|
||||
boolean attempted = Blocker.begin();
|
||||
try {
|
||||
super.write(b);
|
||||
} finally {
|
||||
Blocker.end(attempted);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(byte[] b, int off, int len) throws IOException {
|
||||
boolean attempted = Blocker.begin();
|
||||
try {
|
||||
super.write(b, off, len);
|
||||
} finally {
|
||||
Blocker.end(attempted);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -71,6 +71,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import jdk.internal.logger.LoggerFinderLoader.TemporaryLoggerFinder;
|
||||
import jdk.internal.misc.Blocker;
|
||||
import jdk.internal.misc.CarrierThreadLocal;
|
||||
import jdk.internal.misc.Unsafe;
|
||||
import jdk.internal.util.StaticProperty;
|
||||
@ -2190,9 +2191,9 @@ public final class System {
|
||||
|
||||
lineSeparator = props.getProperty("line.separator");
|
||||
|
||||
FileInputStream fdIn = new FileInputStream(FileDescriptor.in);
|
||||
FileOutputStream fdOut = new FileOutputStream(FileDescriptor.out);
|
||||
FileOutputStream fdErr = new FileOutputStream(FileDescriptor.err);
|
||||
FileInputStream fdIn = new In(FileDescriptor.in);
|
||||
FileOutputStream fdOut = new Out(FileDescriptor.out);
|
||||
FileOutputStream fdErr = new Out(FileDescriptor.err);
|
||||
initialIn = new BufferedInputStream(fdIn);
|
||||
setIn0(initialIn);
|
||||
// stdout/err.encoding are set when the VM is associated with the terminal,
|
||||
@ -2217,6 +2218,83 @@ public final class System {
|
||||
VM.initLevel(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* System.in.
|
||||
*/
|
||||
private static class In extends FileInputStream {
|
||||
In(FileDescriptor fd) {
|
||||
super(fd);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int read() throws IOException {
|
||||
boolean attempted = Blocker.begin();
|
||||
try {
|
||||
return super.read();
|
||||
} finally {
|
||||
Blocker.end(attempted);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int read(byte[] b) throws IOException {
|
||||
boolean attempted = Blocker.begin();
|
||||
try {
|
||||
return super.read(b);
|
||||
} finally {
|
||||
Blocker.end(attempted);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int read(byte[] b, int off, int len) throws IOException {
|
||||
boolean attempted = Blocker.begin();
|
||||
try {
|
||||
return super.read(b, off, len);
|
||||
} finally {
|
||||
Blocker.end(attempted);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* System.out/System.err wrap this output stream.
|
||||
*/
|
||||
private static class Out extends FileOutputStream {
|
||||
Out(FileDescriptor fd) {
|
||||
super(fd);
|
||||
}
|
||||
|
||||
public void write(int b) throws IOException {
|
||||
boolean attempted = Blocker.begin();
|
||||
try {
|
||||
super.write(b);
|
||||
} finally {
|
||||
Blocker.end(attempted);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(byte[] b) throws IOException {
|
||||
boolean attempted = Blocker.begin();
|
||||
try {
|
||||
super.write(b);
|
||||
} finally {
|
||||
Blocker.end(attempted);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(byte[] b, int off, int len) throws IOException {
|
||||
boolean attempted = Blocker.begin();
|
||||
try {
|
||||
super.write(b, off, len);
|
||||
} finally {
|
||||
Blocker.end(attempted);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// @see #initPhase2()
|
||||
static ModuleLayer bootLayer;
|
||||
|
||||
|
@ -460,6 +460,11 @@ final class VirtualThread extends BaseVirtualThread {
|
||||
private void afterYield() {
|
||||
assert carrierThread == null;
|
||||
|
||||
// re-adjust parallelism if the virtual thread yielded when compensating
|
||||
if (currentThread() instanceof CarrierThread ct) {
|
||||
ct.endBlocking();
|
||||
}
|
||||
|
||||
int s = state();
|
||||
|
||||
// LockSupport.park/parkNanos
|
||||
|
@ -1216,11 +1216,11 @@ public sealed class InetAddress implements Serializable permits Inet4Address, In
|
||||
Objects.requireNonNull(policy);
|
||||
validate(host);
|
||||
InetAddress[] addrs;
|
||||
long comp = Blocker.begin();
|
||||
boolean attempted = Blocker.begin();
|
||||
try {
|
||||
addrs = impl.lookupAllHostAddr(host, policy);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
Blocker.end(attempted);
|
||||
}
|
||||
return Arrays.stream(addrs);
|
||||
}
|
||||
@ -1230,11 +1230,11 @@ public sealed class InetAddress implements Serializable permits Inet4Address, In
|
||||
if (addr.length != Inet4Address.INADDRSZ && addr.length != Inet6Address.INADDRSZ) {
|
||||
throw new IllegalArgumentException("Invalid address length");
|
||||
}
|
||||
long comp = Blocker.begin();
|
||||
boolean attempted = Blocker.begin();
|
||||
try {
|
||||
return impl.getHostByAddr(addr);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
Blocker.end(attempted);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -98,13 +98,13 @@ import jdk.internal.misc.Unsafe;
|
||||
long offset = mappingOffset(address, index);
|
||||
long mappingAddress = mappingAddress(address, offset, index);
|
||||
long mappingLength = mappingLength(offset, length);
|
||||
long comp = Blocker.begin();
|
||||
boolean attempted = Blocker.begin();
|
||||
try {
|
||||
force0(fd, mappingAddress, mappingLength);
|
||||
} catch (IOException cause) {
|
||||
throw new UncheckedIOException(cause);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
Blocker.end(attempted);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,20 +25,18 @@
|
||||
|
||||
package jdk.internal.misc;
|
||||
|
||||
import java.util.concurrent.ForkJoinPool;
|
||||
import jdk.internal.access.JavaLangAccess;
|
||||
import jdk.internal.access.JavaUtilConcurrentFJPAccess;
|
||||
import jdk.internal.access.SharedSecrets;
|
||||
|
||||
/**
|
||||
* Defines static methods to mark the beginning and end of a possibly blocking
|
||||
* operation. The methods are intended to be used with try-finally as follows:
|
||||
* {@snippet lang=java :
|
||||
* long comp = Blocker.begin();
|
||||
* boolean attempted = Blocker.begin();
|
||||
* try {
|
||||
* // blocking operation
|
||||
* } finally {
|
||||
* Blocker.end(comp);
|
||||
* Blocker.end(attempted);
|
||||
* }
|
||||
* }
|
||||
* If invoked from a virtual thread and the underlying carrier thread is a
|
||||
@ -62,64 +60,35 @@ public class Blocker {
|
||||
}
|
||||
|
||||
/**
|
||||
* Marks the beginning of a possibly blocking operation.
|
||||
* @return the return value from the attempt to compensate or -1 if not attempted
|
||||
* Marks the beginning of a blocking operation.
|
||||
* @return true if tryCompensate attempted
|
||||
*/
|
||||
public static long begin() {
|
||||
public static boolean begin() {
|
||||
if (VM.isBooted()
|
||||
&& currentCarrierThread() instanceof CarrierThread ct && !ct.inBlocking()) {
|
||||
ct.beginBlocking();
|
||||
boolean completed = false;
|
||||
try {
|
||||
long comp = ForkJoinPools.beginCompensatedBlock(ct.getPool());
|
||||
assert currentCarrierThread() == ct;
|
||||
completed = true;
|
||||
return comp;
|
||||
} finally {
|
||||
if (!completed) {
|
||||
ct.endBlocking();
|
||||
}
|
||||
}
|
||||
&& Thread.currentThread().isVirtual()
|
||||
&& currentCarrierThread() instanceof CarrierThread ct) {
|
||||
return ct.beginBlocking();
|
||||
}
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Marks the beginning of a possibly blocking operation.
|
||||
* @param blocking true if the operation may block, otherwise false
|
||||
* @return the return value from the attempt to compensate, -1 if not attempted
|
||||
* or blocking is false
|
||||
* @return true if tryCompensate attempted
|
||||
*/
|
||||
public static long begin(boolean blocking) {
|
||||
return (blocking) ? begin() : -1;
|
||||
public static boolean begin(boolean blocking) {
|
||||
return (blocking) ? begin() : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Marks the end of an operation that may have blocked.
|
||||
* @param compensateReturn the value returned by the begin method
|
||||
* @param attempted if tryCompensate attempted
|
||||
*/
|
||||
public static void end(long compensateReturn) {
|
||||
if (compensateReturn >= 0) {
|
||||
assert currentCarrierThread() instanceof CarrierThread ct && ct.inBlocking();
|
||||
public static void end(boolean attempted) {
|
||||
if (attempted) {
|
||||
CarrierThread ct = (CarrierThread) currentCarrierThread();
|
||||
ForkJoinPools.endCompensatedBlock(ct.getPool(), compensateReturn);
|
||||
ct.endBlocking();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines static methods to invoke non-public ForkJoinPool methods via the
|
||||
* shared secret support.
|
||||
*/
|
||||
private static class ForkJoinPools {
|
||||
private static final JavaUtilConcurrentFJPAccess FJP_ACCESS =
|
||||
SharedSecrets.getJavaUtilConcurrentFJPAccess();
|
||||
static long beginCompensatedBlock(ForkJoinPool pool) {
|
||||
return FJP_ACCESS.beginCompensatedBlock(pool);
|
||||
}
|
||||
static void endCompensatedBlock(ForkJoinPool pool, long post) {
|
||||
FJP_ACCESS.endCompensatedBlock(pool, post);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -32,7 +32,9 @@ import java.security.ProtectionDomain;
|
||||
import java.util.concurrent.ForkJoinPool;
|
||||
import java.util.concurrent.ForkJoinWorkerThread;
|
||||
import jdk.internal.access.JavaLangAccess;
|
||||
import jdk.internal.access.JavaUtilConcurrentFJPAccess;
|
||||
import jdk.internal.access.SharedSecrets;
|
||||
import jdk.internal.vm.Continuation;
|
||||
|
||||
/**
|
||||
* A ForkJoinWorkerThread that can be used as a carrier thread.
|
||||
@ -49,7 +51,14 @@ public class CarrierThread extends ForkJoinWorkerThread {
|
||||
private static final long INHERITABLETHREADLOCALS;
|
||||
private static final long INHERITEDACCESSCONTROLCONTEXT;
|
||||
|
||||
private boolean blocking; // true if in blocking op
|
||||
// compensating state
|
||||
private static final int NOT_COMPENSATING = 0;
|
||||
private static final int COMPENSATE_IN_PROGRESS = 1;
|
||||
private static final int COMPENSATING = 2;
|
||||
private int compensating;
|
||||
|
||||
// FJP value to adjust release counts
|
||||
private long compensateValue;
|
||||
|
||||
@SuppressWarnings("this-escape")
|
||||
public CarrierThread(ForkJoinPool pool) {
|
||||
@ -60,27 +69,44 @@ public class CarrierThread extends ForkJoinWorkerThread {
|
||||
}
|
||||
|
||||
/**
|
||||
* For use by {@link Blocker} to test if the thread is in a blocking operation.
|
||||
* Mark the start of a blocking operation.
|
||||
*/
|
||||
boolean inBlocking() {
|
||||
//assert JLA.currentCarrierThread() == this;
|
||||
return blocking;
|
||||
public boolean beginBlocking() {
|
||||
assert Thread.currentThread().isVirtual() && JLA.currentCarrierThread() == this;
|
||||
assert compensating == NOT_COMPENSATING || compensating == COMPENSATING;
|
||||
|
||||
if (compensating == NOT_COMPENSATING) {
|
||||
// don't preempt when attempting to compensate
|
||||
Continuation.pin();
|
||||
try {
|
||||
compensating = COMPENSATE_IN_PROGRESS;
|
||||
|
||||
// Uses FJP.tryCompensate to start or re-activate a spare thread
|
||||
compensateValue = ForkJoinPools.beginCompensatedBlock(getPool());
|
||||
compensating = COMPENSATING;
|
||||
return true;
|
||||
} catch (Throwable e) {
|
||||
// exception starting spare thread
|
||||
compensating = NOT_COMPENSATING;
|
||||
throw e;
|
||||
} finally {
|
||||
Continuation.unpin();
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* For use by {@link Blocker} to mark the start of a blocking operation.
|
||||
* Mark the end of a blocking operation.
|
||||
*/
|
||||
void beginBlocking() {
|
||||
//assert JLA.currentCarrierThread() == this && !blocking;
|
||||
blocking = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* For use by {@link Blocker} to mark the end of a blocking operation.
|
||||
*/
|
||||
void endBlocking() {
|
||||
//assert JLA.currentCarrierThread() == this && blocking;
|
||||
blocking = false;
|
||||
public void endBlocking() {
|
||||
assert Thread.currentThread() == this || JLA.currentCarrierThread() == this;
|
||||
if (compensating == COMPENSATING) {
|
||||
ForkJoinPools.endCompensatedBlock(getPool(), compensateValue);
|
||||
compensating = NOT_COMPENSATING;
|
||||
compensateValue = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -95,7 +121,7 @@ public class CarrierThread extends ForkJoinWorkerThread {
|
||||
* The thread group for the carrier threads.
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
private static final ThreadGroup carrierThreadGroup() {
|
||||
private static ThreadGroup carrierThreadGroup() {
|
||||
return AccessController.doPrivileged(new PrivilegedAction<ThreadGroup>() {
|
||||
public ThreadGroup run() {
|
||||
ThreadGroup group = JLA.currentCarrierThread().getThreadGroup();
|
||||
@ -117,6 +143,21 @@ public class CarrierThread extends ForkJoinWorkerThread {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines static methods to invoke non-public ForkJoinPool methods via the
|
||||
* shared secret support.
|
||||
*/
|
||||
private static class ForkJoinPools {
|
||||
private static final JavaUtilConcurrentFJPAccess FJP_ACCESS =
|
||||
SharedSecrets.getJavaUtilConcurrentFJPAccess();
|
||||
static long beginCompensatedBlock(ForkJoinPool pool) {
|
||||
return FJP_ACCESS.beginCompensatedBlock(pool);
|
||||
}
|
||||
static void endCompensatedBlock(ForkJoinPool pool, long post) {
|
||||
FJP_ACCESS.endCompensatedBlock(pool, post);
|
||||
}
|
||||
}
|
||||
|
||||
static {
|
||||
CONTEXTCLASSLOADER = U.objectFieldOffset(Thread.class,
|
||||
"contextClassLoader");
|
||||
|
@ -78,6 +78,7 @@ public class FileChannelImpl
|
||||
// File access mode (immutable)
|
||||
private final boolean writable;
|
||||
private final boolean readable;
|
||||
private final boolean sync; // O_SYNC or O_DSYNC
|
||||
|
||||
// Required to prevent finalization of creating stream (immutable)
|
||||
private final Closeable parent;
|
||||
@ -122,12 +123,14 @@ public class FileChannelImpl
|
||||
}
|
||||
|
||||
private FileChannelImpl(FileDescriptor fd, String path, boolean readable,
|
||||
boolean writable, boolean direct, Closeable parent)
|
||||
boolean writable, boolean sync, boolean direct,
|
||||
Closeable parent)
|
||||
{
|
||||
this.fd = fd;
|
||||
this.path = path;
|
||||
this.readable = readable;
|
||||
this.writable = writable;
|
||||
this.sync = sync;
|
||||
this.direct = direct;
|
||||
this.parent = parent;
|
||||
if (direct) {
|
||||
@ -150,9 +153,9 @@ public class FileChannelImpl
|
||||
// and RandomAccessFile::getChannel
|
||||
public static FileChannel open(FileDescriptor fd, String path,
|
||||
boolean readable, boolean writable,
|
||||
boolean direct, Closeable parent)
|
||||
boolean sync, boolean direct, Closeable parent)
|
||||
{
|
||||
return new FileChannelImpl(fd, path, readable, writable, direct, parent);
|
||||
return new FileChannelImpl(fd, path, readable, writable, sync, direct, parent);
|
||||
}
|
||||
|
||||
private void ensureOpen() throws IOException {
|
||||
@ -230,11 +233,11 @@ public class FileChannelImpl
|
||||
if (!isOpen())
|
||||
return 0;
|
||||
do {
|
||||
long comp = Blocker.begin();
|
||||
boolean attempted = Blocker.begin(direct);
|
||||
try {
|
||||
n = IOUtil.read(fd, dst, -1, direct, alignment, nd);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
Blocker.end(attempted);
|
||||
}
|
||||
} while ((n == IOStatus.INTERRUPTED) && isOpen());
|
||||
return IOStatus.normalize(n);
|
||||
@ -265,11 +268,11 @@ public class FileChannelImpl
|
||||
if (!isOpen())
|
||||
return 0;
|
||||
do {
|
||||
long comp = Blocker.begin();
|
||||
boolean attempted = Blocker.begin(direct);
|
||||
try {
|
||||
n = IOUtil.read(fd, dsts, offset, length, direct, alignment, nd);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
Blocker.end(attempted);
|
||||
}
|
||||
|
||||
} while ((n == IOStatus.INTERRUPTED) && isOpen());
|
||||
@ -298,11 +301,11 @@ public class FileChannelImpl
|
||||
if (!isOpen())
|
||||
return 0;
|
||||
do {
|
||||
long comp = Blocker.begin();
|
||||
boolean attempted = Blocker.begin(sync || direct);
|
||||
try {
|
||||
n = IOUtil.write(fd, src, -1, direct, alignment, nd);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
Blocker.end(attempted);
|
||||
}
|
||||
|
||||
} while ((n == IOStatus.INTERRUPTED) && isOpen());
|
||||
@ -334,11 +337,11 @@ public class FileChannelImpl
|
||||
if (!isOpen())
|
||||
return 0;
|
||||
do {
|
||||
long comp = Blocker.begin();
|
||||
boolean attempted = Blocker.begin(sync || direct);
|
||||
try {
|
||||
n = IOUtil.write(fd, srcs, offset, length, direct, alignment, nd);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
Blocker.end(attempted);
|
||||
}
|
||||
} while ((n == IOStatus.INTERRUPTED) && isOpen());
|
||||
return IOStatus.normalize(n);
|
||||
@ -365,13 +368,8 @@ public class FileChannelImpl
|
||||
return 0;
|
||||
boolean append = fdAccess.getAppend(fd);
|
||||
do {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
// in append-mode then position is advanced to end before writing
|
||||
p = (append) ? nd.size(fd) : nd.seek(fd, -1);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
// in append-mode then position is advanced to end before writing
|
||||
p = (append) ? nd.size(fd) : nd.seek(fd, -1);
|
||||
} while ((p == IOStatus.INTERRUPTED) && isOpen());
|
||||
return IOStatus.normalize(p);
|
||||
} finally {
|
||||
@ -396,12 +394,7 @@ public class FileChannelImpl
|
||||
if (!isOpen())
|
||||
return null;
|
||||
do {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
p = nd.seek(fd, newPosition);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
p = nd.seek(fd, newPosition);
|
||||
} while ((p == IOStatus.INTERRUPTED) && isOpen());
|
||||
return this;
|
||||
} finally {
|
||||
@ -424,12 +417,7 @@ public class FileChannelImpl
|
||||
if (!isOpen())
|
||||
return -1;
|
||||
do {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
s = nd.size(fd);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
s = nd.size(fd);
|
||||
} while ((s == IOStatus.INTERRUPTED) && isOpen());
|
||||
return IOStatus.normalize(s);
|
||||
} finally {
|
||||
@ -461,24 +449,14 @@ public class FileChannelImpl
|
||||
// get current size
|
||||
long size;
|
||||
do {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
size = nd.size(fd);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
size = nd.size(fd);
|
||||
} while ((size == IOStatus.INTERRUPTED) && isOpen());
|
||||
if (!isOpen())
|
||||
return null;
|
||||
|
||||
// get current position
|
||||
do {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
p = nd.seek(fd, -1);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
p = nd.seek(fd, -1);
|
||||
} while ((p == IOStatus.INTERRUPTED) && isOpen());
|
||||
if (!isOpen())
|
||||
return null;
|
||||
@ -487,12 +465,7 @@ public class FileChannelImpl
|
||||
// truncate file if given size is less than the current size
|
||||
if (newSize < size) {
|
||||
do {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
rv = nd.truncate(fd, newSize);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
rv = nd.truncate(fd, newSize);
|
||||
} while ((rv == IOStatus.INTERRUPTED) && isOpen());
|
||||
if (!isOpen())
|
||||
return null;
|
||||
@ -502,12 +475,7 @@ public class FileChannelImpl
|
||||
if (p > newSize)
|
||||
p = newSize;
|
||||
do {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
rp = nd.seek(fd, p);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
rp = nd.seek(fd, p);
|
||||
} while ((rp == IOStatus.INTERRUPTED) && isOpen());
|
||||
return this;
|
||||
} finally {
|
||||
@ -529,11 +497,11 @@ public class FileChannelImpl
|
||||
if (!isOpen())
|
||||
return;
|
||||
do {
|
||||
long comp = Blocker.begin();
|
||||
boolean attempted = Blocker.begin();
|
||||
try {
|
||||
rv = nd.force(fd, metaData);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
Blocker.end(attempted);
|
||||
}
|
||||
} while ((rv == IOStatus.INTERRUPTED) && isOpen());
|
||||
} finally {
|
||||
@ -624,12 +592,7 @@ public class FileChannelImpl
|
||||
long n;
|
||||
boolean append = fdAccess.getAppend(targetFD);
|
||||
do {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
n = nd.transferTo(fd, position, count, targetFD, append);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
n = nd.transferTo(fd, position, count, targetFD, append);
|
||||
} while ((n == IOStatus.INTERRUPTED) && isOpen());
|
||||
return n;
|
||||
}
|
||||
@ -895,12 +858,7 @@ public class FileChannelImpl
|
||||
long n;
|
||||
boolean append = fdAccess.getAppend(fd);
|
||||
do {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
n = nd.transferFrom(srcFD, fd, position, count, append);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
n = nd.transferFrom(srcFD, fd, position, count, append);
|
||||
} while ((n == IOStatus.INTERRUPTED) && isOpen());
|
||||
return n;
|
||||
}
|
||||
@ -1088,11 +1046,11 @@ public class FileChannelImpl
|
||||
if (!isOpen())
|
||||
return -1;
|
||||
do {
|
||||
long comp = Blocker.begin();
|
||||
boolean attempted = Blocker.begin(direct);
|
||||
try {
|
||||
n = IOUtil.read(fd, dst, position, direct, alignment, nd);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
Blocker.end(attempted);
|
||||
}
|
||||
} while ((n == IOStatus.INTERRUPTED) && isOpen());
|
||||
return IOStatus.normalize(n);
|
||||
@ -1133,11 +1091,11 @@ public class FileChannelImpl
|
||||
if (!isOpen())
|
||||
return -1;
|
||||
do {
|
||||
long comp = Blocker.begin();
|
||||
boolean attempted = Blocker.begin(sync || direct);
|
||||
try {
|
||||
n = IOUtil.write(fd, src, position, direct, alignment, nd);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
Blocker.end(attempted);
|
||||
}
|
||||
} while ((n == IOStatus.INTERRUPTED) && isOpen());
|
||||
return IOStatus.normalize(n);
|
||||
@ -1362,12 +1320,7 @@ public class FileChannelImpl
|
||||
synchronized (positionLock) {
|
||||
long filesize;
|
||||
do {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
filesize = nd.size(fd);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
filesize = nd.size(fd);
|
||||
} while ((filesize == IOStatus.INTERRUPTED) && isOpen());
|
||||
if (!isOpen())
|
||||
return null;
|
||||
@ -1379,12 +1332,7 @@ public class FileChannelImpl
|
||||
}
|
||||
int rv;
|
||||
do {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
rv = nd.truncate(fd, position + size);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
rv = nd.truncate(fd, position + size);
|
||||
} while ((rv == IOStatus.INTERRUPTED) && isOpen());
|
||||
if (!isOpen())
|
||||
return null;
|
||||
@ -1575,11 +1523,11 @@ public class FileChannelImpl
|
||||
return null;
|
||||
int n;
|
||||
do {
|
||||
long comp = Blocker.begin();
|
||||
boolean attempted = Blocker.begin();
|
||||
try {
|
||||
n = nd.lock(fd, true, position, size, shared);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
Blocker.end(attempted);
|
||||
}
|
||||
} while ((n == FileDispatcher.INTERRUPTED) && isOpen());
|
||||
if (isOpen()) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -26,7 +26,6 @@
|
||||
package java.io;
|
||||
|
||||
import java.util.Properties;
|
||||
import jdk.internal.misc.Blocker;
|
||||
import jdk.internal.util.StaticProperty;
|
||||
import sun.security.action.GetPropertyAction;
|
||||
|
||||
@ -161,12 +160,7 @@ final class UnixFileSystem extends FileSystem {
|
||||
|
||||
@Override
|
||||
public String canonicalize(String path) throws IOException {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
return canonicalize0(path);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
return canonicalize0(path);
|
||||
}
|
||||
private native String canonicalize0(String path) throws IOException;
|
||||
|
||||
@ -176,25 +170,13 @@ final class UnixFileSystem extends FileSystem {
|
||||
|
||||
@Override
|
||||
public int getBooleanAttributes(File f) {
|
||||
int rv;
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
rv = getBooleanAttributes0(f);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
int rv = getBooleanAttributes0(f);
|
||||
return rv | isHidden(f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasBooleanAttributes(File f, int attributes) {
|
||||
int rv;
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
rv = getBooleanAttributes0(f);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
int rv = getBooleanAttributes0(f);
|
||||
if ((attributes & BA_HIDDEN) != 0) {
|
||||
rv |= isHidden(f);
|
||||
}
|
||||
@ -207,45 +189,25 @@ final class UnixFileSystem extends FileSystem {
|
||||
|
||||
@Override
|
||||
public boolean checkAccess(File f, int access) {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
return checkAccess0(f, access);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
return checkAccess0(f, access);
|
||||
}
|
||||
private native boolean checkAccess0(File f, int access);
|
||||
|
||||
@Override
|
||||
public long getLastModifiedTime(File f) {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
return getLastModifiedTime0(f);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
return getLastModifiedTime0(f);
|
||||
}
|
||||
private native long getLastModifiedTime0(File f);
|
||||
|
||||
@Override
|
||||
public long getLength(File f) {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
return getLength0(f);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
return getLength0(f);
|
||||
}
|
||||
private native long getLength0(File f);
|
||||
|
||||
@Override
|
||||
public boolean setPermission(File f, int access, boolean enable, boolean owneronly) {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
return setPermission0(f, access, enable, owneronly);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
return setPermission0(f, access, enable, owneronly);
|
||||
}
|
||||
private native boolean setPermission0(File f, int access, boolean enable, boolean owneronly);
|
||||
|
||||
@ -253,78 +215,43 @@ final class UnixFileSystem extends FileSystem {
|
||||
|
||||
@Override
|
||||
public boolean createFileExclusively(String path) throws IOException {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
return createFileExclusively0(path);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
return createFileExclusively0(path);
|
||||
}
|
||||
private native boolean createFileExclusively0(String path) throws IOException;
|
||||
|
||||
@Override
|
||||
public boolean delete(File f) {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
return delete0(f);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
return delete0(f);
|
||||
}
|
||||
private native boolean delete0(File f);
|
||||
|
||||
@Override
|
||||
public String[] list(File f) {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
return list0(f);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
return list0(f);
|
||||
}
|
||||
private native String[] list0(File f);
|
||||
|
||||
@Override
|
||||
public boolean createDirectory(File f) {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
return createDirectory0(f);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
return createDirectory0(f);
|
||||
}
|
||||
private native boolean createDirectory0(File f);
|
||||
|
||||
@Override
|
||||
public boolean rename(File f1, File f2) {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
return rename0(f1, f2);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
return rename0(f1, f2);
|
||||
}
|
||||
private native boolean rename0(File f1, File f2);
|
||||
|
||||
@Override
|
||||
public boolean setLastModifiedTime(File f, long time) {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
return setLastModifiedTime0(f, time);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
return setLastModifiedTime0(f, time);
|
||||
}
|
||||
private native boolean setLastModifiedTime0(File f, long time);
|
||||
|
||||
@Override
|
||||
public boolean setReadOnly(File f) {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
return setReadOnly0(f);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
return setReadOnly0(f);
|
||||
}
|
||||
private native boolean setReadOnly0(File f);
|
||||
|
||||
@ -348,12 +275,7 @@ final class UnixFileSystem extends FileSystem {
|
||||
|
||||
@Override
|
||||
public long getSpace(File f, int t) {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
return getSpace0(f, t);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
return getSpace0(f, t);
|
||||
}
|
||||
private native long getSpace0(File f, int t);
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -626,7 +626,7 @@ final class ProcessImpl extends Process {
|
||||
*/
|
||||
private static class ProcessPipeOutputStream extends BufferedOutputStream {
|
||||
ProcessPipeOutputStream(int fd) {
|
||||
super(new FileOutputStream(newFileDescriptor(fd)));
|
||||
super(new PipeOutputStream(newFileDescriptor(fd)));
|
||||
}
|
||||
|
||||
/** Called by the process reaper thread when the process exits. */
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -111,11 +111,11 @@ class PollSelectorImpl extends SelectorImpl {
|
||||
int numPolled;
|
||||
do {
|
||||
long startTime = timedPoll ? System.nanoTime() : 0;
|
||||
long comp = Blocker.begin();
|
||||
boolean attempted = Blocker.begin(blocking);
|
||||
try {
|
||||
numPolled = poll(pollArray.address(), pollArraySize, to);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
Blocker.end(attempted);
|
||||
}
|
||||
if (numPolled == IOStatus.INTERRUPTED && timedPoll) {
|
||||
// timed poll interrupted so need to adjust timeout
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2008, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2008, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -131,8 +131,8 @@ class UnixChannelFactory {
|
||||
throw new IllegalArgumentException("APPEND + TRUNCATE_EXISTING not allowed");
|
||||
|
||||
FileDescriptor fdObj = open(dfd, path, pathForPermissionCheck, flags, mode);
|
||||
return FileChannelImpl.open(fdObj, path.toString(), flags.read,
|
||||
flags.write, flags.direct, null);
|
||||
return FileChannelImpl.open(fdObj, path.toString(), flags.read, flags.write,
|
||||
(flags.sync || flags.dsync), flags.direct, null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -52,7 +52,6 @@ import java.util.Objects;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.regex.Pattern;
|
||||
import jdk.internal.misc.Blocker;
|
||||
import sun.nio.ch.DirectBuffer;
|
||||
import sun.nio.ch.IOStatus;
|
||||
import sun.security.action.GetPropertyAction;
|
||||
@ -682,7 +681,6 @@ abstract class UnixFileSystem
|
||||
// Some forms of direct copy do not work on zero size files
|
||||
if (!directCopyNotSupported && attrs.size() > 0) {
|
||||
// copy bytes to target using platform function
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
int res = directCopy(fo, fi, addressToPollForCancel);
|
||||
if (res == 0) {
|
||||
@ -692,8 +690,6 @@ abstract class UnixFileSystem
|
||||
}
|
||||
} catch (UnixException x) {
|
||||
x.rethrowAsIOException(source, target);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
}
|
||||
|
||||
@ -703,14 +699,11 @@ abstract class UnixFileSystem
|
||||
ByteBuffer buf =
|
||||
sun.nio.ch.Util.getTemporaryDirectBuffer(bufferSize);
|
||||
try {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
bufferedCopy(fo, fi, ((DirectBuffer)buf).address(),
|
||||
bufferSize, addressToPollForCancel);
|
||||
} catch (UnixException x) {
|
||||
x.rethrowAsIOException(source, target);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
} finally {
|
||||
sun.nio.ch.Util.releaseTemporaryDirectBuffer(buf);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2008, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2008, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -26,7 +26,6 @@
|
||||
package sun.nio.fs;
|
||||
|
||||
import java.util.function.Function;
|
||||
import jdk.internal.misc.Blocker;
|
||||
|
||||
/**
|
||||
* Unix system and library calls.
|
||||
@ -67,12 +66,7 @@ class UnixNativeDispatcher {
|
||||
*/
|
||||
static int open(UnixPath path, int flags, int mode) throws UnixException {
|
||||
try (NativeBuffer buffer = copyToNativeBuffer(path)) {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
return open0(buffer.address(), flags, mode);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
return open0(buffer.address(), flags, mode);
|
||||
}
|
||||
}
|
||||
private static native int open0(long pathAddress, int flags, int mode)
|
||||
@ -83,12 +77,7 @@ class UnixNativeDispatcher {
|
||||
*/
|
||||
static int openat(int dfd, byte[] path, int flags, int mode) throws UnixException {
|
||||
try (NativeBuffer buffer = NativeBuffers.asNativeBuffer(path)) {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
return openat0(dfd, buffer.address(), flags, mode);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
return openat0(dfd, buffer.address(), flags, mode);
|
||||
}
|
||||
}
|
||||
private static native int openat0(int dfd, long pathAddress, int flags, int mode)
|
||||
@ -138,12 +127,7 @@ class UnixNativeDispatcher {
|
||||
static void link(UnixPath existing, UnixPath newfile) throws UnixException {
|
||||
try (NativeBuffer existingBuffer = copyToNativeBuffer(existing);
|
||||
NativeBuffer newBuffer = copyToNativeBuffer(newfile)) {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
link0(existingBuffer.address(), newBuffer.address());
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
link0(existingBuffer.address(), newBuffer.address());
|
||||
}
|
||||
}
|
||||
private static native void link0(long existingAddress, long newAddress)
|
||||
@ -154,12 +138,7 @@ class UnixNativeDispatcher {
|
||||
*/
|
||||
static void unlink(UnixPath path) throws UnixException {
|
||||
try (NativeBuffer buffer = copyToNativeBuffer(path)) {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
unlink0(buffer.address());
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
unlink0(buffer.address());
|
||||
}
|
||||
}
|
||||
private static native void unlink0(long pathAddress) throws UnixException;
|
||||
@ -169,12 +148,7 @@ class UnixNativeDispatcher {
|
||||
*/
|
||||
static void unlinkat(int dfd, byte[] path, int flag) throws UnixException {
|
||||
try (NativeBuffer buffer = NativeBuffers.asNativeBuffer(path)) {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
unlinkat0(dfd, buffer.address(), flag);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
unlinkat0(dfd, buffer.address(), flag);
|
||||
}
|
||||
}
|
||||
private static native void unlinkat0(int dfd, long pathAddress, int flag)
|
||||
@ -185,12 +159,7 @@ class UnixNativeDispatcher {
|
||||
*/
|
||||
static void mknod(UnixPath path, int mode, long dev) throws UnixException {
|
||||
try (NativeBuffer buffer = copyToNativeBuffer(path)) {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
mknod0(buffer.address(), mode, dev);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
mknod0(buffer.address(), mode, dev);
|
||||
}
|
||||
}
|
||||
private static native void mknod0(long pathAddress, int mode, long dev)
|
||||
@ -202,12 +171,7 @@ class UnixNativeDispatcher {
|
||||
static void rename(UnixPath from, UnixPath to) throws UnixException {
|
||||
try (NativeBuffer fromBuffer = copyToNativeBuffer(from);
|
||||
NativeBuffer toBuffer = copyToNativeBuffer(to)) {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
rename0(fromBuffer.address(), toBuffer.address());
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
rename0(fromBuffer.address(), toBuffer.address());
|
||||
}
|
||||
}
|
||||
private static native void rename0(long fromAddress, long toAddress)
|
||||
@ -219,12 +183,7 @@ class UnixNativeDispatcher {
|
||||
static void renameat(int fromfd, byte[] from, int tofd, byte[] to) throws UnixException {
|
||||
try (NativeBuffer fromBuffer = NativeBuffers.asNativeBuffer(from);
|
||||
NativeBuffer toBuffer = NativeBuffers.asNativeBuffer(to)) {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
renameat0(fromfd, fromBuffer.address(), tofd, toBuffer.address());
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
renameat0(fromfd, fromBuffer.address(), tofd, toBuffer.address());
|
||||
}
|
||||
}
|
||||
private static native void renameat0(int fromfd, long fromAddress, int tofd, long toAddress)
|
||||
@ -235,12 +194,7 @@ class UnixNativeDispatcher {
|
||||
*/
|
||||
static void mkdir(UnixPath path, int mode) throws UnixException {
|
||||
try (NativeBuffer buffer = copyToNativeBuffer(path)) {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
mkdir0(buffer.address(), mode);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
mkdir0(buffer.address(), mode);
|
||||
}
|
||||
}
|
||||
private static native void mkdir0(long pathAddress, int mode) throws UnixException;
|
||||
@ -250,12 +204,7 @@ class UnixNativeDispatcher {
|
||||
*/
|
||||
static void rmdir(UnixPath path) throws UnixException {
|
||||
try (NativeBuffer buffer = copyToNativeBuffer(path)) {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
rmdir0(buffer.address());
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
rmdir0(buffer.address());
|
||||
}
|
||||
}
|
||||
private static native void rmdir0(long pathAddress) throws UnixException;
|
||||
@ -267,12 +216,7 @@ class UnixNativeDispatcher {
|
||||
*/
|
||||
static byte[] readlink(UnixPath path) throws UnixException {
|
||||
try (NativeBuffer buffer = copyToNativeBuffer(path)) {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
return readlink0(buffer.address());
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
return readlink0(buffer.address());
|
||||
}
|
||||
}
|
||||
private static native byte[] readlink0(long pathAddress) throws UnixException;
|
||||
@ -284,12 +228,7 @@ class UnixNativeDispatcher {
|
||||
*/
|
||||
static byte[] realpath(UnixPath path) throws UnixException {
|
||||
try (NativeBuffer buffer = copyToNativeBuffer(path)) {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
return realpath0(buffer.address());
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
return realpath0(buffer.address());
|
||||
}
|
||||
}
|
||||
private static native byte[] realpath0(long pathAddress) throws UnixException;
|
||||
@ -300,12 +239,7 @@ class UnixNativeDispatcher {
|
||||
static void symlink(byte[] name1, UnixPath name2) throws UnixException {
|
||||
try (NativeBuffer targetBuffer = NativeBuffers.asNativeBuffer(name1);
|
||||
NativeBuffer linkBuffer = copyToNativeBuffer(name2)) {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
symlink0(targetBuffer.address(), linkBuffer.address());
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
symlink0(targetBuffer.address(), linkBuffer.address());
|
||||
}
|
||||
}
|
||||
private static native void symlink0(long name1, long name2)
|
||||
@ -316,26 +250,16 @@ class UnixNativeDispatcher {
|
||||
*/
|
||||
static void stat(UnixPath path, UnixFileAttributes attrs) throws UnixException {
|
||||
try (NativeBuffer buffer = copyToNativeBuffer(path)) {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
int errno = stat0(buffer.address(), attrs);
|
||||
if (errno != 0) {
|
||||
throw new UnixException(errno);
|
||||
}
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
int errno = stat0(buffer.address(), attrs);
|
||||
if (errno != 0) {
|
||||
throw new UnixException(errno);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int stat2(UnixPath path, UnixFileAttributes attrs) {
|
||||
try (NativeBuffer buffer = copyToNativeBuffer(path)) {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
return stat0(buffer.address(), attrs);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
return stat0(buffer.address(), attrs);
|
||||
}
|
||||
}
|
||||
|
||||
@ -346,12 +270,7 @@ class UnixNativeDispatcher {
|
||||
*/
|
||||
static void lstat(UnixPath path, UnixFileAttributes attrs) throws UnixException {
|
||||
try (NativeBuffer buffer = copyToNativeBuffer(path)) {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
lstat0(buffer.address(), attrs);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
lstat0(buffer.address(), attrs);
|
||||
}
|
||||
}
|
||||
private static native void lstat0(long pathAddress, UnixFileAttributes attrs)
|
||||
@ -361,12 +280,7 @@ class UnixNativeDispatcher {
|
||||
* fstat(int filedes, struct stat* buf)
|
||||
*/
|
||||
static void fstat(int fd, UnixFileAttributes attrs) throws UnixException {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
fstat0(fd, attrs);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
fstat0(fd, attrs);
|
||||
}
|
||||
private static native void fstat0(int fd, UnixFileAttributes attrs)
|
||||
throws UnixException;
|
||||
@ -378,12 +292,7 @@ class UnixNativeDispatcher {
|
||||
throws UnixException
|
||||
{
|
||||
try (NativeBuffer buffer = NativeBuffers.asNativeBuffer(path)) {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
fstatat0(dfd, buffer.address(), flag, attrs);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
fstatat0(dfd, buffer.address(), flag, attrs);
|
||||
}
|
||||
}
|
||||
private static native void fstatat0(int dfd, long pathAddress, int flag,
|
||||
@ -394,12 +303,7 @@ class UnixNativeDispatcher {
|
||||
*/
|
||||
static void chown(UnixPath path, int uid, int gid) throws UnixException {
|
||||
try (NativeBuffer buffer = copyToNativeBuffer(path)) {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
chown0(buffer.address(), uid, gid);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
chown0(buffer.address(), uid, gid);
|
||||
}
|
||||
}
|
||||
private static native void chown0(long pathAddress, int uid, int gid)
|
||||
@ -410,12 +314,7 @@ class UnixNativeDispatcher {
|
||||
*/
|
||||
static void lchown(UnixPath path, int uid, int gid) throws UnixException {
|
||||
try (NativeBuffer buffer = copyToNativeBuffer(path)) {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
lchown0(buffer.address(), uid, gid);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
lchown0(buffer.address(), uid, gid);
|
||||
}
|
||||
}
|
||||
private static native void lchown0(long pathAddress, int uid, int gid)
|
||||
@ -425,12 +324,7 @@ class UnixNativeDispatcher {
|
||||
* fchown(int filedes, uid_t owner, gid_t group)
|
||||
*/
|
||||
static void fchown(int fd, int uid, int gid) throws UnixException {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
fchown0(fd, uid, gid);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
fchown0(fd, uid, gid);
|
||||
}
|
||||
static native void fchown0(int fd, int uid, int gid) throws UnixException;
|
||||
|
||||
@ -439,12 +333,7 @@ class UnixNativeDispatcher {
|
||||
*/
|
||||
static void chmod(UnixPath path, int mode) throws UnixException {
|
||||
try (NativeBuffer buffer = copyToNativeBuffer(path)) {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
chmod0(buffer.address(), mode);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
chmod0(buffer.address(), mode);
|
||||
}
|
||||
}
|
||||
private static native void chmod0(long pathAddress, int mode)
|
||||
@ -454,12 +343,7 @@ class UnixNativeDispatcher {
|
||||
* fchmod(int fildes, mode_t mode)
|
||||
*/
|
||||
static void fchmod(int fd, int mode) throws UnixException {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
fchmod0(fd, mode);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
fchmod0(fd, mode);
|
||||
}
|
||||
private static native void fchmod0(int fd, int mode) throws UnixException;
|
||||
|
||||
@ -470,12 +354,7 @@ class UnixNativeDispatcher {
|
||||
throws UnixException
|
||||
{
|
||||
try (NativeBuffer buffer = copyToNativeBuffer(path)) {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
utimes0(buffer.address(), times0, times1);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
utimes0(buffer.address(), times0, times1);
|
||||
}
|
||||
}
|
||||
private static native void utimes0(long pathAddress, long times0, long times1)
|
||||
@ -485,12 +364,7 @@ class UnixNativeDispatcher {
|
||||
* futimes(int fildes, const struct timeval times[2])
|
||||
*/
|
||||
static void futimes(int fd, long times0, long times1) throws UnixException {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
futimes0(fd, times0, times1);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
futimes0(fd, times0, times1);
|
||||
}
|
||||
private static native void futimes0(int fd, long times0, long times1)
|
||||
throws UnixException;
|
||||
@ -499,12 +373,7 @@ class UnixNativeDispatcher {
|
||||
* futimens(int fildes, const struct timespec times[2])
|
||||
*/
|
||||
static void futimens(int fd, long times0, long times1) throws UnixException {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
futimens0(fd, times0, times1);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
futimens0(fd, times0, times1);
|
||||
}
|
||||
private static native void futimens0(int fd, long times0, long times1)
|
||||
throws UnixException;
|
||||
@ -516,12 +385,7 @@ class UnixNativeDispatcher {
|
||||
throws UnixException
|
||||
{
|
||||
try (NativeBuffer buffer = copyToNativeBuffer(path)) {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
lutimes0(buffer.address(), times0, times1);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
lutimes0(buffer.address(), times0, times1);
|
||||
}
|
||||
}
|
||||
private static native void lutimes0(long pathAddress, long times0, long times1)
|
||||
@ -532,12 +396,7 @@ class UnixNativeDispatcher {
|
||||
*/
|
||||
static long opendir(UnixPath path) throws UnixException {
|
||||
try (NativeBuffer buffer = copyToNativeBuffer(path)) {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
return opendir0(buffer.address());
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
return opendir0(buffer.address());
|
||||
}
|
||||
}
|
||||
private static native long opendir0(long pathAddress) throws UnixException;
|
||||
@ -559,12 +418,7 @@ class UnixNativeDispatcher {
|
||||
* @return dirent->d_name
|
||||
*/
|
||||
static byte[] readdir(long dir) throws UnixException {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
return readdir0(dir);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
return readdir0(dir);
|
||||
}
|
||||
static native byte[] readdir0(long dir) throws UnixException;
|
||||
|
||||
@ -572,12 +426,7 @@ class UnixNativeDispatcher {
|
||||
* size_t read(int fildes, void* buf, size_t nbyte)
|
||||
*/
|
||||
static int read(int fildes, long buf, int nbyte) throws UnixException {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
return read0(fildes, buf, nbyte);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
return read0(fildes, buf, nbyte);
|
||||
}
|
||||
private static native int read0(int fildes, long buf, int nbyte) throws UnixException;
|
||||
|
||||
@ -585,12 +434,7 @@ class UnixNativeDispatcher {
|
||||
* size_t writeint fildes, void* buf, size_t nbyte)
|
||||
*/
|
||||
static int write(int fildes, long buf, int nbyte) throws UnixException {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
return write0(fildes, buf, nbyte);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
return write0(fildes, buf, nbyte);
|
||||
}
|
||||
private static native int write0(int fildes, long buf, int nbyte) throws UnixException;
|
||||
|
||||
@ -599,12 +443,7 @@ class UnixNativeDispatcher {
|
||||
*/
|
||||
static int access(UnixPath path, int amode) {
|
||||
try (NativeBuffer buffer = copyToNativeBuffer(path)) {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
return access0(buffer.address(), amode);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
return access0(buffer.address(), amode);
|
||||
}
|
||||
}
|
||||
private static native int access0(long pathAddress, int amode);
|
||||
@ -630,12 +469,7 @@ class UnixNativeDispatcher {
|
||||
*/
|
||||
static int getpwnam(String name) throws UnixException {
|
||||
try (NativeBuffer buffer = NativeBuffers.asNativeBuffer(Util.toBytes(name))) {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
return getpwnam0(buffer.address());
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
return getpwnam0(buffer.address());
|
||||
}
|
||||
}
|
||||
private static native int getpwnam0(long nameAddress) throws UnixException;
|
||||
@ -647,12 +481,7 @@ class UnixNativeDispatcher {
|
||||
*/
|
||||
static int getgrnam(String name) throws UnixException {
|
||||
try (NativeBuffer buffer = NativeBuffers.asNativeBuffer(Util.toBytes(name))) {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
return getgrnam0(buffer.address());
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
return getgrnam0(buffer.address());
|
||||
}
|
||||
}
|
||||
private static native int getgrnam0(long nameAddress) throws UnixException;
|
||||
@ -664,12 +493,7 @@ class UnixNativeDispatcher {
|
||||
throws UnixException
|
||||
{
|
||||
try (NativeBuffer buffer = copyToNativeBuffer(path)) {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
statvfs0(buffer.address(), attrs);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
statvfs0(buffer.address(), attrs);
|
||||
}
|
||||
}
|
||||
private static native void statvfs0(long pathAddress, UnixFileStoreAttributes attrs)
|
||||
@ -687,12 +511,7 @@ class UnixNativeDispatcher {
|
||||
throws UnixException
|
||||
{
|
||||
try (NativeBuffer buffer = NativeBuffers.asNativeBuffer(name)) {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
return fgetxattr0(filedes, buffer.address(), valueAddress, valueLen);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
return fgetxattr0(filedes, buffer.address(), valueAddress, valueLen);
|
||||
}
|
||||
}
|
||||
|
||||
@ -706,12 +525,7 @@ class UnixNativeDispatcher {
|
||||
throws UnixException
|
||||
{
|
||||
try (NativeBuffer buffer = NativeBuffers.asNativeBuffer(name)) {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
fsetxattr0(filedes, buffer.address(), valueAddress, valueLen);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
fsetxattr0(filedes, buffer.address(), valueAddress, valueLen);
|
||||
}
|
||||
}
|
||||
|
||||
@ -723,12 +537,7 @@ class UnixNativeDispatcher {
|
||||
*/
|
||||
static void fremovexattr(int filedes, byte[] name) throws UnixException {
|
||||
try (NativeBuffer buffer = NativeBuffers.asNativeBuffer(name)) {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
fremovexattr0(filedes, buffer.address());
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
fremovexattr0(filedes, buffer.address());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -30,7 +30,6 @@ import java.nio.file.Path;
|
||||
import java.util.BitSet;
|
||||
import java.util.Locale;
|
||||
import java.util.Properties;
|
||||
import jdk.internal.misc.Blocker;
|
||||
import sun.security.action.GetPropertyAction;
|
||||
|
||||
/**
|
||||
@ -491,12 +490,7 @@ final class WinNTFileSystem extends FileSystem {
|
||||
return path;
|
||||
return "" + ((char) (c-32)) + ':' + '\\';
|
||||
}
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
return canonicalize0(path);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
return canonicalize0(path);
|
||||
}
|
||||
|
||||
private native String canonicalize0(String path)
|
||||
@ -507,56 +501,31 @@ final class WinNTFileSystem extends FileSystem {
|
||||
|
||||
@Override
|
||||
public int getBooleanAttributes(File f) {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
return getBooleanAttributes0(f);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
return getBooleanAttributes0(f);
|
||||
}
|
||||
private native int getBooleanAttributes0(File f);
|
||||
|
||||
@Override
|
||||
public boolean checkAccess(File f, int access) {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
return checkAccess0(f, access);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
return checkAccess0(f, access);
|
||||
}
|
||||
private native boolean checkAccess0(File f, int access);
|
||||
|
||||
@Override
|
||||
public long getLastModifiedTime(File f) {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
return getLastModifiedTime0(f);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
return getLastModifiedTime0(f);
|
||||
}
|
||||
private native long getLastModifiedTime0(File f);
|
||||
|
||||
@Override
|
||||
public long getLength(File f) {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
return getLength0(f);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
return getLength0(f);
|
||||
}
|
||||
private native long getLength0(File f);
|
||||
|
||||
@Override
|
||||
public boolean setPermission(File f, int access, boolean enable, boolean owneronly) {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
return setPermission0(f, access, enable, owneronly);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
return setPermission0(f, access, enable, owneronly);
|
||||
}
|
||||
private native boolean setPermission0(File f, int access, boolean enable, boolean owneronly);
|
||||
|
||||
@ -564,78 +533,43 @@ final class WinNTFileSystem extends FileSystem {
|
||||
|
||||
@Override
|
||||
public boolean createFileExclusively(String path) throws IOException {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
return createFileExclusively0(path);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
return createFileExclusively0(path);
|
||||
}
|
||||
private native boolean createFileExclusively0(String path) throws IOException;
|
||||
|
||||
@Override
|
||||
public String[] list(File f) {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
return list0(f);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
return list0(f);
|
||||
}
|
||||
private native String[] list0(File f);
|
||||
|
||||
@Override
|
||||
public boolean createDirectory(File f) {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
return createDirectory0(f);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
return createDirectory0(f);
|
||||
}
|
||||
private native boolean createDirectory0(File f);
|
||||
|
||||
@Override
|
||||
public boolean setLastModifiedTime(File f, long time) {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
return setLastModifiedTime0(f, time);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
return setLastModifiedTime0(f, time);
|
||||
}
|
||||
private native boolean setLastModifiedTime0(File f, long time);
|
||||
|
||||
@Override
|
||||
public boolean setReadOnly(File f) {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
return setReadOnly0(f);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
return setReadOnly0(f);
|
||||
}
|
||||
private native boolean setReadOnly0(File f);
|
||||
|
||||
@Override
|
||||
public boolean delete(File f) {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
return delete0(f);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
return delete0(f);
|
||||
}
|
||||
private native boolean delete0(File f);
|
||||
|
||||
@Override
|
||||
public boolean rename(File f1, File f2) {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
return rename0(f1, f2);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
return rename0(f1, f2);
|
||||
}
|
||||
private native boolean rename0(File f1, File f2);
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1995, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1995, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -515,7 +515,7 @@ final class ProcessImpl extends Process {
|
||||
fdAccess.setHandle(stdin_fd, stdHandles[0]);
|
||||
fdAccess.registerCleanup(stdin_fd);
|
||||
stdin_stream = new BufferedOutputStream(
|
||||
new FileOutputStream(stdin_fd));
|
||||
new PipeOutputStream(stdin_fd));
|
||||
}
|
||||
|
||||
if (stdHandles[1] == -1L || forceNullOutputStream)
|
||||
@ -564,11 +564,11 @@ final class ProcessImpl extends Process {
|
||||
private static native int getExitCodeProcess(long handle);
|
||||
|
||||
public int waitFor() throws InterruptedException {
|
||||
long comp = Blocker.begin();
|
||||
boolean attempted = Blocker.begin();
|
||||
try {
|
||||
waitForInterruptibly(handle);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
Blocker.end(attempted);
|
||||
}
|
||||
if (Thread.interrupted())
|
||||
throw new InterruptedException();
|
||||
@ -593,11 +593,11 @@ final class ProcessImpl extends Process {
|
||||
// if wraps around then wait a long while
|
||||
msTimeout = Integer.MAX_VALUE;
|
||||
}
|
||||
long comp = Blocker.begin();
|
||||
boolean attempted = Blocker.begin();
|
||||
try {
|
||||
waitForTimeoutInterruptibly(handle, msTimeout);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
Blocker.end(attempted);
|
||||
}
|
||||
if (Thread.interrupted())
|
||||
throw new InterruptedException();
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -109,11 +109,11 @@ class WEPollSelectorImpl extends SelectorImpl {
|
||||
processDeregisterQueue();
|
||||
try {
|
||||
begin(blocking);
|
||||
long comp = Blocker.begin(blocking);
|
||||
boolean attempted = Blocker.begin(blocking);
|
||||
try {
|
||||
numEntries = WEPoll.wait(eph, pollArrayAddress, NUM_EPOLLEVENTS, to);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
Blocker.end(attempted);
|
||||
}
|
||||
} finally {
|
||||
end(blocking);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2008, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2008, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -166,8 +166,8 @@ class WindowsChannelFactory {
|
||||
throw new IllegalArgumentException("APPEND + TRUNCATE_EXISTING not allowed");
|
||||
|
||||
FileDescriptor fdObj = open(pathForWindows, pathToCheck, flags, pSecurityDescriptor);
|
||||
return FileChannelImpl.open(fdObj, pathForWindows, flags.read,
|
||||
flags.write, flags.direct, null);
|
||||
return FileChannelImpl.open(fdObj, pathForWindows, flags.read, flags.write,
|
||||
(flags.sync || flags.dsync), flags.direct, null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2008, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2008, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,7 +25,6 @@
|
||||
|
||||
package sun.nio.fs;
|
||||
|
||||
import jdk.internal.misc.Blocker;
|
||||
import jdk.internal.misc.Unsafe;
|
||||
|
||||
import static sun.nio.fs.WindowsConstants.*;
|
||||
@ -68,17 +67,12 @@ class WindowsNativeDispatcher {
|
||||
throws WindowsException
|
||||
{
|
||||
try (NativeBuffer buffer = asNativeBuffer(path)) {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
return CreateFile0(buffer.address(),
|
||||
dwDesiredAccess,
|
||||
dwShareMode,
|
||||
lpSecurityAttributes,
|
||||
dwCreationDisposition,
|
||||
dwFlagsAndAttributes);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
return CreateFile0(buffer.address(),
|
||||
dwDesiredAccess,
|
||||
dwShareMode,
|
||||
lpSecurityAttributes,
|
||||
dwCreationDisposition,
|
||||
dwFlagsAndAttributes);
|
||||
}
|
||||
}
|
||||
static long CreateFile(String path,
|
||||
@ -113,12 +107,7 @@ class WindowsNativeDispatcher {
|
||||
*/
|
||||
static void DeleteFile(String path) throws WindowsException {
|
||||
try (NativeBuffer buffer = asNativeBuffer(path)) {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
DeleteFile0(buffer.address());
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
DeleteFile0(buffer.address());
|
||||
}
|
||||
}
|
||||
private static native void DeleteFile0(long lpFileName)
|
||||
@ -132,12 +121,7 @@ class WindowsNativeDispatcher {
|
||||
*/
|
||||
static void CreateDirectory(String path, long lpSecurityAttributes) throws WindowsException {
|
||||
try (NativeBuffer buffer = asNativeBuffer(path)) {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
CreateDirectory0(buffer.address(), lpSecurityAttributes);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
CreateDirectory0(buffer.address(), lpSecurityAttributes);
|
||||
}
|
||||
}
|
||||
private static native void CreateDirectory0(long lpFileName, long lpSecurityAttributes)
|
||||
@ -150,12 +134,7 @@ class WindowsNativeDispatcher {
|
||||
*/
|
||||
static void RemoveDirectory(String path) throws WindowsException {
|
||||
try (NativeBuffer buffer = asNativeBuffer(path)) {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
RemoveDirectory0(buffer.address());
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
RemoveDirectory0(buffer.address());
|
||||
}
|
||||
}
|
||||
private static native void RemoveDirectory0(long lpFileName)
|
||||
@ -200,12 +179,7 @@ class WindowsNativeDispatcher {
|
||||
static FirstFile FindFirstFile(String path) throws WindowsException {
|
||||
try (NativeBuffer buffer = asNativeBuffer(path)) {
|
||||
FirstFile data = new FirstFile();
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
FindFirstFile0(buffer.address(), data);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
FindFirstFile0(buffer.address(), data);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@ -230,12 +204,7 @@ class WindowsNativeDispatcher {
|
||||
*/
|
||||
static long FindFirstFile(String path, long address) throws WindowsException {
|
||||
try (NativeBuffer buffer = asNativeBuffer(path)) {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
return FindFirstFile1(buffer.address(), address);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
return FindFirstFile1(buffer.address(), address);
|
||||
}
|
||||
}
|
||||
private static native long FindFirstFile1(long lpFileName, long address)
|
||||
@ -250,12 +219,7 @@ class WindowsNativeDispatcher {
|
||||
* @return lpFindFileData->cFileName or null
|
||||
*/
|
||||
static String FindNextFile(long handle, long address) throws WindowsException {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
return FindNextFile0(handle, address);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
return FindNextFile0(handle, address);
|
||||
}
|
||||
private static native String FindNextFile0(long handle, long address)
|
||||
throws WindowsException;
|
||||
@ -271,12 +235,7 @@ class WindowsNativeDispatcher {
|
||||
static FirstStream FindFirstStream(String path) throws WindowsException {
|
||||
try (NativeBuffer buffer = asNativeBuffer(path)) {
|
||||
FirstStream data = new FirstStream();
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
FindFirstStream0(buffer.address(), data);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
FindFirstStream0(buffer.address(), data);
|
||||
if (data.handle() == WindowsConstants.INVALID_HANDLE_VALUE)
|
||||
return null;
|
||||
return data;
|
||||
@ -300,12 +259,7 @@ class WindowsNativeDispatcher {
|
||||
* )
|
||||
*/
|
||||
static String FindNextStream(long handle) throws WindowsException {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
return FindNextStream0(handle);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
return FindNextStream0(handle);
|
||||
}
|
||||
private static native String FindNextStream0(long handle) throws WindowsException;
|
||||
|
||||
@ -325,12 +279,7 @@ class WindowsNativeDispatcher {
|
||||
static void GetFileInformationByHandle(long handle, long address)
|
||||
throws WindowsException
|
||||
{
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
GetFileInformationByHandle0(handle, address);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
GetFileInformationByHandle0(handle, address);
|
||||
}
|
||||
private static native void GetFileInformationByHandle0(long handle, long address)
|
||||
throws WindowsException;
|
||||
@ -351,13 +300,7 @@ class WindowsNativeDispatcher {
|
||||
{
|
||||
try (NativeBuffer sourceBuffer = asNativeBuffer(source);
|
||||
NativeBuffer targetBuffer = asNativeBuffer(target)) {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
CopyFileEx0(sourceBuffer.address(), targetBuffer.address(), flags,
|
||||
addressToPollForCancel);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
CopyFileEx0(sourceBuffer.address(), targetBuffer.address(), flags, addressToPollForCancel);
|
||||
}
|
||||
}
|
||||
private static native void CopyFileEx0(long existingAddress, long newAddress,
|
||||
@ -375,12 +318,7 @@ class WindowsNativeDispatcher {
|
||||
{
|
||||
try (NativeBuffer sourceBuffer = asNativeBuffer(source);
|
||||
NativeBuffer targetBuffer = asNativeBuffer(target)) {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
MoveFileEx0(sourceBuffer.address(), targetBuffer.address(), flags);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
MoveFileEx0(sourceBuffer.address(), targetBuffer.address(), flags);
|
||||
}
|
||||
}
|
||||
private static native void MoveFileEx0(long existingAddress, long newAddress,
|
||||
@ -393,12 +331,7 @@ class WindowsNativeDispatcher {
|
||||
*/
|
||||
static int GetFileAttributes(String path) throws WindowsException {
|
||||
try (NativeBuffer buffer = asNativeBuffer(path)) {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
return GetFileAttributes0(buffer.address());
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
return GetFileAttributes0(buffer.address());
|
||||
}
|
||||
}
|
||||
private static native int GetFileAttributes0(long lpFileName)
|
||||
@ -413,12 +346,7 @@ class WindowsNativeDispatcher {
|
||||
throws WindowsException
|
||||
{
|
||||
try (NativeBuffer buffer = asNativeBuffer(path)) {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
SetFileAttributes0(buffer.address(), dwFileAttributes);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
SetFileAttributes0(buffer.address(), dwFileAttributes);
|
||||
}
|
||||
}
|
||||
private static native void SetFileAttributes0(long lpFileName,
|
||||
@ -433,12 +361,7 @@ class WindowsNativeDispatcher {
|
||||
*/
|
||||
static void GetFileAttributesEx(String path, long address) throws WindowsException {
|
||||
try (NativeBuffer buffer = asNativeBuffer(path)) {
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
GetFileAttributesEx0(buffer.address(), address);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
GetFileAttributesEx0(buffer.address(), address);
|
||||
}
|
||||
}
|
||||
private static native void GetFileAttributesEx0(long lpFileName, long address)
|
||||
@ -455,12 +378,7 @@ class WindowsNativeDispatcher {
|
||||
static void SetFileTime(long handle, long createTime, long lastAccessTime, long lastWriteTime)
|
||||
throws WindowsException
|
||||
{
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
SetFileTime0(handle, createTime, lastAccessTime, lastWriteTime);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
SetFileTime0(handle, createTime, lastAccessTime, lastWriteTime);
|
||||
}
|
||||
private static native void SetFileTime0(long handle,
|
||||
long createTime,
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2004, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -368,16 +368,21 @@ public class Object {
|
||||
* @see java.lang.Object#notifyAll()
|
||||
*/
|
||||
public final void wait(long timeoutMillis) throws InterruptedException {
|
||||
long comp = Blocker.begin();
|
||||
if (!Thread.currentThread().isVirtual()) {
|
||||
wait0(timeoutMillis);
|
||||
return;
|
||||
}
|
||||
|
||||
// virtual thread waiting
|
||||
boolean attempted = Blocker.begin();
|
||||
try {
|
||||
wait0(timeoutMillis);
|
||||
} catch (InterruptedException e) {
|
||||
Thread thread = Thread.currentThread();
|
||||
if (thread.isVirtual())
|
||||
thread.getAndClearInterrupt();
|
||||
// virtual thread's interrupt status needs to be cleared
|
||||
Thread.currentThread().getAndClearInterrupt();
|
||||
throw e;
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
Blocker.end(attempted);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user