8207235: ManagementFactory.getPlatformMXBeans(BufferPoolMXBean.class) throws NPE

Reviewed-by: alanb
This commit is contained in:
Claes Redestad 2018-07-13 18:39:11 +02:00
parent 8afac1c9da
commit 173732afaa
3 changed files with 41 additions and 40 deletions

View file

@ -26,6 +26,8 @@
package java.nio;
import jdk.internal.HotSpotIntrinsicCandidate;
import jdk.internal.misc.JavaNioAccess;
import jdk.internal.misc.SharedSecrets;
import jdk.internal.misc.Unsafe;
import java.util.Spliterator;
@ -707,4 +709,23 @@ public abstract class Buffer {
throw new IndexOutOfBoundsException();
}
static {
// setup access to this package in SharedSecrets
SharedSecrets.setJavaNioAccess(
new JavaNioAccess() {
@Override
public JavaNioAccess.BufferPool getDirectBufferPool() {
return Bits.BUFFER_POOL;
}
@Override
public ByteBuffer newDirectByteBuffer(long addr, int cap, Object ob) {
return new DirectByteBuffer(addr, cap, ob);
}
@Override
public void truncate(Buffer buf) {
buf.truncate();
}
});
}
}