Questions tagged [java-annotations]
211 questions
0
votes
1 answer
Is there anyway to create a Spring Aspect advice that triggers on any method that is NOT annotated by certain annotation?
Basically I am trying to create a log system that will log most of the controller methods (their parameters, bodies, status codes and so on), however, there are few controller methods I do not want to log for some specific reasons. I do not want to…

Cheng Chen
- 151
- 1
- 11
0
votes
1 answer
Java annotation processor not generating file in generated sources
I am writing a simple java annotation processor which generates a the java class using JavaPoet and then write it into the filer.
@AutoService(Processor.class)
public class ConfigProcessor extends AbstractProcessor {
private Types …

saurabh kumar
- 332
- 1
- 8
0
votes
1 answer
how Java annotation @Suppresswarnings works?
I have read Thinking in Java in which I know AnnotationProcessor use Reflection to resolve annotation.
After I dive into the source, I know this annotation's Retention Policy is Source. So I think maybe there's a Processor which get the String like…

jojo_007
- 115
- 1
- 5
0
votes
1 answer
JAXB marshalling @XmlElementRef name property not coming as Name
I am not getting name as tag name for @XmlElementRef.
Element declaration in parent elemnet:
@XmlElementRef(name = "Agents", type = JAXBElement.class, required = false)
protected JAXBElement agents;
Declaration of class…

paril
- 1,850
- 2
- 14
- 26
0
votes
0 answers
Could I pass annotation to child class which extends it?
I'm lazy person... i just want the simplest way, now i'm learning android room. This might be answered here "Why is it not possible to extend annotations in Java?", but it seems like to try pass annotation to another annotation, right? So, Could i…

Augustine Sena
- 9
- 1
- 5
0
votes
1 answer
get target element type of custom annotation
I have a custom annotation:
@Target({ElementType.METHOD}) // NOTE: ElementType is METHOD
public @interface MyAnnotation {
}
I have a generic class that takes a generic bounded type:
class MyWork {
T theAnnotation;
…

Leem.fin
- 40,781
- 83
- 202
- 354
0
votes
1 answer
No instance(s) of type variable(s) exist so that T conforms to Annotation
I am trying to write a generic function to find value of any given annotation. In code, instead of directly using abc.class (as a parameter) in method getAnnotation, I am using variable of type Class.
While doing so, following error is being…

user
- 383
- 1
- 5
- 20
0
votes
1 answer
Multiple @EnsuresNonNullIf should be ok; but the compiler complains
The manual of the Checker Framework claims "You can write multiple @EnsuresNonNullIf annotations on a single method", however I observe the following message if I try this:
@EnsuresNonNullIf(expression="getFieldNames()",…

Jurgen Vinju
- 6,393
- 1
- 15
- 26
0
votes
1 answer
Errors while binding a library with Java annotations
Fellow developers,
I'm binding this library:
https://github.com/leinardi/FloatingActionButtonSpeedDial
But I have faced two issues while generating the control:
The first one, I had an idea how to do it I added the following code in the…

Federico Navarrete
- 3,069
- 5
- 41
- 76
0
votes
0 answers
Execute callbacks on Annotated fields and methods in Java
In Java, I'd like to monitor state of annotated fields and method's return values.
How do I execute a callback on an annotated field value / method return values.
What I'm trying to do : Creating a custom debugger of a sort which would execute some…

Cybermonk
- 514
- 1
- 6
- 28
0
votes
1 answer
Java - Why annotation is not retained on local variable declaration in .class file?
I am reading the Java Reference by Herber Schildt. I found a note in one of the annotations section that says:
An annotation on a local variable declaration is not retained in the .class file.
Why annotation is not retained on local variable…

Stack Overflow
- 1
- 5
- 23
- 51
0
votes
1 answer
custom annotations && aspects error java.lang.IllegalArgumentException: error Type referred to is not an annotation type
I'm trying to make and aspect around a custom annotation.
I have this annotation:
@Target({ElementType.METHOD })
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface BatchControlAnnotation{
public Class> classType();
public…

Jose Miguel
- 355
- 2
- 6
- 18
0
votes
1 answer
How do I use a list of enums as parameters in MyBatis Spring Boot?
How do I use a List of enums as a parameter to a MyBatis query? I've created a type handler for it already and specified the mapped type as described in this other question. It is returning 0 count when it should be thousands.
@Mapper
public…

Chloe
- 25,162
- 40
- 190
- 357
0
votes
2 answers
Write a java file using JavaPoet in annotation processor
I am trying to use processingEnv.getFiler() to create a source file. But I don't see any source file getting created. Below is the code that I am using:
public void javaPoetEg() {
Filer filer = super.processingEnv.getFiler();
MethodSpec main =…

Ankit Shubham
- 2,989
- 2
- 36
- 61
0
votes
1 answer
How to set a double with Java Annotations
I am writing a custom module for use with Tridiums Niagara Framework version 4.3 and the defaultValue I am trying to set is giving the following error:
'class' or 'interface' expected error.
I've tried several different ways to set this and the…

Richard Farmer
- 1
- 1