test/jdk/java/nio/channels/spi/SelectorProvider/inheritedChannel/UnixDomainSocket.java
--- a/test/jdk/java/nio/channels/spi/SelectorProvider/inheritedChannel/UnixDomainSocket.java Tue Sep 24 17:08:19 2019 +0200
+++ b/test/jdk/java/nio/channels/spi/SelectorProvider/inheritedChannel/UnixDomainSocket.java Tue Sep 24 16:19:11 2019 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 2019 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
@@ -37,21 +37,44 @@
}
private final int fd;
+ private volatile String name;
+
+ public UnixDomainSocket() throws IOException {
+ this.fd = create();
+ }
+
+ public void bind(String name) throws IOException {
+ bind0(fd, name);
+ this.name = name;
+ }
+
+ public UnixDomainSocket accept() throws IOException {
+ int newsock = accept0(fd);
+ return new UnixDomainSocket(newsock);
+ }
public UnixDomainSocket(int fd) {
this.fd = fd;
}
+ public void connect(String dest) throws IOException {
+ connect0(fd, dest);
+ }
+
public int read() throws IOException {
return read0(fd);
}
+ public String name() {
+ return name;
+ }
+
public void write(int w) throws IOException {
write0(fd, w);
}
public void close() {
- close0(fd);
+ close0(fd, name); // close0 will unlink name if non-null
}
public int fd() {
@@ -62,11 +85,16 @@
return "UnixDomainSocket: fd=" + Integer.toString(fd);
}
+ private static native int create() throws IOException;
+ private static native void bind0(int fd, String name) throws IOException;
+ private static native int accept0(int fd) throws IOException;
+ private static native int connect0(int fd, String name) throws IOException;
+
/* read and write bytes with UNIX domain sockets */
private static native int read0(int fd) throws IOException;
private static native void write0(int fd, int w) throws IOException;
- private static native void close0(int fd);
+ private static native void close0(int fd, String name);
private static native void init();
public static native UnixDomainSocket[] socketpair();
}