Hello,
I’m trying to validate if the Test1 class has the correct annotation in the test attribute.
public class Test1{
@Inject //Corrrect is @EJB
private Test2 test;
//code
}
@Stateless
public class Test2{
//code
}
But typeSymbol.declaration() is always null.
Symbol.VariableSymbol variableSymbol = (VariableSymbol) tree.symbol();
Symbol.TypeSymbol typeSymbol = variableSymbol.type().symbol();
if (typeSymbol != null && typeSymbol.declaration() != null) {
ClassTree classTree = (ClassTree) typeSymbol.declaration();
// code
} else {
LOGGER.info("Declaration is null")
}
What am I doing wrong? How can I do this validation?