--- old/src/java.base/share/classes/sun/nio/ch/SelectionKeyImpl.java 2018-03-14 18:37:48.000000000 +0000 +++ new/src/java.base/share/classes/sun/nio/ch/SelectionKeyImpl.java 2018-03-14 18:37:48.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2018, 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,9 +25,11 @@ package sun.nio.ch; -import java.io.IOException; -import java.nio.channels.*; -import java.nio.channels.spi.*; +import java.nio.channels.CancelledKeyException; +import java.nio.channels.SelectableChannel; +import java.nio.channels.SelectionKey; +import java.nio.channels.Selector; +import java.nio.channels.spi.AbstractSelectionKey; /** @@ -45,7 +47,7 @@ private int index; private volatile int interestOps; - private int readyOps; + private volatile int readyOps; SelectionKeyImpl(SelChImpl ch, SelectorImpl sel) { channel = ch; @@ -111,4 +113,22 @@ return interestOps; } + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("channel=") + .append(channel) + .append(", selector=") + .append(selector); + if (isValid()) { + sb.append(", interestOps=") + .append(interestOps) + .append(", readyOps=") + .append(readyOps); + } else { + sb.append(", invalid"); + } + return sb.toString(); + } + }