|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object edu.rice.cs.cunit.classFile.ClassFileTools
public class ClassFileTools
Tools for dealing with class files.
Nested Class Summary | |
---|---|
static class |
ClassFileTools.ClassFileToolsTest
Test cases. |
static class |
ClassFileTools.ClassLocation
Helper class for findClassFile. |
Constructor Summary | |
---|---|
ClassFileTools()
|
Method Summary | |
---|---|
static boolean |
classNameMatches(java.lang.String className,
java.lang.String... classNamePatterns)
Returns true if the specified class name matches one of the patterns. |
static ClassFileTools.ClassLocation |
findClassFile(java.lang.String className,
java.util.List<java.lang.String> classPath)
Find a class. |
static ClassFile |
findClassInFiles(java.lang.String className,
java.util.Set<java.lang.String> filesToConsider)
Find a class in the files to consider and return its class file info. |
static void |
generateDependencyFixPoint(java.util.Set<java.lang.String> classNames,
java.util.List<java.lang.String> classPath,
java.util.Set<java.lang.String> classesUsed,
ILambda<java.lang.Object,ClassFileTools.ClassLocation> processClassNameLambda,
ILambda<java.lang.Object,java.lang.String> processNotFoundLambda)
Generate the class dependency fix point. |
static java.lang.String |
getAccessString(short flags)
Return a string that represents the access flags set. |
static java.lang.Class<?> |
getClassFromType(java.lang.String type)
Get the Class instance for the given type. |
static java.lang.Class<?> |
getClassFromType(java.lang.String type,
boolean initialize,
java.lang.ClassLoader loader)
Get the Class instance for the given type. |
static java.lang.String |
getClassName(java.lang.String s)
Return class name in Java form. |
static java.lang.String |
getClassNameFromType(java.lang.String type)
Get the class/primitive name for the given type. |
static java.util.Set<java.lang.String> |
getClassNamesUsed(ClassFile cf)
Returns a set of class names used in a class files. |
static java.util.Set<java.lang.String> |
getClassNamesUsed(java.lang.String s)
Return set of class names used in this mangled name. |
java.util.Set<java.lang.String> |
getDependencyFixPoint(java.util.Set<java.lang.String> classNames,
java.util.List<java.lang.String> classPath)
Return the class dependency fix point. |
static java.lang.String |
getNextSignature(java.lang.String sig)
Return the next descriptor from a string of concatenated signatures. |
static char |
getPrimitiveTypeChar(java.lang.String primTypeName)
Returns the type character associated with a primitive type name, or 0 if there was an error. |
static java.util.List<java.lang.String> |
getSignatures(java.lang.String sig)
Return a list of signatures. |
static java.lang.String |
getTypeString(java.lang.String typeString,
java.lang.String varName)
Translate a type descriptor descriptor and a variable name into a Java declaration. |
static boolean |
isPrimitive(java.lang.String typeString)
Return true if this is a primitive type or an array of primitive types. |
static ClassFile |
loadClassFromStream(java.io.InputStream is)
Load class file info from the stream. |
private static void |
processAnnotation(AAnnotationsAttributeInfo.Annotation a,
java.util.HashSet<java.lang.String> classesUsed)
Helper for getClassNamesUsed that processes an annotation. |
private static void |
processMemberValue(AAnnotationsAttributeInfo.Annotation.AMemberValue mv,
java.util.HashSet<java.lang.String> classesUsed)
Helper for processAnnotation that processes an annotation member value. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ClassFileTools()
Method Detail |
---|
public static java.lang.String getAccessString(short flags)
flags
- access flags
public static java.lang.String getTypeString(java.lang.String typeString, java.lang.String varName)
typeString
- type descriptor descriptorvarName
- variable name
public static char getPrimitiveTypeChar(java.lang.String primTypeName)
primTypeName
- primitive type name, e.g. "void" or "byte"
public static boolean isPrimitive(java.lang.String typeString)
typeString
- type descriptor descriptor
public static java.util.List<java.lang.String> getSignatures(java.lang.String sig)
sig
- concatenated signatures
public static java.lang.String getNextSignature(java.lang.String sig)
sig
- concatenated signatures
public static java.lang.String getClassName(java.lang.String s)
s
- mangled class name
public static java.util.Set<java.lang.String> getClassNamesUsed(java.lang.String s)
s
- mangled class name
public static java.util.Set<java.lang.String> getClassNamesUsed(ClassFile cf)
cf
- class file
private static void processAnnotation(AAnnotationsAttributeInfo.Annotation a, java.util.HashSet<java.lang.String> classesUsed)
a
- annotationclassesUsed
- set of classes usedprivate static void processMemberValue(AAnnotationsAttributeInfo.Annotation.AMemberValue mv, java.util.HashSet<java.lang.String> classesUsed)
mv
- member valueclassesUsed
- set of classes usedpublic static ClassFileTools.ClassLocation findClassFile(java.lang.String className, java.util.List<java.lang.String> classPath)
className
- class to findclassPath
- list with class path entries
public static void generateDependencyFixPoint(java.util.Set<java.lang.String> classNames, java.util.List<java.lang.String> classPath, java.util.Set<java.lang.String> classesUsed, ILambda<java.lang.Object,ClassFileTools.ClassLocation> processClassNameLambda, ILambda<java.lang.Object,java.lang.String> processNotFoundLambda)
classNames
- list of class namesclassPath
- list of class path entriesclassesUsed
- set of used classesprocessClassNameLambda
- lambda to apply class names toprocessNotFoundLambda
- lambda to apply to missing class names to
NOTE: The ClassLocation's input stream will get closed after the lambda has been invoked.
That means it should not be stored and used later.public java.util.Set<java.lang.String> getDependencyFixPoint(java.util.Set<java.lang.String> classNames, java.util.List<java.lang.String> classPath)
classNames
- class namesclassPath
- class path entries
public static ClassFile findClassInFiles(java.lang.String className, java.util.Set<java.lang.String> filesToConsider)
className
- name of class to findfilesToConsider
- set of file names (*.class and *.jar) to consider during the search.
public static ClassFile loadClassFromStream(java.io.InputStream is) throws java.io.IOException
is
- input stream
java.io.IOException
public static boolean classNameMatches(java.lang.String className, java.lang.String... classNamePatterns)
className
- class nameclassNamePatterns
- variable argument list of patterns
public static java.lang.Class<?> getClassFromType(java.lang.String type) throws java.lang.ClassNotFoundException
type
- type string
java.lang.ClassNotFoundException
public static java.lang.Class<?> getClassFromType(java.lang.String type, boolean initialize, java.lang.ClassLoader loader) throws java.lang.ClassNotFoundException
type
- type stringinitialize
- whether the class needs to be initializedloader
- the class loader
java.lang.ClassNotFoundException
public static java.lang.String getClassNameFromType(java.lang.String type)
type
- type string
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |