本文整理汇总了Java中com.sun.squawk.NativeUnsafe.getUnalignedShort方法的典型用法代码示例。如果您正苦于以下问题:Java NativeUnsafe.getUnalignedShort方法的具体用法?Java NativeUnsafe.getUnalignedShort怎么用?Java NativeUnsafe.getUnalignedShort使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.squawk.NativeUnsafe
的用法示例。
在下文中一共展示了NativeUnsafe.getUnalignedShort方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getShort
import com.sun.squawk.NativeUnsafe; //导入方法依赖的package包/类
/**
* Gets the <code>short</code> at the given offset in the memory area
* associated with this object. If the short is aligned on a natural
* boundary it is always loaded from memory
* in a single atomic operation. If it is not on a natural boundary it may not be loaded atomically, and
* the number and order of the load operations is unspecified.
* <p>
* Caching of the memory access is controlled by the memory <code>type</code> requested
* when the <code>RawMemoryAccess</code> instance was created. If the memory is not cached,
* this method guarantees serialized access (that is, the memory access at the memory
* occurs in the same order as in the program. Multiple writes to the same location
* may not be coalesced.)
*
* @param offset The offset in bytes from the beginning of the raw memory area
* from which to load the short.
*
* @throws OffsetOutOfBoundsException Thrown if the offset is negative or greater than the size of the
* raw memory area. The role of the {@link SizeOutOfBoundsException} somewhat overlaps
* this exception since it is thrown if the offset is within the object but outside the
* mapped area. (See {@link RawMemoryAccess#map(long base, long size)}).
*
* @throws SizeOutOfBoundsException Thrown if the object is not mapped,
* or if the short falls in an invalid address range.
*
*
* @throws java.lang.SecurityException Thrown if this access is
* not permitted by the security manager.
* @return The short loaded from raw memory.
*/
public short getShort(long offset) {
int off = (int)offset;
checkRead(off, 2);
return (short) NativeUnsafe.getUnalignedShort(vbase, off);
}