SDA SE Wiki

Software Engineering for Smart Data Analytics & Smart Data Analytics for Software Engineering

User Tools

Site Tools



markerT (#id, #comment, 'kind', ['args'])

Java annotations cannot be added inside nested expressions. However, some analysis results refer to deeply nested program elements. Therefore, JTransformer offers 'markerT' as a generic annotation facility that can be added to every element. JTransformer markers are basically Java comments whose internal structure obeys a simple syntax: The initial part must have the form

 annotationKind(arg1, ..., argN)

There may be an arbitrary trailing part up to the closing */. E.g.

<code Java>

/*@JT_suppress(string_identity_comparison) <- Tells JT not to 
  complain about == comparison of strings for this specific case:
*/
if (debugLevel == INFO) {
    ...
}

</Code>

See 'Adding analysis predicates to JT' for more information. (Supported since JTransformer 3.1)

Attributes

#id: id
the ID of the marked program element.

#comment: commentT
the ID of the commentT that contains the annotation

'kind' atom
the annotation kind. This can be any atom.

['args'] list of atoms
arguments of the annotation

See 'Adding analysis predicates to JT' for how to use the annotation kind and arguments.

Sample Java Source

public void m() {
   /*@JT_suppress(string_identity_comparison)*/
   if (debugLevel == INFO) {
      ...
   }
}

Its PEF Representation

ifT(If,Parent,Encl,Operation,Block,null).
  operationT(Operation,If,Encl,[Lhs,Rhs],==,0).
    getFieldT(Lhs,Operation,Encl,null,debugLevel,Field1).
    getFieldT(Rhs,Operation,Encl,null,'INFO',Field2).
markerT(If,Comment,suppress,[string_identity_comparison]).
commentT(Comment,If,blockComment).

AST Specification

ast_relation_type_spec(markerT,[
	ast_arg(id,	 mult(1,1,no ),  id,   [id]),
	ast_arg(comment, mult(1,1,no ),  id,   [commentT]),
	ast_arg(kind,	 mult(1,1,no ),  attr, [atomic]),
	ast_arg(args,	 mult(0,*,ord ), attr, [atomic])
]).
research/jtransformer/api/java/pefs/3.0/markert.txt · Last modified: 2018/05/09 01:59 (external edit)

SEWiki, © 2025