/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* The listener returned by startListening
*/
long id;
}
long id() {
return id;
}
}
return name;
}
return address();
}
}
initialize();
}
return "SharedMemory";
}
return "javadebug";
}
/**
* Return localized description of this transport service
*/
synchronized (this) {
}
}
}
return new SharedMemoryTransportServiceCapabilities();
}
private native void initialize();
public Connection attach(String address, long attachTimeout, long handshakeTimeout) throws IOException {
throw new NullPointerException("address is null");
}
return conn;
}
address = defaultAddress();
}
}
return startListening(null);
}
if (!(listener instanceof SharedMemoryListenKey)) {
throw new IllegalArgumentException("Invalid listener");
}
long id;
synchronized (key) {
if (id == 0) {
throw new IllegalArgumentException("Invalid listener");
}
// invalidate the id
}
}
public Connection accept(ListenKey listener, long acceptTimeout, long handshakeTimeout) throws IOException {
if (!(listener instanceof SharedMemoryListenKey)) {
throw new IllegalArgumentException("Invalid listener");
}
long transportId;
synchronized (key) {
if (transportId == 0) {
throw new IllegalArgumentException("Invalid listener");
}
}
// in theory another thread could call stopListening before
// accept0 is called. In that case accept0 will try to accept
// with an invalid "transport id" - this should result in an
// IOException.
return conn;
}
}
private long id;
private boolean closed = false;
// handshake with the target VM
}
byte b = receiveByte0(id);
if (b != hello[i]) {
throw new IOException("handshake failed - unrecognized message from target VM");
}
}
}
}
public void close() {
synchronized (closeLock) {
if (!closed) {
closed = true;
}
}
}
public boolean isOpen() {
synchronized (closeLock) {
return !closed;
}
}
if (!isOpen()) {
throw new ClosedConnectionException("Connection closed");
}
byte b[];
try {
// only one thread may be reading at a time
synchronized (receiveLock) {
b = receivePacket0(id);
}
} catch (IOException ioe) {
if (!isOpen()) {
throw new ClosedConnectionException("Connection closed");
} else {
throw ioe;
}
}
return b;
}
if (!isOpen()) {
throw new ClosedConnectionException("Connection closed");
}
/*
* Check the packet size
*/
if (b.length < 11) {
throw new IllegalArgumentException("packet is insufficient size");
}
if (len < 11) {
throw new IllegalArgumentException("packet is insufficient size");
}
/*
* Check that the byte array contains the complete packet
*/
throw new IllegalArgumentException("length mis-match");
}
try {
// only one thread may be writing at a time
synchronized(sendLock) {
sendPacket0(id, b);
}
} catch (IOException ioe) {
if (!isOpen()) {
throw new ClosedConnectionException("Connection closed");
} else {
throw ioe;
}
}
}
}
public boolean supportsMultipleConnections() {
return false;
}
public boolean supportsAttachTimeout() {
return true;
}
public boolean supportsAcceptTimeout() {
return true;
}
public boolean supportsHandshakeTimeout() {
return false;
}
}