219 questions
0 votes
0 answers
59 views
Is it ok to suppress there warnings [duplicate]
I have code that has two warnings. The code is from a commandline Expense manager project that uses a List to save and access expenses. Saving and retrieving the List is done via serialisation and ...
1 vote
0 answers
322 views
How to "ignore": jakarta.validation.UnexpectedTypeException: No validator could be found for constraint 'jakarta.validation.constraints.Pattern'
I read that the usage of @jakarta.validation.constraints.Pattern should be used on return types of Charsequence. The issue that I am facing is that in my case, I am using generated java files from ...
4 votes
3 answers
332 views
Why are Checker Framework annotations not returned by Field#getDeclaredAnnotations?
I wanted to extend a bit of code that processes annotations to also support the Nullable annotation from the Checker Framework. To my surprise, this didn't work. Upon further inspection, it seems like ...
0 votes
2 answers
311 views
IntelliJ and Eclipse disagree on null annotations through multiple interfaces. Is one "more correct" or is it a fault of poor annotation in the API?
I am having a null analysis issue when compiling GriefPrevention in Eclipse. For example, line 304 in PlayerEventHandler.java invokes Player#getLocation(). The API specification for this class can be ...
8 votes
1 answer
586 views
Generating code for an annotation using Java Poet
I want to create method level annotations & generate code for it. I want to avoid using AspectJ and would prefer a compile time code generator so that if I've to ever debug the code I can actually ...
-4 votes
2 answers
217 views
What does `@SuppressWarnings("javadoc")` do? When is it Redundant?
I have @SuppressWarnings("javadoc") on almost every class. My IDE gives me a warning on virtually all of them: "Redundant suppression". I assume advances in technology have made ...
0 votes
2 answers
992 views
How @ConditionalOnClass works, as Spring doc says, @Conditional that only matches when the specified classes are on the classpath
@ConditionalOnProperty works straight forward, depending upon this property is present (and/or value is correct), condition will result into true or false. But can someone explain how @...
0 votes
1 answer
64 views
Creating a Reusable Column Type Annotation for JPA to Set Size and Nullability
I'm working with several tables that have multiple fields sharing common characteristics, such as attributes like length and nullability. For instance, the field Username remains consistent across ...
0 votes
1 answer
53 views
Defining embeded annotation interface in Java
I have following annotation interface: @Target({ElementType.METHOD, ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) @Inherited @Documented public @interface MockToken { String user() ...
0 votes
1 answer
776 views
Annotation-processor based builder pattern with Java 14 records
At my org we extensively use @Value.Immutable annotation with interfaces or abstract classes to generate Immutable classes with builders for our internal data transfer objects (DTOs) [ref]. We are ...
-1 votes
1 answer
353 views
Java annotation to change null value
I want to write an annotation that can change the parameter value to some default if it is null. For example: static void myMethod(@NullToDefault String param) { System.out.println(param); } ...
1 vote
1 answer
659 views
How to use Lombok's RequiredArgsConstructor with Nullaway?
We're trying to add "Nullaway" (https://github.com/uber/NullAway) to our repo. This is a tool that assumes everything not annotated with @Nullable can't be null and enforces it in compile ...
1 vote
0 answers
541 views
Spring Boot Graphql: How can I pre-process an individual query/mutation before it runs the controller method?
I want to add an annotation to my controller methods that is used to check if the user can perform an action or access a piece of data before the controller method is called. I want to be able to ...
0 votes
0 answers
105 views
Find Java annotations via reflection for Kotlin getter
We have a wrapper class for checking the Android SDK version, and it uses the ChecksSdkIntAtLeast annotation. Here's a trimmed example of the class with just one getter and the logging removed: class ...
0 votes
0 answers
131 views
How does Spring's @Cacheble annotation work?
I was looking into annotations but wasn't able to grasp how annotations actually work. So I tried to break my problem as follows: Lets suppose I have a spring boot project that is used as a ...