< prev index next >

src/java.base/share/classes/jdk/internal/misc/Unsafe.java

Print this page
rev 47483 : [mq]: XXXXXXX-double-trouble-2


 555         Class<?> componentType = c.getComponentType();
 556         if (componentType == null || !componentType.isPrimitive()) {
 557             throw invalidInput();
 558         }
 559     }
 560 
 561     /**
 562      * Check that a pointer is a valid primitive array type pointer
 563      *
 564      * Note: pointers off-heap are considered to be primitive arrays
 565      *
 566      * @throws RuntimeException if the pointer is invalid
 567      *         (<em>Note:</em> after optimization, invalid inputs may
 568      *         go undetected, which will lead to unpredictable
 569      *         behavior)
 570      */
 571     private void checkPrimitivePointer(Object o, long offset) {
 572         checkPointer(o, offset);
 573 
 574         if (o != null) {
 575             // If on heap, it it must be a primitive array
 576             checkPrimitiveArray(o.getClass());
 577         }
 578     }
 579 
 580 
 581     /// wrappers for malloc, realloc, free:
 582 
 583     /**
 584      * Allocates a new block of native memory, of the given size in bytes.  The
 585      * contents of the memory are uninitialized; they will generally be
 586      * garbage.  The resulting native pointer will never be zero, and will be
 587      * aligned for all value types.  Dispose of this memory by calling {@link
 588      * #freeMemory}, or resize it with {@link #reallocateMemory}.
 589      *
 590      * <em>Note:</em> It is the resposibility of the caller to make
 591      * sure arguments are checked before the methods are called. While
 592      * some rudimentary checks are performed on the input, the checks
 593      * are best effort and when performance is an overriding priority,
 594      * as when methods of this class are optimized by the runtime
 595      * compiler, some or all checks (if any) may be elided. Hence, the




 555         Class<?> componentType = c.getComponentType();
 556         if (componentType == null || !componentType.isPrimitive()) {
 557             throw invalidInput();
 558         }
 559     }
 560 
 561     /**
 562      * Check that a pointer is a valid primitive array type pointer
 563      *
 564      * Note: pointers off-heap are considered to be primitive arrays
 565      *
 566      * @throws RuntimeException if the pointer is invalid
 567      *         (<em>Note:</em> after optimization, invalid inputs may
 568      *         go undetected, which will lead to unpredictable
 569      *         behavior)
 570      */
 571     private void checkPrimitivePointer(Object o, long offset) {
 572         checkPointer(o, offset);
 573 
 574         if (o != null) {
 575             // If on heap, it must be a primitive array
 576             checkPrimitiveArray(o.getClass());
 577         }
 578     }
 579 
 580 
 581     /// wrappers for malloc, realloc, free:
 582 
 583     /**
 584      * Allocates a new block of native memory, of the given size in bytes.  The
 585      * contents of the memory are uninitialized; they will generally be
 586      * garbage.  The resulting native pointer will never be zero, and will be
 587      * aligned for all value types.  Dispose of this memory by calling {@link
 588      * #freeMemory}, or resize it with {@link #reallocateMemory}.
 589      *
 590      * <em>Note:</em> It is the resposibility of the caller to make
 591      * sure arguments are checked before the methods are called. While
 592      * some rudimentary checks are performed on the input, the checks
 593      * are best effort and when performance is an overriding priority,
 594      * as when methods of this class are optimized by the runtime
 595      * compiler, some or all checks (if any) may be elided. Hence, the


< prev index next >