Top Description Fields Constructors Methods
org.lwjgl.system

public final Class Checks

extends Object
Class Inheritance
Imports
org.lwjgl.*, javax.annotation.*, java.nio.*

A 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.

See Also
Configuration#DISABLE_CHECKS, Configuration#DEBUG, Configuration#DEBUG_FUNCTIONS

Field Summary

Modifier and TypeField and Description
public static final boolean
CHECKS

Runtime checks flag.

public static final boolean
DEBUG

Debug mode flag.

public static final boolean
DEBUG_FUNCTIONS

Debug functions flag.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private static void
assertNT(boolean found)

public static long
check(long
the pointer to check
pointer
)

Ensures that the specified pointer is not NULL (0L).

public static void
check(byte[]
the array to check
buf
,
int
the minimum array capacity
size
)

Helper method to ensure a array has enough capacity.

public static void
check(short[]
the array to check
buf
,
int
the minimum array capacity
size
)

Helper method to ensure a array has enough capacity.

public static void
check(int[]
the array to check
buf
,
int
the minimum array capacity
size
)

Helper method to ensure a array has enough capacity.

public static void
check(long[]
the array to check
buf
,
int
the minimum array capacity
size
)

Helper method to ensure a array has enough capacity.

public static void
check(float[]
the array to check
buf
,
int
the minimum array capacity
size
)

Helper method to ensure a array has enough capacity.

public static void
check(double[]
the array to check
buf
,
int
the minimum array capacity
size
)

Helper method to ensure a array has enough capacity.

public static void
check(CharSequence
the text to check
text
,
int
the minimum number of characters
size
)

Helper method to ensure a CharSequence has enough characters.

public static void
check(Buffer
the buffer to check
buf
,
int
the minimum buffer capacity
size
)

Helper method to ensure a buffer has enough capacity.

public static void
check(Buffer buf, long size)

public static void
check(CustomBuffer<?>
the buffer to check
buf
,
int
the minimum buffer capacity
size
)

Helper method to ensure a CustomBuffer has enough capacity.

public static void
check(CustomBuffer<?> buf, long size)

public static void
check(Object[] array, int size)

public static long
check(int index, int length)

private static void
checkBuffer(int bufferSize, int minimumSize)

private static void
checkBufferGT(int bufferSize, int maximumSize)

public static boolean

Returns:

true if all function pointers are valid, false otherwise.
checkFunctions
(long...
the function pointers to check
functions
)

Checks if any of the specified functions pointers is NULL.

public static boolean

Returns:

true if all functions are available, false otherwise
checkFunctions
(FunctionProvider
the function address provider
provider
,
PointerBuffer
the function address buffer
caps
,
int[]
the function indices
indices
,
String...
the function names
functions
)

Checks if all functions are available in the function provider.

public static boolean

Returns:

true if all functions are available, false otherwise
checkFunctions
(FunctionProviderLocal
the function address provider
provider
,
long
the handle to a platform/device/context
handle
,
PointerBuffer
the function address buffer
caps
,
int[]
the function indices
indices
,
String...
the function names
functions
)

Checks if all functions are available in the function provider.

public static boolean

Returns:

true if all functions are available, false otherwise
checkFunctions
(FunctionProvider
the function address provider
provider
,
long[]
the function address buffer
caps
,
int[]
the function indices
indices
,
String...
the function names
functions
)

Checks if all functions are available in the function provider.

public static void
checkGT(Buffer buf, int size)

public static void
checkGT(CustomBuffer<?> buf, int size)

public static void
checkNT(int[] buf)

Ensures that the specified array is null-terminated.

public static void
checkNT(int[] buf, int terminator)

Ensures that the specified array is terminated with the specified terminator.

public static void
checkNT(long[] buf)

Ensures that the specified array is null-terminated.

public static void
checkNT(float[] buf)

Ensures that the specified array is null-terminated.

