|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.annotation.processing.AbstractProcessor com.sun.source.util.AbstractTypeProcessor checkers.source.SourceChecker checkers.basetype.BaseTypeChecker checkers.igj.IGJChecker
@TypeQualifiers(value={ReadOnly.class,Mutable.class,Immutable.class,I.class,AssignsFields.class,checkers.igj.IGJBottom.class}) public class IGJChecker
A type-checker plug-in for the IGJ immutability type system that finds (and
verifies the absence of) undesired side-effect errors.
The IGJ language is a Java language extension that expresses immutability
constraints, using six annotations: ReadOnly
, Mutable
,
Immutable
, I
-- a polymorphic qualifier, Assignable
,
and AssignsFields
. The language is specified by the FSE 2007 paper.
Field Summary | |
---|---|
protected AnnotationMirror |
ASSIGNS_FIELDS
Supported Annotations for IGJ. |
protected AnnotationMirror |
BOTTOM_QUAL
Supported Annotations for IGJ. |
protected AnnotationMirror |
I
Supported Annotations for IGJ. |
protected AnnotationMirror |
IMMUTABLE
Supported Annotations for IGJ. |
protected AnnotationMirror |
MUTABLE
Supported Annotations for IGJ. |
protected AnnotationMirror |
READONLY
Supported Annotations for IGJ. |
Fields inherited from class checkers.source.SourceChecker |
---|
currentPath, currentRoot, env, messager, messages, skipPattern, trees |
Fields inherited from class javax.annotation.processing.AbstractProcessor |
---|
processingEnv |
Constructor Summary | |
---|---|
IGJChecker()
|
Method Summary | |
---|---|
protected QualifierHierarchy |
createQualifierHierarchy()
Returns the type qualifier hierarchy graph to be used by this processor. |
protected TypeHierarchy |
createTypeHierarchy()
Creates the type subtyping checker using the current type qualifier hierarchy. |
void |
init(ProcessingEnvironment env)
|
boolean |
isAssignable(AnnotatedTypeMirror varType,
AnnotatedTypeMirror receiverType,
Tree varTree)
Return true if the assignment variable is an assignable field or variable, and returns false otherwise. |
boolean |
isValidUse(AnnotatedTypeMirror.AnnotatedDeclaredType elemType,
AnnotatedTypeMirror.AnnotatedDeclaredType use)
Tests that the qualifiers present on the useType are valid qualifiers, given the qualifiers on the declaration of the type, declarationType. |
Methods inherited from class checkers.basetype.BaseTypeChecker |
---|
createFactory, createSourceVisitor, createSupportedTypeQualifiers, getQualifierHierarchy, getSupportedLintOptions, getSupportedTypeQualifiers, isSubtype |
Methods inherited from class checkers.source.SourceChecker |
---|
getLintOption, getLintOption, getMessages, getProcessingEnvironment, getShouldSkip, getSupportedAnnotationTypes, getSupportedOptions, getSupportedSourceVersion, getSuppressWarningsKey, message, report, shouldSkip, typeProcess |
Methods inherited from class com.sun.source.util.AbstractTypeProcessor |
---|
process, typeProcessingOver |
Methods inherited from class javax.annotation.processing.AbstractProcessor |
---|
getCompletions, isInitialized |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected AnnotationMirror READONLY
protected AnnotationMirror MUTABLE
protected AnnotationMirror IMMUTABLE
protected AnnotationMirror I
protected AnnotationMirror ASSIGNS_FIELDS
protected AnnotationMirror BOTTOM_QUAL
Constructor Detail |
---|
public IGJChecker()
Method Detail |
---|
public void init(ProcessingEnvironment env)
SourceChecker
init
in interface Processor
init
in class BaseTypeChecker
AbstractProcessor.init(ProcessingEnvironment)
public boolean isAssignable(AnnotatedTypeMirror varType, AnnotatedTypeMirror receiverType, Tree varTree)
Assignable
3. accessed through a mutable reference
4. reassigned with an AssignsFields
method and owned by 'this'
isAssignable
in class BaseTypeChecker
varType
- the annotated variable typevarTree
- tree used to access the variable
public boolean isValidUse(AnnotatedTypeMirror.AnnotatedDeclaredType elemType, AnnotatedTypeMirror.AnnotatedDeclaredType use)
BaseTypeChecker
The check is shallow, as it does not descend into generic or array
types (i.e. only performing the validity check on the raw type or
outmost array dimension). BaseTypeVisitor.validateTypeOf(Tree)
would call this for each type argument or array dimention separately.
For instance, in the IGJ type system, a @Mutable
is an invalid
qualifier for String
, as String
is declared as
@Immutable String
.
In most cases, useType
simply needs to be a subtype of
declarationType
, but there are exceptions. In IGJ, a variable may be
declared @ReadOnly String
, even though String
is
@Immutable String
; ReadOnly
is not a subtype of
Immutable
.
isValidUse
in class BaseTypeChecker
elemType
- the type of the class (TypeElement)use
- the use of the class (instance type)
protected QualifierHierarchy createQualifierHierarchy()
BaseTypeChecker
BaseTypeChecker.getSupportedTypeQualifiers()
using the
meta-annotations found in them. The current implementation returns an
instance of GraphQualifierHierarchy
.
Subclasses may override this method to express any relationships that
cannot be inferred using meta-annotations (e.g. due to lack of
meta-annotations).
createQualifierHierarchy
in class BaseTypeChecker
protected TypeHierarchy createTypeHierarchy()
BaseTypeChecker
createTypeHierarchy
in class BaseTypeChecker
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |