Package randoop.util
Class ClassFileConstants
- java.lang.Object
-
- randoop.util.ClassFileConstants
-
public class ClassFileConstants extends Object
Reads literals from a class file, including from the constant pool and from bytecodes that take immediate arguments.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ClassFileConstants.ConstantSet
Stores constant values from a class file.
-
Field Summary
Fields Modifier and Type Field Description (package private) static byte
bb
A byte value for testing.(package private) static char
c
A char value for testing.(package private) static double
d
A double value for testing.(package private) static float
f
A float value for testing.(package private) static int
ii
An int value for testing.(package private) static long
ll
A long value for testing.(package private) static short
s
A short value for testing.
-
Constructor Summary
Constructors Constructor Description ClassFileConstants()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static void
addToConstantMap(ClassFileConstants.ConstantSet cs, MultiMap<Class<?>,NonreceiverTerm> map)
Add all constant values from the given ConstantSet as NonreceiverTerms to their corresponding class in the given map.private static Set<NonreceiverTerm>
constantSetToNonreceiverTerms(ClassFileConstants.ConstantSet cs)
Convert a ConstantSet to a set of NonreceiverTerms.(package private) static void
doubleConstant(Double value, ClassFileConstants.ConstantSet cs)
Register a double constant in the given ConstantSet.(package private) static void
floatConstant(Float value, ClassFileConstants.ConstantSet cs)
Register a float constant in the given ConstantSet.static ClassFileConstants.ConstantSet
getConstants(String classname)
Returns all the constants found in the given class.static ClassFileConstants.ConstantSet
getConstants(String classname, ClassFileConstants.ConstantSet result)
Adds all the constants found in the given class into the given ConstantSet, and returns it.static Set<NonreceiverTerm>
getNonreceiverTerms(Class<?> c)
Return the set of NonreceiverTerms converted from constants for the given class.(package private) static void
integerConstant(Integer value, ClassFileConstants.ConstantSet cs)
Register an integer constant in the given ConstantSet.(package private) static void
longConstant(Long value, ClassFileConstants.ConstantSet cs)
Register a long constant in the given ConstantSet.static void
main(String[] args)
A simple driver program that prints output literals file format.static MultiMap<Class<?>,NonreceiverTerm>
toMap(Collection<ClassFileConstants.ConstantSet> constantSets)
Convert a collection of ConstantSets to the format expected by GenTest.addClassLiterals.
-
-
-
Field Detail
-
bb
static byte bb
A byte value for testing.
-
d
static double d
A double value for testing.
-
f
static float f
A float value for testing.
-
ii
static int ii
An int value for testing.
-
ll
static long ll
A long value for testing.
-
s
static short s
A short value for testing.
-
c
static char c
A char value for testing.
-
-
Method Detail
-
main
public static void main(String[] args) throws IOException
A simple driver program that prints output literals file format.- Parameters:
args
- the command line arguments- Throws:
IOException
- if an error occurs in writing the constants- See Also:
LiteralFileReader
-
getConstants
public static ClassFileConstants.ConstantSet getConstants(String classname)
Returns all the constants found in the given class.- Parameters:
classname
- the name of the type- Returns:
- the set of constants of the given type
- See Also:
getConstants(String,ConstantSet)
-
getConstants
public static ClassFileConstants.ConstantSet getConstants(String classname, ClassFileConstants.ConstantSet result)
Adds all the constants found in the given class into the given ConstantSet, and returns it.- Parameters:
classname
- the name of the typeresult
- the set of constants to which constants are added- Returns:
- the set of constants with new constants of given type added
- See Also:
getConstants(String)
-
doubleConstant
static void doubleConstant(Double value, ClassFileConstants.ConstantSet cs)
Register a double constant in the given ConstantSet.- Parameters:
value
- the double constantcs
- the ConstantSet
-
floatConstant
static void floatConstant(Float value, ClassFileConstants.ConstantSet cs)
Register a float constant in the given ConstantSet.- Parameters:
value
- the float constantcs
- the ConstantSet
-
integerConstant
static void integerConstant(Integer value, ClassFileConstants.ConstantSet cs)
Register an integer constant in the given ConstantSet.- Parameters:
value
- the integer constantcs
- the ConstantSet
-
longConstant
static void longConstant(Long value, ClassFileConstants.ConstantSet cs)
Register a long constant in the given ConstantSet.- Parameters:
value
- the long constantcs
- the ConstantSet
-
getNonreceiverTerms
public static Set<NonreceiverTerm> getNonreceiverTerms(Class<?> c)
Return the set of NonreceiverTerms converted from constants for the given class.- Parameters:
c
- the class- Returns:
- a set of Nonreceiver terms for the given class
-
toMap
public static MultiMap<Class<?>,NonreceiverTerm> toMap(Collection<ClassFileConstants.ConstantSet> constantSets)
Convert a collection of ConstantSets to the format expected by GenTest.addClassLiterals.- Parameters:
constantSets
- the sets of constantSets- Returns:
- a map of types to constant operations
-
addToConstantMap
private static void addToConstantMap(ClassFileConstants.ConstantSet cs, MultiMap<Class<?>,NonreceiverTerm> map)
Add all constant values from the given ConstantSet as NonreceiverTerms to their corresponding class in the given map.- Parameters:
cs
- the constant setmap
- the map to add to
-
constantSetToNonreceiverTerms
private static Set<NonreceiverTerm> constantSetToNonreceiverTerms(ClassFileConstants.ConstantSet cs)
Convert a ConstantSet to a set of NonreceiverTerms.- Parameters:
cs
- the ConstantSet- Returns:
- a set of NonreceiverTerms
-
-