public static void
checkNT(IntBuffer buf)

Ensures that the specified IntBuffer is null-terminated.

public static void
checkNT(IntBuffer buf, int terminator)

Ensures that the specified IntBuffer is terminated with the specified terminator.

public static void
checkNT(LongBuffer buf)

Ensures that the specified LongBuffer is null-terminated.

public static void
checkNT(FloatBuffer buf)

Ensures that the specified FloatBuffer is null-terminated.

public static void
checkNT(PointerBuffer buf)

Ensures that the specified PointerBuffer is null-terminated.

public static void
checkNT(PointerBuffer buf, long terminator)

Ensures that the specified PointerBuffer is terminated with the specified terminator.

public static void
checkNT1(ByteBuffer buf)

Ensures that the specified ByteBuffer is null-terminated (last byte equal to 0).

public static void
public static void
checkNT2(ByteBuffer buf)

Ensures that the specified ByteBuffer is null-terminated (last 2 bytes equal to 0).

public static void
public static void
checkNTSafe(int[] buf)

public static void
checkNTSafe(int[] buf, int terminator)

public static void
checkNTSafe(long[] buf)

public static void
checkNTSafe(float[] buf)

public static void
public static void
checkNTSafe(IntBuffer buf, int terminator)

public static void
public static void
public static void
public static void
checkNTSafe(PointerBuffer buf, long terminator)

public static void
checkSafe(short[] buf, int size)

public static void
checkSafe(int[] buf, int size)

public static void
checkSafe(long[] buf, int size)

public static void
checkSafe(float[] buf, int size)

public static void
checkSafe(double[] buf, int size)

public static void
checkSafe(Buffer buf, int size)

public static void
checkSafe(Buffer buf, long size)

public static void
checkSafe(CustomBuffer<?> buf, int size)

public static void
checkSafe(CustomBuffer<?> buf, long size)

public static int
lengthSafe(short[] array)

public static int
lengthSafe(int[] array)

public static int
lengthSafe(long[] array)

public static int
lengthSafe(float[] array)

public static int
lengthSafe(double[] array)

public static int
public static int
public static boolean
reportMissing(String api, String extension)

private static void
throwIAE(int bufferSize, int minimumSize)

private static void
throwIAEGT(int bufferSize, int maximumSize)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

CHECKSback to summary
public static final boolean 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_CHECKS to true.

DEBUGback to summary
public static final boolean DEBUG

Debug mode flag.

When enabled, LWJGL will perform additional checks during its operation. These checks are more expensive than the ones enabled with CHECKS and 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#DEBUG to true.

DEBUG_FUNCTIONSback to summary
public static final boolean DEBUG_FUNCTIONS

Debug functions flag.

When enabled, a warning message will be output to the debug stream when LWJGL fails to retrieve a function pointer.

Can be enabled by setting Configuration#DEBUG_FUNCTIONS to true.

Constructor Detail

Checksback to summary
private Checks()

Method Detail

assertNTback to summary
private static void assertNT(boolean found)
checkback to summary
public static long check(long pointer)

Ensures that the specified pointer is not NULL (0L).

Parameters
pointer:long

the pointer to check

Exceptions
NullPointerException:
if pointer is NULL
checkback to summary
public static void check(byte[] buf, int size)

Helper method to ensure a array has enough capacity.

Parameters
buf:byte[]

the array to check

size:int

the minimum array capacity

Exceptions
IllegalArgumentException:
if buf.length < size
checkback to summary
public static void check(short[] buf, int size)

Helper method to ensure a array has enough capacity.

Parameters
buf:short[]

the array to check

size:int

the minimum array capacity

Exceptions
IllegalArgumentException:
if buf.length < size
checkback to summary
public static void check(int[] buf, int size)

Helper method to ensure a array has enough capacity.

Parameters
buf:int[]

the array to check

size:int

the minimum array capacity

