Class PlatformInternals
- java.lang.Object
-
- one.microstream.memory.PlatformInternals
-
public class PlatformInternals extends Object
This class provides static utility functionality to access certain required access to internal JDK logic without using JDK-version-specific dependencies. E.g. JDK-internal classes in the "sun.*" package were moved to the "jdk.*" package but access to those is required to compensate for certain shortcomings in the JDK's public API.This class does the magic trick of allowing JDK-specific access without having JDK-specific dependencies in the source code. Congratulations and felicitation always welcomed.
In more general terms, this class abstracts platform-version-specific details.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfacePlatformInternals.Warning
-
Constructor Summary
Constructors Constructor Description PlatformInternals()
-
Method Summary
Modifier and Type Method Description static voiddeallocateDirectBuffer(ByteBuffer directBuffer)No idea if this method is really (still?) necesssary, but it sounds reasonable.static byte[]directBufferToArray(ByteBuffer directBuffer)static ByteBufferensureDirectBufferCapacity(ByteBuffer current, long capacity)static Class<?>getClassCleaner()static Class<?>getClassDirectbuffer()static longgetDirectBufferAddress(ByteBuffer directBuffer)static DirectBufferAddressGettergetDirectBufferAddressGetter()static DirectBufferDeallocatorgetDirectBufferDeallocator()static StringgetResolvingStatus()static <DB extends ByteBuffer>
DBguaranteeDirectBuffer(DB directBuffer)static voidguaranteeUsability()Guarantees the usability of this class by validating if all functionality is usable.static XGettingSequence<PlatformInternals.Warning>initializationWarnings()static booleanisDirectBuffer(ByteBuffer directBuffer)Just to have all jdk internal types here at one place.static voidprintInitializationWarnings(PrintStream printStream)static voidsetDirectBufferAddressGetter(DirectBufferAddressGetter addressGetter)Allows to set theDirectBufferAddressGetterused bygetDirectBufferAddress(ByteBuffer)as an override to the means this class inherently tries to provide.
SeeDirectBufferAddressGetterfor details.static voidsetDirectBufferDeallocator(DirectBufferDeallocator deallocator)Allows to set theDirectBufferDeallocatorused bydeallocateDirectBuffer(ByteBuffer)as an override to the means this class inherently tries to provide.
SeeDirectBufferDeallocatorfor details.
-
-
-
Method Detail
-
setDirectBufferDeallocator
public static void setDirectBufferDeallocator(DirectBufferDeallocator deallocator)
Allows to set theDirectBufferDeallocatorused bydeallocateDirectBuffer(ByteBuffer)as an override to the means this class inherently tries to provide.
SeeDirectBufferDeallocatorfor details.The passed instance "should" be immutable or better stateless to ensure concurrency-safe usage, but ultimately, the responsibility resides with the author of the instance's implementation.
Passing a null resets the behavior of
deallocateDirectBuffer(ByteBuffer)to the inherent logic.- Parameters:
deallocator- the deallocator to be used, potentially null.- See Also:
DirectBufferDeallocator
-
getDirectBufferDeallocator
public static DirectBufferDeallocator getDirectBufferDeallocator()
-
setDirectBufferAddressGetter
public static void setDirectBufferAddressGetter(DirectBufferAddressGetter addressGetter)
Allows to set theDirectBufferAddressGetterused bygetDirectBufferAddress(ByteBuffer)as an override to the means this class inherently tries to provide.
SeeDirectBufferAddressGetterfor details.The passed instance "should" be immutable or better stateless to ensure concurrency-safe usage, but ultimately, the responsibility resides with the author of the instance's implementation.
Passing a null resets the behavior of
getDirectBufferAddress(ByteBuffer)to the inherent logic.- Parameters:
addressGetter- the addressGetter to be used, potentially null.- See Also:
DirectBufferDeallocator
-
getDirectBufferAddressGetter
public static DirectBufferAddressGetter getDirectBufferAddressGetter()
-
getClassDirectbuffer
public static Class<?> getClassDirectbuffer()
-
getClassCleaner
public static Class<?> getClassCleaner()
-
guaranteeUsability
public static void guaranteeUsability()
Guarantees the usability of this class by validating if all functionality is usable. This does not necessarily mean that all attempts to resolve JDK-internal code structures were successful. Some have alternative options that are used as a fallback.- Throws:
Error
-
isDirectBuffer
public static final boolean isDirectBuffer(ByteBuffer directBuffer)
Just to have all jdk internal types here at one place.- Parameters:
directBuffer-
-
guaranteeDirectBuffer
public static final <DB extends ByteBuffer> DB guaranteeDirectBuffer(DB directBuffer)
-
ensureDirectBufferCapacity
public static final ByteBuffer ensureDirectBufferCapacity(ByteBuffer current, long capacity)
-
deallocateDirectBuffer
public static final void deallocateDirectBuffer(ByteBuffer directBuffer)
No idea if this method is really (still?) necesssary, but it sounds reasonable. See http://stackoverflow.com/questions/8462200/examples-of-forcing-freeing-of-native-memory-direct-bytebuffer-has-allocated-us- Parameters:
directBuffer-
-
getDirectBufferAddress
public static final long getDirectBufferAddress(ByteBuffer directBuffer)
-
directBufferToArray
public static final byte[] directBufferToArray(ByteBuffer directBuffer)
-
getResolvingStatus
public static final String getResolvingStatus()
-
initializationWarnings
public static final XGettingSequence<PlatformInternals.Warning> initializationWarnings()
-
printInitializationWarnings
public static final void printInitializationWarnings(PrintStream printStream)
-
-