Class Checks
- java.lang.Object
-
- org.lwjgl.system.Checks
-
public final class Checks extends java.lang.ObjectA class to check buffer boundaries in general. If there is insufficient space in the buffer when the call is made then a buffer overflow would otherwise occur and cause unexpected behaviour, a crash, or worse, a security risk.Internal class, don't use.
-
-
Field Summary
Fields Modifier and Type Field Description static booleanCHECKSRuntime checks flag.static booleanDEBUGDebug mode flag.static booleanDEBUG_FUNCTIONSDebug functions flag.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidcheck(byte[] buf, int size)Helper method to ensure a array has enough capacity.static voidcheck(double[] buf, int size)Helper method to ensure a array has enough capacity.static voidcheck(float[] buf, int size)Helper method to ensure a array has enough capacity.static voidcheck(int[] buf, int size)Helper method to ensure a array has enough capacity.static longcheck(int index, int length)static longcheck(long pointer)Ensures that the specified pointer is notNULL(0L).static voidcheck(long[] buf, int size)Helper method to ensure a array has enough capacity.static voidcheck(short[] buf, int size)Helper method to ensure a array has enough capacity.static voidcheck(java.lang.CharSequence text, int size)Helper method to ensure a CharSequence has enough characters.static voidcheck(java.lang.Object[] array, int size)static voidcheck(java.nio.Buffer buf, int size)Helper method to ensure a buffer has enough capacity.static voidcheck(java.nio.Buffer buf, long size)static voidcheck(CustomBuffer<?> buf, int size)Helper method to ensure aCustomBufferhas enough capacity.static voidcheck(CustomBuffer<?> buf, long size)static booleancheckFunctions(long... functions)Checks if any of the specified functions pointers isNULL.static voidcheckGT(java.nio.Buffer buf, int size)static voidcheckGT(CustomBuffer<?> buf, int size)static voidcheckNT(float[] buf)Ensures that the specified array is null-terminated.static voidcheckNT(int[] buf)Ensures that the specified array is null-terminated.static voidcheckNT(int[] buf, int terminator)Ensures that the specified array is terminated with the specified terminator.static voidcheckNT(long[] buf)Ensures that the specified array is null-terminated.static voidcheckNT(java.nio.FloatBuffer buf)Ensures that the specified FloatBuffer is null-terminated.static voidcheckNT(java.nio.IntBuffer buf)Ensures that the specified IntBuffer is null-terminated.static voidcheckNT(java.nio.IntBuffer buf, int terminator)Ensures that the specified IntBuffer is terminated with the specified terminator.static voidcheckNT(java.nio.LongBuffer buf)Ensures that the specified LongBuffer is null-terminated.static voidcheckNT(PointerBuffer buf)Ensures that the specified PointerBuffer is null-terminated.static voidcheckNT(PointerBuffer buf, long terminator)Ensures that the specified PointerBuffer is terminated with the specified terminator.static voidcheckNT1(java.nio.ByteBuffer buf)Ensures that the specified ByteBuffer is null-terminated (last byte equal to 0).static voidcheckNT1Safe(java.nio.ByteBuffer buf)static voidcheckNT2(java.nio.ByteBuffer buf)Ensures that the specified ByteBuffer is null-terminated (last 2 bytes equal to 0).static voidcheckNT2Safe(java.nio.ByteBuffer buf)static voidcheckNTSafe(float[] buf)static voidcheckNTSafe(int[] buf)static voidcheckNTSafe(int[] buf, int terminator)static voidcheckNTSafe(long[] buf)static voidcheckNTSafe(java.nio.FloatBuffer buf)static voidcheckNTSafe(java.nio.IntBuffer buf)static voidcheckNTSafe(java.nio.IntBuffer buf, int terminator)static voidcheckNTSafe(java.nio.LongBuffer buf)static voidcheckNTSafe(PointerBuffer buf)static voidcheckNTSafe(PointerBuffer buf, long terminator)static voidcheckSafe(double[] buf, int size)static voidcheckSafe(float[] buf, int size)static voidcheckSafe(int[] buf, int size)static voidcheckSafe(long[] buf, int size)static voidcheckSafe(short[] buf, int size)static voidcheckSafe(java.nio.Buffer buf, int size)static voidcheckSafe(java.nio.Buffer buf, long size)static voidcheckSafe(CustomBuffer<?> buf, int size)static voidcheckSafe(CustomBuffer<?> buf, long size)static intlengthSafe(double[] array)static intlengthSafe(float[] array)static intlengthSafe(int[] array)static intlengthSafe(long[] array)static intlengthSafe(short[] array)static intremainingSafe(java.nio.Buffer buffer)static intremainingSafe(CustomBuffer<?> buffer)
-
-
-
Field Detail
-
CHECKS
Runtime checks flag.When enabled, LWJGL will perform basic checks during its operation, mainly to avoid crashes in native code. Examples of such checks are: context-specific function address validation, buffer capacity checks, null-termination checks, etc. These checks are generally low-overhead and should not have a measurable effect on performance, so its recommended to have them enabled both during development and in production releases.
If maximum performance is required, they can be disabled by setting
Configuration.DISABLE_CHECKSto true.
-
DEBUG
Debug mode flag.When enabled, LWJGL will perform additional checks during its operation. These checks are more expensive than the ones enabled with
CHECKSand will have a noticeable effect on performance, so they are disabled by default. Examples of such checks are: buffer object binding state check (GL), buffer capacity checks for texture images (GL & CL), etc. LWJGL will also print additional information, mainly during start-up.Can be enabled by setting
Configuration.DEBUGto true.
-
DEBUG_FUNCTIONS
Debug functions flag.When enabled, capabilities classes will print an error message when they fail to retrieve a function pointer.
Can be enabled by setting
Configuration.DEBUG_FUNCTIONSto true.
-
-
Method Detail
-
lengthSafe
public static int lengthSafe(@Nullable short[] array)
-
lengthSafe
public static int lengthSafe(@Nullable int[] array)
-
lengthSafe
public static int lengthSafe(@Nullable long[] array)
-
lengthSafe
public static int lengthSafe(@Nullable float[] array)
-
lengthSafe
public static int lengthSafe(@Nullable double[] array)
-
remainingSafe
public static int remainingSafe(@Nullable java.nio.Buffer buffer)
-
remainingSafe
public static int remainingSafe(@Nullable CustomBuffer<?> buffer)
-
checkFunctions
public static boolean checkFunctions(long... functions)
Checks if any of the specified functions pointers isNULL.- Parameters:
functions- the function pointers to check- Returns:
- true if all function pointers are valid, false otherwise.
-
check
public static long check(long pointer)
Ensures that the specified pointer is notNULL(0L).- Parameters:
pointer- the pointer to check- Throws:
java.lang.NullPointerException- ifpointerisNULL
-
checkNT
public static void checkNT(int[] buf)
Ensures that the specified array is null-terminated.
-
checkNT
public static void checkNT(int[] buf, int terminator)Ensures that the specified array is terminated with the specified terminator.
-
checkNT
public static void checkNT(long[] buf) public static void checkNT(float[] buf)
Ensures that the specified array is null-terminated.
-
checkNT1
public static void checkNT1(java.nio.ByteBuffer buf)
Ensures that the specified ByteBuffer is null-terminated (last byte equal to 0).
-
checkNT2
public static void checkNT2(java.nio.ByteBuffer buf)
Ensures that the specified ByteBuffer is null-terminated (last 2 bytes equal to 0).
-
checkNT
public static void checkNT(java.nio.IntBuffer buf)
Ensures that the specified IntBuffer is null-terminated.
-
checkNT
public static void checkNT(java.nio.IntBuffer buf, int terminator)Ensures that the specified IntBuffer is terminated with the specified terminator.
-
checkNT
public static void checkNT(java.nio.LongBuffer buf)
Ensures that the specified LongBuffer is null-terminated.
-
checkNT
public static void checkNT(java.nio.FloatBuffer buf)
Ensures that the specified FloatBuffer is null-terminated.
-
checkNT
public static void checkNT(PointerBuffer buf)
Ensures that the specified PointerBuffer is null-terminated.
-
checkNT
public static void checkNT(PointerBuffer buf, long terminator)
Ensures that the specified PointerBuffer is terminated with the specified terminator.
-
checkNTSafe
public static void checkNTSafe(@Nullable int[] buf)
-
checkNTSafe
public static void checkNTSafe(@Nullable int[] buf, int terminator)
-
checkNTSafe
public static void checkNTSafe(@Nullable long[] buf)
-
checkNTSafe
public static void checkNTSafe(@Nullable float[] buf)
-
checkNT1Safe
public static void checkNT1Safe(@Nullable java.nio.ByteBuffer buf)
-
checkNT2Safe
public static void checkNT2Safe(@Nullable java.nio.ByteBuffer buf)
-
checkNTSafe
public static void checkNTSafe(@Nullable java.nio.IntBuffer buf)
-
checkNTSafe
public static void checkNTSafe(@Nullable java.nio.IntBuffer buf, int terminator)
-
checkNTSafe
public static void checkNTSafe(@Nullable java.nio.LongBuffer buf)
-
checkNTSafe
public static void checkNTSafe(@Nullable java.nio.FloatBuffer buf)
-
checkNTSafe
public static void checkNTSafe(@Nullable PointerBuffer buf)
-
checkNTSafe
public static void checkNTSafe(@Nullable PointerBuffer buf, long terminator)
-
check
public static void check(byte[] buf, int size) public static void check(short[] buf, int size) public static void check(int[] buf, int size) public static void check(long[] buf, int size) public static void check(float[] buf, int size) public static void check(double[] buf, int size)Helper method to ensure a array has enough capacity.- Parameters:
buf- the array to checksize- the minimum array capacity- Throws:
java.lang.IllegalArgumentException- ifbuf.length < size
-
check
public static void check(java.lang.CharSequence text, int size)Helper method to ensure a CharSequence has enough characters.- Parameters:
text- the text to checksize- the minimum number of characters- Throws:
java.lang.IllegalArgumentException- iftext.length() < size
-
check
public static void check(java.nio.Buffer buf, int size)Helper method to ensure a buffer has enough capacity.- Parameters:
buf- the buffer to checksize- the minimum buffer capacity- Throws:
java.lang.IllegalArgumentException- ifbuf.remaining() < size
-
check
public static void check(java.nio.Buffer buf, long size)- See Also:
check(Buffer, int)
-
check
public static void check(CustomBuffer<?> buf, int size)
Helper method to ensure aCustomBufferhas enough capacity.- Parameters:
buf- the buffer to checksize- the minimum buffer capacity- Throws:
java.lang.IllegalArgumentException- ifbuf.remaining() < size
-
check
public static void check(CustomBuffer<?> buf, long size)
- See Also:
check(CustomBuffer, int)
-
checkSafe
public static void checkSafe(@Nullable short[] buf, int size)
-
checkSafe
public static void checkSafe(@Nullable int[] buf, int size)
-
checkSafe
public static void checkSafe(@Nullable long[] buf, int size)
-
checkSafe
public static void checkSafe(@Nullable float[] buf, int size)
-
checkSafe
public static void checkSafe(@Nullable double[] buf, int size)
-
checkSafe
public static void checkSafe(@Nullable java.nio.Buffer buf, int size)
-
checkSafe
public static void checkSafe(@Nullable java.nio.Buffer buf, long size)
-
checkSafe
public static void checkSafe(@Nullable CustomBuffer<?> buf, int size)
-
checkSafe
public static void checkSafe(@Nullable CustomBuffer<?> buf, long size)
-
check
public static void check(java.lang.Object[] array, int size)
-
checkGT
public static void checkGT(java.nio.Buffer buf, int size)
-
checkGT
public static void checkGT(CustomBuffer<?> buf, int size)
-
check
public static long check(int index, int length)
-
-