Exceptions
IllegalArgumentException:
if buf.length < size
checkback to summary
public static void check(long[] buf, int size)

Helper method to ensure a array has enough capacity.

Parameters
buf:long[]

the array to check

size:int

the minimum array capacity

Exceptions
IllegalArgumentException:
if buf.length < size
checkback to summary
public static void check(float[] buf, int size)

Helper method to ensure a array has enough capacity.

Parameters
buf:float[]

the array to check

size:int

the minimum array capacity

Exceptions
IllegalArgumentException:
if buf.length < size
checkback to summary
public static void check(double[] buf, int size)

Helper method to ensure a array has enough capacity.

Parameters
buf:double[]

the array to check

size:int

the minimum array capacity

Exceptions
IllegalArgumentException:
if buf.length < size
checkback to summary
public static void check(CharSequence text, int size)

Helper method to ensure a CharSequence has enough characters.

Parameters
text:CharSequence

the text to check

size:int

the minimum number of characters

Exceptions
IllegalArgumentException:
if text.length() < size
checkback to summary
public static void check(Buffer buf, int size)

Helper method to ensure a buffer has enough capacity.

Parameters
buf:Buffer

the buffer to check

size:int

the minimum buffer capacity

Exceptions
IllegalArgumentException:
if buf.remaining() < size
checkback to summary
public static void check(Buffer buf, long size)
See Also
check(Buffer, int)
checkback to summary
public static void check(CustomBuffer<?> buf, int size)

Helper method to ensure a CustomBuffer has enough capacity.

Parameters
buf:CustomBuffer<?>

the buffer to check

size:int

the minimum buffer capacity

Exceptions
IllegalArgumentException:
if buf.remaining() < size
checkback to summary
public static void check(CustomBuffer<?> buf, long size)
See Also
check(CustomBuffer, int)
checkback to summary
public static void check(Object[] array, int size)
checkback to summary
public static long check(int index, int length)
checkBufferback to summary
private static void checkBuffer(int bufferSize, int minimumSize)
checkBufferGTback to summary
private static void checkBufferGT(int bufferSize, int maximumSize)
checkFunctionsback to summary
public static boolean checkFunctions(long... functions)

Checks if any of the specified functions pointers is NULL.

Parameters
functions:long[]

the function pointers to check

Returns:boolean

true if all function pointers are valid, false otherwise.

checkFunctionsback to summary
public static boolean checkFunctions(FunctionProvider provider, PointerBuffer caps, int[] indices, String... functions)

Checks if all functions are available in the function provider.

Parameters
provider:FunctionProvider

the function address provider

caps:PointerBuffer

the function address buffer

indices:int[]

the function indices

functions:String[]

the function names

Returns:boolean

true if all functions are available, false otherwise

checkFunctionsback to summary
public static boolean checkFunctions(FunctionProviderLocal provider, long handle, PointerBuffer caps, int[] indices, String... functions)

Checks if all functions are available in the function provider.

Parameters
provider:FunctionProviderLocal

the function address provider

handle:long

the handle to a platform/device/context

caps:PointerBuffer

the function address buffer

indices:int[]

the function indices

functions:String[]

the function names

Returns:boolean

true if all functions are available, false otherwise

checkFunctionsback to summary
public static boolean checkFunctions(FunctionProvider provider, long[] caps, int[] indices, String... functions)

Checks if all functions are available in the function provider.

Parameters
provider:FunctionProvider

the function address provider

caps:long[]

the function address buffer

indices:int[]

the function indices

functions:String[]

the function names

Returns:boolean

true if all functions are available, false otherwise

checkGTback to summary
public static void checkGT(Buffer buf, int size)
checkGTback to summary
public static void checkGT(CustomBuffer<?> buf, int size)
checkNTback to summary
public static void checkNT(int[] buf)

Ensures that the specified array is null-terminated.

checkNTback to summary
public static void checkNT(int[] buf, int terminator)

