Package org.apache.uima.internal.util
Class Misc
- java.lang.Object
-
- org.apache.uima.internal.util.Misc
-
public class Misc extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.Stringblanksprivate static intC1private static intC2static java.lang.Stringdotsstatic int[]INT0static booleanisJava9eaprivate static java.io.FilenameFilterjarFilterstatic intnumberOfCoresFor multi-core machine "tuning" - the number of coresprivate static intseedstatic java.lang.invoke.MethodHandles.LookupUIMAlookupprivate static java.util.regex.Patternwhitespace
-
Constructor Summary
Constructors Constructor Description Misc()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidaddAll(java.util.Collection<java.lang.String> c, java.lang.String... v)Takes trailing arguments of strings and adds them all the firststatic <T> java.lang.StringBuilderaddElementsToStringBuilder(int[] indent, java.lang.StringBuilder sb, java.util.Collection<T> c, int limit, java.util.function.BiConsumer<java.lang.StringBuilder,T> appender)static <T> java.lang.StringBuilderaddElementsToStringBuilder(int[] indent, java.util.List<T> c, int limit, java.util.function.BiConsumer<java.lang.StringBuilder,T> appender)static java.lang.StringBuilderaddElementsToStringBuilder(java.lang.StringBuilder sb, int size, int limit, int indent, int incr, java.util.function.BiConsumer<java.lang.StringBuilder,java.lang.Integer> appender)static <T> java.lang.StringBuilderaddElementsToStringBuilder(java.lang.StringBuilder sb, java.util.Collection<T> c)For standardized prettyprinting, to string.static <T> java.lang.StringBuilderaddElementsToStringBuilder(java.lang.StringBuilder sb, java.util.Collection<T> c, int limit)static <T> java.lang.StringBuilderaddElementsToStringBuilder(java.lang.StringBuilder sb, java.util.Collection<T> c, int limit, java.util.function.BiConsumer<java.lang.StringBuilder,T> appender)Does two styles of list formatting: Style 1: [ item1, item 2, item3] Style 2: [ item1, item2, item3 ] Starts as style 1, switches to style 2 when length > 60static <T> java.lang.StringBuilderaddElementsToStringBuilder(java.lang.StringBuilder sb, java.util.Collection<T> c, java.util.function.BiConsumer<java.lang.StringBuilder,T> appender)static <T> java.lang.StringBuilderaddElementsToStringBuilder(java.util.List<T> c, int limit)static <T> java.lang.StringBuilderaddElementsToStringBuilder(java.util.List<T> c, int limit, java.util.function.BiConsumer<java.lang.StringBuilder,T> appender)static voidaddNlIfMissing(java.lang.StringBuffer sb)static voidaddNlIfMissing(java.lang.StringBuilder sb)private static voidaddPathToURLs(java.util.List<java.net.URL> urls, java.io.File cp)static voidaddUrlsFromPath(java.lang.String p, java.util.List<java.net.URL> urls)Given a String corresponding to one file path, which may be a directory, or may end in *, add the URLS it represents to the urls argument.static voidassertUie(boolean v)Check and throw UIMA Internal Error if falsestatic voidassertUie(boolean v, java.lang.Throwable e)static java.lang.StringclassNameFromByteCode(byte[] bytes)extract the slashified version of the fully qualified class name from the bytecode for a classstatic java.net.URL[]classpath2urls(java.lang.String classpath)Convert a classpath having multiple parts separated by the pathSeparator, expanding paths that end with "*" as needed.static intcompareStrings(java.lang.String s1, java.lang.String s2)static booleancontains(java.lang.ClassLoader[] cls, java.lang.ClassLoader cl)static booleancontains(java.lang.String[] strings, java.lang.String item)static voiddebug(java.lang.Object o)static voiddecreasingMessage(java.util.concurrent.atomic.AtomicInteger errorCount, java.util.function.Supplier<java.lang.String> messageSupplier, java.util.function.Consumer<java.lang.String> publishMessage)static voiddecreasingWithTrace(java.util.concurrent.atomic.AtomicInteger errorCount, java.lang.String message, Logger logger)Issues message at warning or fine level (fine if enabled, includes stack trace)static java.lang.StringdumpByteArray(byte[] b, int limit)static java.lang.StringBuilderdumpCallers(java.lang.StackTraceElement[] e, int s, int n)static java.lang.Stringelide(java.lang.String s, int n)static java.lang.Stringelide(java.lang.String s, int n, boolean pad)static java.lang.StringelideString(java.lang.String s, int len)private static booleanendsWithNl(java.lang.StringBuffer sb)private static booleanendsWithNl(java.lang.StringBuilder sb)static booleanequalStrings(java.lang.String s1, java.lang.String s2)static java.lang.StringexpandClasspath(java.lang.String classpath)private static java.lang.Stringformatcaller(java.lang.StackTraceElement e)static java.lang.Stringformatcaller(java.lang.String className, java.lang.String methodName, int lineNumber)static java.lang.StringgetCaller()static java.lang.StringBuildergetCallers(int s, int n)static java.lang.ClassLoader[]getCallingClass_classLoaders()static booleangetNoValueSystemProperty(java.lang.String name)static intgetPrivateStaticIntFieldNoInherit(java.lang.Class<?> clazz, java.lang.String fieldName)static java.lang.invoke.MethodHandlegetProtectedFieldGetter(java.lang.Class<?> clazz, java.lang.String protectedField)static java.lang.invoke.MethodHandlegetProtectedMethodHandle(java.lang.Class<?> clazz, java.lang.invoke.MethodHandles.Lookup methodHandleAccessContext, java.lang.String protectedMethod, java.lang.Class<?>... args)Given a class, a lookup context, and a protected method and its arg classes, return the method handle for that method.static java.lang.invoke.MethodHandlegetProtectedMethodHandle(java.lang.Class<?> clazz, java.lang.String protectedMethod, java.lang.Class<?>... args)Given a class, and a protected method and its arg classes, return the method handle for that method.static intgetStaticIntField(java.lang.Class<?> clazz, java.lang.String fieldName)Gets an int from a named field.static intgetStaticIntFieldNoInherit(java.lang.Class<?> clazz, java.lang.String fieldName)static java.net.URL[]getURLs(java.lang.String s)static <T> TgetWithExpand(java.util.List<T> a, int i)Get item from array list.static inthashInt(int k1)static longhashStringLong(java.lang.String s)a hash for strings as a long - less likely to be a collisionstatic byte[]hex_string_to_bytearray(java.lang.String s)static java.lang.StringBuilderindent(java.lang.StringBuilder sb, int indent)static java.lang.StringBuilderindent(java.lang.StringBuilder sb, int[] indent)static java.lang.RuntimeExceptioninternalError()static voidinternalError(java.lang.Throwable e)static booleanisJava9ea()static java.lang.StringjavaClassName2UimaTypeName(java.lang.String className)Convert a JCas class name (fully qualified) to a UIMA type name Normally this is the same, but for two prefixes, it's slightly different Also, class names for primitives (int, byte, etc.static booleanmaybeShrink(boolean secondTimeShrinkable, int size, int capacity, int factor, int minCapacity, java.util.function.IntConsumer realloc, java.lang.Runnable reset)static intnextHigherPowerOf2(int i)Convert an int argument to the next higher power of 2 if not already a power of 2static intnextHigherPowerOfX(int i, int x)Convert an int argument to the next higher power of 2 to the x powerstatic java.lang.Stringnull2str(java.lang.String s)static <T> java.lang.StringppList(int[] indent, java.util.List<T> items)format a list of items for pretty printing as [item1, item2, ...static <T> java.lang.StringppList(int[] indent, java.util.List<T> items, int max)static <T> java.lang.StringppList(int[] indent, java.util.List<T> items, int max, java.util.function.BiConsumer<java.lang.StringBuilder,T> appender)static <T> java.lang.StringppList(java.util.List<T> items)format a list of items for pretty printing as [item1, item2, ...static <T> java.lang.StringppList(java.util.List<T> items, int max)static <T> java.lang.StringppList(java.util.List<T> items, int max, java.util.function.BiConsumer<java.lang.StringBuilder,T> appender)private static java.lang.StringreadModifiedUTF8(java.nio.ByteBuffer bb)read ByteBuffer modified UTF into String see http://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.4static java.lang.StringreplaceWhiteSpace(java.lang.String s, java.lang.String replacement)static <T> java.util.List<T>setAsList(java.util.Set<T> set)static <T> voidsetWithExpand(java.util.List<T> a, int i, T value)static <T> TshareExisting(T obj, java.util.WeakHashMap<T,java.lang.ref.WeakReference<T>> cache)Some objects can be shared, if "equal", rather than creating duplicates, if they're read-only.static voidsleep(int milliseconds)private static <T> java.lang.StringBuilderstyle2(int[] indent, java.lang.StringBuilder sb, java.util.Collection<T> c, int limit, java.util.function.BiConsumer<java.lang.StringBuilder,T> appender)private static <T> java.lang.StringBuilderstyle2(java.lang.StringBuilder sb, int size, int limit, int indent, int incr, java.util.function.BiConsumer<java.lang.StringBuilder,java.lang.Integer> appender)static voidtimeLoops(java.lang.String title, int iterations, Runnable_withException r)static voidtoFile(java.io.ByteArrayOutputStream baos, java.io.File file)Writes a byte array output stream to a filestatic voidtoFile(java.io.ByteArrayOutputStream baos, java.lang.String name)Writes a byte array output stream to a filestatic java.lang.StringtypeName2ClassName(java.lang.String typeName)Convert a UIMA type name to a JCas class name (fully qualified) Normally this is the same, but for two prefixes, it's slightly different
-
-
-
Field Detail
-
isJava9ea
public static final boolean isJava9ea
-
blanks
public static final java.lang.String blanks
-
dots
public static final java.lang.String dots
- See Also:
- Constant Field Values
-
INT0
public static final int[] INT0
-
whitespace
private static final java.util.regex.Pattern whitespace
-
UIMAlookup
public static final java.lang.invoke.MethodHandles.Lookup UIMAlookup
-
jarFilter
private static java.io.FilenameFilter jarFilter
-
numberOfCores
public static final int numberOfCores
For multi-core machine "tuning" - the number of cores
-
C1
private static final int C1
- See Also:
- Constant Field Values
-
C2
private static final int C2
- See Also:
- Constant Field Values
-
seed
private static final int seed
- See Also:
- Constant Field Values
-
-
Method Detail
-
replaceWhiteSpace
public static java.lang.String replaceWhiteSpace(java.lang.String s, java.lang.String replacement)
-
null2str
public static java.lang.String null2str(java.lang.String s)
-
hex_string_to_bytearray
public static byte[] hex_string_to_bytearray(java.lang.String s)
-
dumpByteArray
public static java.lang.String dumpByteArray(byte[] b, int limit)
-
getCallers
public static java.lang.StringBuilder getCallers(int s, int n)- Parameters:
s- starting frames above invokern- max number of callers to return- Returns:
- x called by: y ...
-
dumpCallers
public static java.lang.StringBuilder dumpCallers(java.lang.StackTraceElement[] e, int s, int n)
-
getCaller
public static java.lang.String getCaller()
- Returns:
- the name of the caller in the stack and their caller
-
formatcaller
private static java.lang.String formatcaller(java.lang.StackTraceElement e)
-
formatcaller
public static java.lang.String formatcaller(java.lang.String className, java.lang.String methodName, int lineNumber)
-
getCallingClass_classLoaders
public static java.lang.ClassLoader[] getCallingClass_classLoaders()
-
elide
public static java.lang.String elide(java.lang.String s, int n)- Parameters:
s- the string to possibly eliden- the length, after which, elision happens- Returns:
- the elided string, padded on the left to length n
-
elide
public static java.lang.String elide(java.lang.String s, int n, boolean pad)- Parameters:
s- the string to possibly eliden- the length, after which, elision happenspad- true to include left padding to length n- Returns:
- the elided string, padded on the left to length n
-
indent
public static java.lang.StringBuilder indent(java.lang.StringBuilder sb, int[] indent)- Parameters:
sb- the stringBuilder to indentindent- the indent amount (passed as array of 1 item, to allow it to be final for lambdas- Returns:
- the stringBuilder, with nl if needed, and indention
-
indent
public static java.lang.StringBuilder indent(java.lang.StringBuilder sb, int indent)- Parameters:
sb- the stringBuilder to indentindent- the indent amount- Returns:
- the stringBuilder, with nl if needed, and indention
-
addNlIfMissing
public static void addNlIfMissing(java.lang.StringBuilder sb)
-
addNlIfMissing
public static void addNlIfMissing(java.lang.StringBuffer sb)
-
endsWithNl
private static boolean endsWithNl(java.lang.StringBuilder sb)
-
endsWithNl
private static boolean endsWithNl(java.lang.StringBuffer sb)
-
getURLs
public static java.net.URL[] getURLs(java.lang.String s) throws java.net.MalformedURLException, java.io.IOException, java.net.URISyntaxException- Throws:
java.net.MalformedURLExceptionjava.io.IOExceptionjava.net.URISyntaxException
-
addUrlsFromPath
public static void addUrlsFromPath(java.lang.String p, java.util.List<java.net.URL> urls) throws java.net.MalformedURLException, java.io.IOException, java.net.URISyntaxExceptionGiven a String corresponding to one file path, which may be a directory, or may end in *, add the URLS it represents to the urls argument.- Parameters:
p- a Jar path, or a Directory, or a directory ending with a directory-separator and a single * p may be relative or absolute, following the definition of same in the Java File class.urls- the list to add the URLs to- Throws:
java.net.MalformedURLException- -java.io.IOException- -java.net.URISyntaxException- -
-
addPathToURLs
private static void addPathToURLs(java.util.List<java.net.URL> urls, java.io.File cp) throws java.net.MalformedURLException- Throws:
java.net.MalformedURLException
-
classpath2urls
public static java.net.URL[] classpath2urls(java.lang.String classpath)
Convert a classpath having multiple parts separated by the pathSeparator, expanding paths that end with "*" as needed.- Parameters:
classpath- - to scan and convert to list of URLs- Returns:
- the urls
-
expandClasspath
public static java.lang.String expandClasspath(java.lang.String classpath)
-
getNoValueSystemProperty
public static boolean getNoValueSystemProperty(java.lang.String name)
- Parameters:
name- of property- Returns:
- true if property is defined, or is defined and set to anything except "false"; false if property is not defined, or is defined and set to "false".
-
addElementsToStringBuilder
public static <T> java.lang.StringBuilder addElementsToStringBuilder(java.lang.StringBuilder sb, java.util.Collection<T> c)For standardized prettyprinting, to string. Adds a collection of things (toString) separated by , and surrounded by [ ], to a StringBuilder- Type Parameters:
T- the kind of elements in the collection- Parameters:
sb- where the formatted collection results are appended toc- the collection- Returns:
- the StringBuilder for chaining
-
addElementsToStringBuilder
public static <T> java.lang.StringBuilder addElementsToStringBuilder(java.lang.StringBuilder sb, java.util.Collection<T> c, int limit)
-
addElementsToStringBuilder
public static <T> java.lang.StringBuilder addElementsToStringBuilder(java.lang.StringBuilder sb, java.util.Collection<T> c, java.util.function.BiConsumer<java.lang.StringBuilder,T> appender)
-
addElementsToStringBuilder
public static <T> java.lang.StringBuilder addElementsToStringBuilder(java.util.List<T> c, int limit)
-
addElementsToStringBuilder
public static <T> java.lang.StringBuilder addElementsToStringBuilder(java.util.List<T> c, int limit, java.util.function.BiConsumer<java.lang.StringBuilder,T> appender)
-
addElementsToStringBuilder
public static <T> java.lang.StringBuilder addElementsToStringBuilder(int[] indent, java.util.List<T> c, int limit, java.util.function.BiConsumer<java.lang.StringBuilder,T> appender)
-
addElementsToStringBuilder
public static <T> java.lang.StringBuilder addElementsToStringBuilder(java.lang.StringBuilder sb, java.util.Collection<T> c, int limit, java.util.function.BiConsumer<java.lang.StringBuilder,T> appender)Does two styles of list formatting: Style 1: [ item1, item 2, item3] Style 2: [ item1, item2, item3 ] Starts as style 1, switches to style 2 when length > 60- Type Parameters:
T- the type of the collection- Parameters:
sb- where the string is assembledc- the collection to processlimit- the maximum number of items, if negative, no limitappender- the appender- Returns:
- argument sb, appeneded
-
addElementsToStringBuilder
public static <T> java.lang.StringBuilder addElementsToStringBuilder(int[] indent, java.lang.StringBuilder sb, java.util.Collection<T> c, int limit, java.util.function.BiConsumer<java.lang.StringBuilder,T> appender)
-
addElementsToStringBuilder
public static java.lang.StringBuilder addElementsToStringBuilder(java.lang.StringBuilder sb, int size, int limit, int indent, int incr, java.util.function.BiConsumer<java.lang.StringBuilder,java.lang.Integer> appender)
-
style2
private static <T> java.lang.StringBuilder style2(int[] indent, java.lang.StringBuilder sb, java.util.Collection<T> c, int limit, java.util.function.BiConsumer<java.lang.StringBuilder,T> appender)
-
style2
private static <T> java.lang.StringBuilder style2(java.lang.StringBuilder sb, int size, int limit, int indent, int incr, java.util.function.BiConsumer<java.lang.StringBuilder,java.lang.Integer> appender)
-
toFile
public static void toFile(java.io.ByteArrayOutputStream baos, java.lang.String name)Writes a byte array output stream to a file- Parameters:
baos- the array to writename- the name of the file
-
toFile
public static void toFile(java.io.ByteArrayOutputStream baos, java.io.File file)Writes a byte array output stream to a file- Parameters:
baos- the array to writefile- the file
-
nextHigherPowerOf2
public static int nextHigherPowerOf2(int i)
Convert an int argument to the next higher power of 2 if not already a power of 2- Parameters:
i- the value to convert- Returns:
- the next higher power of 2, or i if it is already a power of 2
-
nextHigherPowerOfX
public static int nextHigherPowerOfX(int i, int x)Convert an int argument to the next higher power of 2 to the x power- Parameters:
i- the value to convertx- the power of 2 to use- Returns:
- the next higher power of 2 to the x, or i if it is already == to 2 to the x
-
getProtectedMethodHandle
public static java.lang.invoke.MethodHandle getProtectedMethodHandle(java.lang.Class<?> clazz, java.lang.invoke.MethodHandles.Lookup methodHandleAccessContext, java.lang.String protectedMethod, java.lang.Class<?>... args)Given a class, a lookup context, and a protected method and its arg classes, return the method handle for that method. Using that method handle is slow, but converting it to a lambda makes for JIT-able fast access.- Parameters:
clazz- -methodHandleAccessContext- -protectedMethod- -args- -- Returns:
- -
-
getProtectedMethodHandle
public static java.lang.invoke.MethodHandle getProtectedMethodHandle(java.lang.Class<?> clazz, java.lang.String protectedMethod, java.lang.Class<?>... args)Given a class, and a protected method and its arg classes, return the method handle for that method. Note: uses the UIMA context as the lookup context Using that method handle is slow, but converting it to a lambda makes for JIT-able fast access.- Parameters:
clazz- -protectedMethod- -args- -- Returns:
- -
-
getProtectedFieldGetter
public static java.lang.invoke.MethodHandle getProtectedFieldGetter(java.lang.Class<?> clazz, java.lang.String protectedField)
-
getStaticIntField
public static int getStaticIntField(java.lang.Class<?> clazz, java.lang.String fieldName)Gets an int from a named field. If the field isn't present, returns Integer.MIN_VALUE;- Parameters:
clazz- the class where the field isfieldName- the name of the field- Returns:
- the value or Integer.MIN_VALUE if not present
-
getStaticIntFieldNoInherit
public static int getStaticIntFieldNoInherit(java.lang.Class<?> clazz, java.lang.String fieldName)
-
getPrivateStaticIntFieldNoInherit
public static int getPrivateStaticIntFieldNoInherit(java.lang.Class<?> clazz, java.lang.String fieldName)
-
addAll
public static void addAll(java.util.Collection<java.lang.String> c, java.lang.String... v)Takes trailing arguments of strings and adds them all the first- Parameters:
c- the collection to add the strings tov- 0 or more strings as arguments
-
debug
public static void debug(java.lang.Object o)
-
assertUie
public static void assertUie(boolean v)
Check and throw UIMA Internal Error if false- Parameters:
v- if false, throws
-
assertUie
public static void assertUie(boolean v, java.lang.Throwable e)
-
internalError
public static java.lang.RuntimeException internalError()
-
internalError
public static void internalError(java.lang.Throwable e)
-
hashInt
public static int hashInt(int k1)
-
hashStringLong
public static long hashStringLong(java.lang.String s)
a hash for strings as a long - less likely to be a collision- Parameters:
s- - the string- Returns:
- a long hash
-
getWithExpand
public static <T> T getWithExpand(java.util.List<T> a, int i)Get item from array list. If index is > length, expand the array, and return null- Type Parameters:
T- the type of the items in the list- Parameters:
a- the listi- the index- Returns:
- the item at the index or null
-
setWithExpand
public static <T> void setWithExpand(java.util.List<T> a, int i, T value)
-
equalStrings
public static boolean equalStrings(java.lang.String s1, java.lang.String s2)
-
compareStrings
public static int compareStrings(java.lang.String s1, java.lang.String s2)
-
elideString
public static java.lang.String elideString(java.lang.String s, int len)
-
shareExisting
public static <T> T shareExisting(T obj, java.util.WeakHashMap<T,java.lang.ref.WeakReference<T>> cache)Some objects can be shared, if "equal", rather than creating duplicates, if they're read-only. This may in general be beneficial by reducing the size of the "working set" via more sharing of read-only objects. Users should insure the read-only property. This routine allows a) creating a potentially sharable object b) checking to see if we already have an "equal" one, and c) if so, using that and allowing the just created one to be GC'd.- Type Parameters:
T- the type of the cached object- Parameters:
obj- - the object to use a cached substitute for, if one existscache- - the cache- Returns:
- - the object or a cached version of it.
-
ppList
public static <T> java.lang.String ppList(java.util.List<T> items)
format a list of items for pretty printing as [item1, item2, ... ]- Type Parameters:
T- the type of elements in the list- Parameters:
items- to print- Returns:
- [item1, item2, ... ]
-
ppList
public static <T> java.lang.String ppList(java.util.List<T> items, int max)- Type Parameters:
T- the type of elements in the list- Parameters:
items- to printmax- - maximum number of items to print- Returns:
- [item1, item2, ... ]
-
ppList
public static <T> java.lang.String ppList(java.util.List<T> items, int max, java.util.function.BiConsumer<java.lang.StringBuilder,T> appender)- Type Parameters:
T- the type of elements in the list- Parameters:
items- to printmax- - maximum number of items to printappender- - appender function- Returns:
- [item1, item2, ... ]
-
ppList
public static <T> java.lang.String ppList(int[] indent, java.util.List<T> items)format a list of items for pretty printing as [item1, item2, ... ]- Type Parameters:
T- the type of elements in the list- Parameters:
indent- the amount to use as indentationitems- to print- Returns:
- [item1, item2, ... ]
-
ppList
public static <T> java.lang.String ppList(int[] indent, java.util.List<T> items, int max)- Type Parameters:
T- the type of elements in the list- Parameters:
indent- the amount to use as indentationitems- to printmax- - maximum number of items to print- Returns:
- [item1, item2, ... ]
-
ppList
public static <T> java.lang.String ppList(int[] indent, java.util.List<T> items, int max, java.util.function.BiConsumer<java.lang.StringBuilder,T> appender)- Type Parameters:
T- the type of elements in the list- Parameters:
indent- the amount to use as indentationitems- to printmax- - maximum number of items to printappender- - appender function- Returns:
- [item1, item2, ... ]
-
typeName2ClassName
public static java.lang.String typeName2ClassName(java.lang.String typeName)
Convert a UIMA type name to a JCas class name (fully qualified) Normally this is the same, but for two prefixes, it's slightly different- Parameters:
typeName- the UIMA type name, fully qualified- Returns:
- the fully qualified JCas class name
-
javaClassName2UimaTypeName
public static java.lang.String javaClassName2UimaTypeName(java.lang.String className)
Convert a JCas class name (fully qualified) to a UIMA type name Normally this is the same, but for two prefixes, it's slightly different Also, class names for primitives (int, byte, etc. ) converted to int, byte, etc.- Parameters:
className- the Java JCas class name for a UIMA type, fully qualified- Returns:
- the fully qualified UIMA Type name
-
timeLoops
public static void timeLoops(java.lang.String title, int iterations, Runnable_withException r) throws java.lang.Exception- Throws:
java.lang.Exception
-
sleep
public static void sleep(int milliseconds)
-
maybeShrink
public static boolean maybeShrink(boolean secondTimeShrinkable, int size, int capacity, int factor, int minCapacity, java.util.function.IntConsumer realloc, java.lang.Runnable reset)
-
isJava9ea
public static boolean isJava9ea()
-
classNameFromByteCode
public static java.lang.String classNameFromByteCode(byte[] bytes)
extract the slashified version of the fully qualified class name from the bytecode for a class- Parameters:
bytes- the bytecode to extract from- Returns:
- the slashified class name eg. x/y/z/Myclass
-
readModifiedUTF8
private static java.lang.String readModifiedUTF8(java.nio.ByteBuffer bb)
read ByteBuffer modified UTF into String see http://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.4
-
setAsList
public static <T> java.util.List<T> setAsList(java.util.Set<T> set)
-
contains
public static boolean contains(java.lang.String[] strings, java.lang.String item)
-
contains
public static boolean contains(java.lang.ClassLoader[] cls, java.lang.ClassLoader cl)
-
decreasingWithTrace
public static void decreasingWithTrace(java.util.concurrent.atomic.AtomicInteger errorCount, java.lang.String message, Logger logger)Issues message at warning or fine level (fine if enabled, includes stack trace)- Parameters:
errorCount- the count of errors used to decrease the frequencymessage- the messagelogger- the logger to use
-
decreasingMessage
public static void decreasingMessage(java.util.concurrent.atomic.AtomicInteger errorCount, java.util.function.Supplier<java.lang.String> messageSupplier, java.util.function.Consumer<java.lang.String> publishMessage)
-
-