1 /* |
1 /* |
2 * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
24 */ |
24 */ |
25 |
25 |
26 package jdk.internal.misc; |
26 package jdk.internal.misc; |
27 |
27 |
28 import jdk.internal.HotSpotIntrinsicCandidate; |
28 import jdk.internal.HotSpotIntrinsicCandidate; |
|
29 import jdk.internal.ref.Cleaner; |
29 import jdk.internal.vm.annotation.ForceInline; |
30 import jdk.internal.vm.annotation.ForceInline; |
|
31 import sun.nio.ch.DirectBuffer; |
30 |
32 |
31 import java.lang.reflect.Field; |
33 import java.lang.reflect.Field; |
32 import java.security.ProtectionDomain; |
34 import java.security.ProtectionDomain; |
33 |
35 |
34 |
36 |
3716 private native int getLoadAverage0(double[] loadavg, int nelems); |
3718 private native int getLoadAverage0(double[] loadavg, int nelems); |
3717 private native boolean unalignedAccess0(); |
3719 private native boolean unalignedAccess0(); |
3718 private native boolean isBigEndian0(); |
3720 private native boolean isBigEndian0(); |
3719 |
3721 |
3720 |
3722 |
|
3723 /** |
|
3724 * Invokes the given direct byte buffer's cleaner, if any. |
|
3725 * |
|
3726 * @param directBuffer a direct byte buffer |
|
3727 * @throws NullPointerException if {@code directBuffer} is null |
|
3728 * @throws IllegalArgumentException if {@code directBuffer} is non-direct, |
|
3729 * or is a {@link java.nio.Buffer#slice slice}, or is a |
|
3730 * {@link java.nio.Buffer#duplicate duplicate} |
|
3731 */ |
|
3732 public void invokeCleaner(java.nio.ByteBuffer directBuffer) { |
|
3733 if (!directBuffer.isDirect()) |
|
3734 throw new IllegalArgumentException("buffer is non-direct"); |
|
3735 |
|
3736 DirectBuffer db = (DirectBuffer) directBuffer; |
|
3737 if (db.attachment() != null) |
|
3738 throw new IllegalArgumentException("duplicate or slice"); |
|
3739 |
|
3740 Cleaner cleaner = db.cleaner(); |
|
3741 if (cleaner != null) { |
|
3742 cleaner.clean(); |
|
3743 } |
|
3744 } |
|
3745 |
3721 // The following deprecated methods are used by JSR 166. |
3746 // The following deprecated methods are used by JSR 166. |
3722 |
3747 |
3723 @Deprecated(since="12", forRemoval=true) |
3748 @Deprecated(since="12", forRemoval=true) |
3724 public final Object getObject(Object o, long offset) { |
3749 public final Object getObject(Object o, long offset) { |
3725 return getReference(o, offset); |
3750 return getReference(o, offset); |