Ensures that the specified array is terminated with the specified terminator.

checkNTback to summary
public static void checkNT(long[] buf)

Ensures that the specified array is null-terminated.

checkNTback to summary
public static void checkNT(float[] buf)

Ensures that the specified array is null-terminated.

checkNTback to summary
public static void checkNT(IntBuffer buf)

Ensures that the specified IntBuffer is null-terminated.

checkNTback to summary
public static void checkNT(IntBuffer buf, int terminator)

Ensures that the specified IntBuffer is terminated with the specified terminator.

checkNTback to summary
public static void checkNT(LongBuffer buf)

Ensures that the specified LongBuffer is null-terminated.

checkNTback to summary
public static void checkNT(FloatBuffer buf)

Ensures that the specified FloatBuffer is null-terminated.

checkNTback to summary
public static void checkNT(PointerBuffer buf)

Ensures that the specified PointerBuffer is null-terminated.

checkNTback to summary
public static void checkNT(PointerBuffer buf, long terminator)

Ensures that the specified PointerBuffer is terminated with the specified terminator.

checkNT1back to summary
public static void checkNT1(ByteBuffer buf)

Ensures that the specified ByteBuffer is null-terminated (last byte equal to 0).

checkNT1Safeback to summary
public static void checkNT1Safe(ByteBuffer buf)
checkNT2back to summary
public static void checkNT2(ByteBuffer buf)

Ensures that the specified ByteBuffer is null-terminated (last 2 bytes equal to 0).

checkNT2Safeback to summary
public static void checkNT2Safe(ByteBuffer buf)
checkNTSafeback to summary
public static void checkNTSafe(int[] buf)
checkNTSafeback to summary
public static void checkNTSafe(int[] buf, int terminator)
checkNTSafeback to summary
public static void checkNTSafe(long[] buf)
checkNTSafeback to summary
public static void checkNTSafe(float[] buf)
checkNTSafeback to summary
public static void checkNTSafe(IntBuffer buf)
checkNTSafeback to summary
public static void checkNTSafe(IntBuffer buf, int terminator)
checkNTSafeback to summary
public static void checkNTSafe(LongBuffer buf)
checkNTSafeback to summary
public static void checkNTSafe(FloatBuffer buf)
checkNTSafeback to summary
public static void checkNTSafe(PointerBuffer buf)
checkNTSafeback to summary
public static void checkNTSafe(PointerBuffer buf, long terminator)
checkSafeback to summary
public static void checkSafe(short[] buf, int size)
checkSafeback to summary
public static void checkSafe(int[] buf, int size)
checkSafeback to summary
public static void checkSafe(long[] buf, int size)
checkSafeback to summary
public static void checkSafe(float[] buf, int size)
checkSafeback to summary
public static void checkSafe(double[] buf, int size)
checkSafeback to summary
public static void checkSafe(Buffer buf, int size)
checkSafeback to summary
public static void checkSafe(Buffer buf, long size)
checkSafeback to summary
public static void checkSafe(CustomBuffer<?> buf, int size)
checkSafeback to summary
public static void checkSafe(CustomBuffer<?> buf, long size)
lengthSafeback to summary
public static int lengthSafe(short[] array)
lengthSafeback to summary
public static int lengthSafe(int[] array)
lengthSafeback to summary
public static int lengthSafe(long[] array)
lengthSafeback to summary
public static int lengthSafe(float[] array)
lengthSafeback to summary
public static int lengthSafe(double[] array)
remainingSafeback to summary
public static int remainingSafe(Buffer buffer)
remainingSafeback to summary
public static int remainingSafe(CustomBuffer<?> buffer)
reportMissingback to summary
public static boolean reportMissing(String api, String extension)
throwIAEback to summary
private static void throwIAE(int bufferSize, int minimumSize)
throwIAEGTback to summary
private static void throwIAEGT(int bufferSize, int maximumSize)