Class IndexFileWriter
java.lang.Object
org.checkerframework.afu.scenelib.io.IndexFileWriter
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidformatAnnotationValue(StringBuilder sb, AnnotationFieldType aft, Object o) Formats a literal argument of an annotation.static StringDeprecated.static voidWrites the annotations insceneand their definitions tooutin index file format.static voidWrites the annotations insceneand their definitions to the filefilenamein index file format; seewrite(AScene, Writer).
-
Method Details
-
formatAnnotationValue
Deprecated.Formats a literal argument of an annotation. Public to permit re-use in stub-based whole-program inference.- Parameters:
aft- the type of the annotation fieldo- the value or values to format- Returns:
- the String representation of the value
-
formatAnnotationValue
Formats a literal argument of an annotation. Public to permit re-use in stub-based whole-program inference.- Parameters:
sb- where to format the arguments toaft- the type of the annotation fieldo- the value or values to format
-
write
Writes the annotations insceneand their definitions tooutin index file format.An
AScenecan contain several annotations of the same type but different definitions, while an index file can accommodate only a single definition for each annotation type. This has two consequences:- Before writing anything, this method uses a
DefCollectorto ensure that all definitions of each annotation type are identical (modulo unknown array types). If not, aDefExceptionis thrown. - There is one case in which, even if a scene is written successfully, reading it back in
produces a different scene. Consider a scene containing two annotations of type Foo, each
with an array field bar. In one annotation, bar is empty and of unknown element type (see
AnnotationBuilder.addEmptyArrayField(java.lang.String)); in the other, bar is of known element type. This method will unify the two definitions of Foo by writing a single definition with known element type. When the index file is read into a new scene, the definitions of both annotations will have known element type, whereas in the original scene, one had unknown element type.
- Throws:
DefException
- Before writing anything, this method uses a
-
write
Writes the annotations insceneand their definitions to the filefilenamein index file format; seewrite(AScene, Writer).- Throws:
IOExceptionDefException
-