Package org.jboss.weld.util.reflection
Class Formats
- java.lang.Object
-
- org.jboss.weld.util.reflection.Formats
-
public class Formats extends Object
Utility class to produce friendly names e.g. for debugging- Author:
- Pete Muir, Nicklas Karlsson, Jozef Hartinger
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
addSpaceIfNeeded(String string)
static String
formatActualTypeArguments(Type type)
static String
formatActualTypeArguments(Type[] actualTypeArguments)
static String
formatActualTypeArguments(Type[] actualTypeArguments, boolean simpleNames)
static String
formatAnnotatedConstructor(jakarta.enterprise.inject.spi.AnnotatedConstructor<?> constructor)
static String
formatAnnotatedField(jakarta.enterprise.inject.spi.AnnotatedField<?> field)
static String
formatAnnotatedMethod(jakarta.enterprise.inject.spi.AnnotatedMethod<?> method)
static String
formatAnnotatedParameter(jakarta.enterprise.inject.spi.AnnotatedParameter<?> parameter)
static String
formatAnnotatedType(jakarta.enterprise.inject.spi.AnnotatedType<?> type)
static String
formatAnnotations(Annotation[] annotations)
Gets a string representation from an array of annotationsstatic String
formatAnnotations(Iterable<Annotation> annotations)
static String
formatAsFormalParameterList(Iterable<? extends jakarta.enterprise.inject.spi.AnnotatedParameter<?>> parameters)
static String
formatAsStackTraceElement(jakarta.enterprise.inject.spi.InjectionPoint ij)
See also WELD-1454.static String
formatAsStackTraceElement(Member member)
static String
formatBusinessInterfaceDescriptors(Iterable<? extends org.jboss.weld.ejb.spi.BusinessInterfaceDescriptor<?>> businessInterfaceDescriptors)
static String
formatInjectionPointType(Type type)
static String
formatModifiers(int modifiers)
static String
formatParameter(jakarta.enterprise.inject.spi.AnnotatedParameter<?> parameter)
static String
formatSimpleClassName(Class<?> javaClass)
static String
formatSimpleClassName(Object object)
static String
formatType(Type baseType)
static String
formatType(Type baseType, boolean simpleNames)
static <D extends GenericDeclaration>
StringformatTypeParameters(TypeVariable<D>[] typeParams)
static String
formatTypes(Iterable<? extends Type> baseTypes)
static String
formatTypes(Iterable<? extends Type> baseTypes, boolean simpleNames)
static int
getLineNumber(Member member)
Try to get the line number associated with the given member.static String
getNameOfMissingClassLoaderDependency(Throwable e)
Attempts to extract a name of a missing class loader dependency from an exception such asNoClassDefFoundError
orClassNotFoundException
.static String
getSimpleVersion()
static String
version(Package pkg)
static String
version(String version, String timestamp)
static String
wrapIfNecessary(String string, String prepend, String append)
-
-
-
Method Detail
-
formatAsStackTraceElement
public static String formatAsStackTraceElement(jakarta.enterprise.inject.spi.InjectionPoint ij)
See also WELD-1454.- Parameters:
ij
-- Returns:
- the formatted string
-
getLineNumber
public static int getLineNumber(Member member)
Try to get the line number associated with the given member. The reflection API does not expose such an info and so we need to analyse the bytecode. Unfortunately, it seems there is no way to get this kind of information for fields. Moreover, theLineNumberTable
attribute is just optional, i.e. the compiler is not required to store this information at all. See also Java Virtual Machine Specification Implementation note: it wouldn't be appropriate to add a bytecode scanning dependency just for this functionality, therefore Apache BCEL included in Oracle JDK 1.5+ and OpenJDK 1.6+ is used. Other JVMs should not crash as we only use it if it's on the classpath and by means of reflection calls.- Parameters:
member
-resourceLoader
-- Returns:
- the line number or 0 if it's not possible to find it
-
formatTypes
public static String formatTypes(Iterable<? extends Type> baseTypes, boolean simpleNames)
-
formatBusinessInterfaceDescriptors
public static String formatBusinessInterfaceDescriptors(Iterable<? extends org.jboss.weld.ejb.spi.BusinessInterfaceDescriptor<?>> businessInterfaceDescriptors)
-
formatAsFormalParameterList
public static String formatAsFormalParameterList(Iterable<? extends jakarta.enterprise.inject.spi.AnnotatedParameter<?>> parameters)
-
formatParameter
public static String formatParameter(jakarta.enterprise.inject.spi.AnnotatedParameter<?> parameter)
-
formatModifiers
public static String formatModifiers(int modifiers)
-
formatActualTypeArguments
public static String formatActualTypeArguments(Type[] actualTypeArguments)
-
formatActualTypeArguments
public static String formatActualTypeArguments(Type[] actualTypeArguments, boolean simpleNames)
-
formatAnnotations
public static String formatAnnotations(Iterable<Annotation> annotations)
-
formatAnnotations
public static String formatAnnotations(Annotation[] annotations)
Gets a string representation from an array of annotations- Parameters:
annotations
- The annotations- Returns:
- The string representation
-
version
public static String version(@Deprecated Package pkg)
- Parameters:
pkg
- This param is completely ignored- Returns:
- the formatted version
-
getSimpleVersion
public static String getSimpleVersion()
- Returns:
- a simple version string, i.e. no formatting is applied
-
formatAnnotatedType
public static String formatAnnotatedType(jakarta.enterprise.inject.spi.AnnotatedType<?> type)
-
formatAnnotatedConstructor
public static String formatAnnotatedConstructor(jakarta.enterprise.inject.spi.AnnotatedConstructor<?> constructor)
-
formatAnnotatedField
public static String formatAnnotatedField(jakarta.enterprise.inject.spi.AnnotatedField<?> field)
-
formatAnnotatedMethod
public static String formatAnnotatedMethod(jakarta.enterprise.inject.spi.AnnotatedMethod<?> method)
-
formatAnnotatedParameter
public static String formatAnnotatedParameter(jakarta.enterprise.inject.spi.AnnotatedParameter<?> parameter)
-
getNameOfMissingClassLoaderDependency
public static String getNameOfMissingClassLoaderDependency(Throwable e)
Attempts to extract a name of a missing class loader dependency from an exception such asNoClassDefFoundError
orClassNotFoundException
.
-
formatTypeParameters
public static <D extends GenericDeclaration> String formatTypeParameters(TypeVariable<D>[] typeParams)
-
-