Reputation: 1259
below code should throw an exception
import jakarta.annotation.Nonnull;
public class test89 {
public String processString(@Nonnull String input) {
// Your method logic here
return "Processed: " + input;
}
public static void main(String[] args) {
test89 exampleService = new test89();
String result = exampleService.processString(null);
System.out.println(result);
}
}
but giving output as
`
Processed: null
Process finished with exit code 0`
it should throw Exception
Upvotes: 0
Views: 265
Reputation: 5135
Where should the annotation processing happen in your small code example?
You don't use dependency injection or call any validation, so your code works as I would expect it.
The annotation doesn't do anything by itself, it is just a marker for other code to process.
See the Jakarta Annotations specification and Javadoc.
Upvotes: 4