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

User Tools

Site Tools

jtAnnotationT(#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 jtAnnotationT 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) {


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


#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() {
   if (debugLevel == INFO) {

Its PEF Representation

ifT(If, _, _, _, _,null),
commentT(Comment, If, blockComment),
jtAnnotationT(If, Comment, suppress, [string_identity_comparison]).

AST Specification

	ast_arg(id,	 mult(1,1,no ),  id,   [jtAnnotationT]),
	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/4.2/jtannotationt.txt · Last modified: 2018/05/09 01:59 (external edit)

SEWiki, © 2023