Questions tagged [annotation-processing]
An annotation processor is a plug-in for the Java compiler. An annotation processor can do such things as analyze declarations, cause compilation errors and generate new compilation units.
730
questions
0
votes
0
answers
19
views
How does Hibernate check wheather of basic type attribute for @Entity is used or not?
I would like to repeat a behavior of annotations like @Entity in Hibernate, @Override, e.t.c, to display warnings in coding time:
I making the ORM library for working with Clickhouse DB, and i created ...
0
votes
1
answer
54
views
Can't find class in generated sources produced by custom annotation processor when running java program
I have written an annotation processor to generate classes to the generated sources directly during compilation. The class generates with valid syntax, and to the correct, matching (same as interface ...
2
votes
1
answer
25
views
javac command line `-Akey[=value]` args are not covered via javac plugins, only annotation processors. How best to address this?
Although the javac docs state the -Akey[=value] command line argument is designed for annotation processors, it applies to javac plugins as well; there doesn't appear to be a separate command line ...
0
votes
1
answer
43
views
Access interface of return value of enclosedElement in java annotationprocessor using TypeVisitor?
I'm currently building an annotation processor, and I want to filter all methods that return a record that implement a certain interface.
In the IntelliJ Debug window I can see that the restype ...
0
votes
0
answers
56
views
I can't import class that generated using annotation via databinding
I generated a class with below annotation generator.
@AutoService(Processor::class)
class GenerateSealedGettersProcessor : AbstractProcessor() {
override fun getSupportedAnnotationTypes(): ...
1
vote
1
answer
37
views
Java annotation processor comparing method return `TypeMirror` with known class
My Java annotation processor is generating an implementation of an interface, which has a MyInterface.foo() method returning CompletableFuture<String>. In my processor the ExecutableElement for ...
0
votes
0
answers
44
views
Java annotation processor Element AnnotationMirror for repeatable annotations
If I have an annotation @Schedule that is repeatable as described in the Java tutorial; and I call Element.getAnnotationMirrors(); will the list contain repeated annotations themselves (e.g. @Schedule ...
0
votes
0
answers
65
views
Compile code with generated source by annotation processor on Gradle
I extended the AbstractProcessor to create an annotation processor to generate a class in Java and it works fine.
The first issue is: the class only is generated for the second time I run ./gradlew ...
3
votes
1
answer
54
views
Java annotation processor check annotations of discovered type by class name
Let's say I have an annotation @Foo that indicates some other classes like this:
@Foo({Other.class, Another.class})
public class MyClass { …
…
}
I'm writing an annotation processor for Foo, and ...
1
vote
0
answers
30
views
Purpose of "originating elements" in Java annotation processing
Several Java annotation processing methods for creating files, such as createResouce(…), refer to "originating elements":
originatingElements - class or interface or package or module ...
0
votes
1
answer
84
views
Spring boot Gradle Build Java Compiler issue java.lang.IllegalStateException: endPosTable already set
I am facing java compiler issue while running gradle build. It passes when I rerun it locally. But I cannot rerun on jenkins and build always fails there.
gradle version : 6.9
java 1.8
spring boot : 2....
2
votes
2
answers
47
views
IntelliJ incremental Maven builds with annotations and APT
Gradle supports incremental annotation processing now, but I don't believe that helps those with Maven projects in IntelliJ. When I google on this I find a few references to IntelliJ and incremental ...
0
votes
0
answers
40
views
How to run a custom Java annotation processor locally with Gradle?
I have a custom annotation processor and would like to test it locally, but I'm having trouble configuring the annotation processor for this.
build.gradle
plugins {
id("java")
}
group = ...
1
vote
1
answer
63
views
Kotlin Poet ambigouos imports
Let's say I have two interfaces in a project:
interface InterfaceA {
// ...
interface Listener {
// ...
}
}
interface InterfaceB {
// ...
interface Listener {
// .....
-2
votes
1
answer
55
views
Annotation processor doesn't run
I wannna use annotation processor in my IDEA plugin, which will resolve classes and methods with 'TaskID' annotation. But I found that my processor can't run at all. I do wanna know what's wrong and ...
0
votes
1
answer
35
views
Eclipse/ SpringSTS Code assist very slow with Spring and Lombok.jar
So, first of all this happenes only with Java project where we use lombok.jar. The project has more than 1900 Java files. Now the problem comes when I hit [CTRL+SPACEBAR] on the keyboard, or when I ...
0
votes
0
answers
44
views
Trying to inject a certain value into a field with annotation without @Value
I just got into java annotation processing and I wanted to create an annotation that does a similar job to @Value.
I already created the annotation and annotation processor.
so is there a way to ...
-1
votes
1
answer
118
views
CustomValue Annotation Processing : How can i create a similar annotation of @Value
I have just started using annotation processing and trying to inject the value on the field annotated with my annotation . Since yesterday I am facing this error message: Compilation failure
I have ...
0
votes
1
answer
104
views
Unresolved reference when trying to use annotations
I'm facing an issue in my Android project where I'm trying to use annotations defined in Module B in my code within Module C. However, I'm getting an "Unresolved reference" error in Android ...
2
votes
0
answers
73
views
How to trigger Java annotation processor in a Kotlin project?
I have a Kotlin Multiplatform project built with Gradle (.kts). One of the targets is jvm().
For that target I also have a Java library with custom annotations that I need to use. However, when I just ...
1
vote
1
answer
196
views
Mapstruct uses not working, how to make mapstruct "uses" use other mapper for inner fields
Mapstruct "uses" not working, it maps all entities in one mapper, instead of using different mappers for different entities
I have pom
`<plugin>
<groupId>org.apache....
1
vote
2
answers
531
views
Maven compiler plugin: Annotation processor not found
I have a Maven java project which includes a custom annotation processor:
@SupportedAnnotationTypes("com.example.Processor")
@SupportedSourceVersion(SourceVersion.RELEASE_17)
public class ...
0
votes
0
answers
16
views
Is the annotationType of an AnnotationMirror associated with the wrong module by javac?
Suppose I have the following in some unit test code somewhere, patched into a module named com.foo.main (name doesn't matter, only that this test code is running as part of a module):
@org.junit....
0
votes
0
answers
24
views
AnnotationProcessor (Checker Framework) in Executions Block
I am trying to add the CheckerFrameworks annotation processing to an already existing maven project.
In this project, most settings are included in module-specific profiles. If I just add the Checker ...
0
votes
0
answers
21
views
Possible to automatically generate a custom composite annotation for use on a Java Entity field containing a populated @Column annotation
Due to a bug in liquibase-hibernate Java Bean Validation constraint annotations (e.g @NotNull, @Size) on Java Entity classes are not being mapped to any generated Liquibase changelogs:
https://github....
0
votes
0
answers
30
views
how to debug a java abstractProcess using vscode
I created an abstractProcess to generate a code when a Pojoproperty is annotated with my custom annotation and I save it.
I have two projects:
a project called MyAbstractProcessProject that has an ...
0
votes
0
answers
33
views
Cannot build being Class Annotation Processor
I have a Project with the following structure:
Annotation Format
package io.tholv.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang....
0
votes
1
answer
217
views
gradle use project as its own annotation processor
I'm making a library that includes an annotation processor
.
├── lib
│ ├── build.gradle
│ └── src
│ ├── main
│ │ ├── java
│ │ │ └── demo
│ │ │ ├── ...
2
votes
0
answers
363
views
Control output folder and source set for a KSP annotation processor
In an Android project (native with mixed java / kotlin) we are using a KSP based annotation processor to collect class definitions that are annotated with a specific project internal annotation. All ...
0
votes
1
answer
78
views
AnnotationProcessor in mixed java/kotlin Android project does not process kotlin class
In an Android project (native with mixed java / kotlin) we use a simple annotation processor to generate a class in our build process. That generated class contains all Activity classes in the project ...
0
votes
1
answer
176
views
Why annotation processor doesn't work with Maven and java11?
I'm migrating a Java webapp from Java8 to Java17.
This project uses this very nice solution to embed strings (ex. SQL queries) in constanst:
https://github.com/adrianwalker/multiline-string
This ...
0
votes
1
answer
363
views
How does @NotNull add itself in IntelliJ IDEA?
This sample program exhibits the behavior I do not understand:
public class Main {
public static String foo(String value) {
return "length: " + value.length();
}
public ...
-1
votes
1
answer
104
views
Java annotation implementation logic
I want to know how Java generates annotation implementation like @Mapper and @FeignClient. Does It generates an implementation class in runtime?
Thanks.
Know how Java generates an implementation for ...
0
votes
0
answers
32
views
Scan a super method definition from TreeScanner.visitMethodInvocation
Given the following class hierarchy
public AClass {
String getSomething() { ... }
}
public BClass extends AClass {
@Override
@CustomAnnotation
String getSomething() { super.getSomething(); ...
1
vote
1
answer
124
views
How to get intellij idea to recognise methods generated by my annotation processor
I have created a multi module project namely App and Mods, App contains the main method and Mods contains the annotation and its annotation processor.
Project Structure
I have used the annotation on a ...
0
votes
1
answer
76
views
Named fields for another class
I need to access some private fields via reflection. While this is considered bad, it is an external library and I have no other way to access it. The field names (and types) are known in advance (...
1
vote
0
answers
189
views
Vscode not showing java annotation processor warnings in source code
I am developing a java project requiring the use of annotation processors using maven in VS Code. I set up two maven projects, one containing the main project and one containing the annotations. When ...
4
votes
4
answers
4k
views
kotlin-kapt plugin with version catalogs
I have migrated my build to use version catalogs.
I have removed the following from my build.gradle
plugins {
id 'kotlin-android'
id 'kotlin-kapt'
}
and
kapt "androidx.room:room-compiler:$...
0
votes
2
answers
161
views
IntelliJ enables annotation processing every time the gradle project is refreshed
I am building and running my project using IntelliJ IDEA and not Gradle.
In Build, Execution, Deployment > Compiler > Annotation Processors, I have two profiles: Default and Gradle Imported. I ...
0
votes
0
answers
62
views
Annotation processor cannot get annotation for type variable
This method:
public static <T, @Nullable R> void foo(@Nullable Object obj, T t, @Nullable List<? extends @Nullable R> r)
annotationProcessor (by gradle) cannot read the @Nullable for R (...
0
votes
0
answers
66
views
Need help grouping annotated classes in Android Kotlin project
I'm currently working on a project where I need to group classes annotated with the @MainType and @SubType annotations. The @MainType annotation is applied to the superclass, while the @SubType ...
0
votes
0
answers
370
views
Getting access to com.sun.tools.javac with Java 8+
I have been trying to do something like The Lombok Project and tried to make com.sun.tools.javac visible but everything I tried didn't work out.
Tried compiler args in build.gradle
compileJava{
...
0
votes
0
answers
106
views
Set class field using class annotation in spring component context at class initialization
I try to set a class field of an abstract superclass by setting the value from a custom annotation defined on the subclass. The subclass is declared as Spring @Component, and the field has to be set ...
0
votes
1
answer
80
views
How to find an anonymous class in the annotation processing environment?
I'm writing an annotation processor with Java 8.
Let's say I have a class like this somewhere in my project:
public class SampleClass {
public void foo(int i) {
new Runnable() {
...
1
vote
1
answer
124
views
Run Annotation Processor in Eclipse when an Annotation is removed
I've written an annotation processor that simply dumps the list of annotated classes to a text file. To accommodate incremental builds in Eclipse, it also attempts to re-read the file and checks if ...
1
vote
0
answers
117
views
Gradle annotation processor with ECJ compiler produces "Unable to get public no-arg constructor" error
I'm trying to compile a gradle project with the ECJ compiler. I have an annotation processor in one of the projects, that the other projects depend on.
When ECJ attempts to run the annotation ...
3
votes
1
answer
97
views
A @Target-less annotation cannot be applied to a type parameter declaration in Java 19: why not?
Section 9.6.4.1 of the Java Language Specification version 19 lists all declaration contexts in the Java language. One of those declaration contexts is "Type parameter declarations of generic ...
1
vote
0
answers
420
views
Maven compile kotlin and java with generated sources
I have a kotlin project in which some code is generated using Annotation Processing (AbstractProcessor). The generated code is in java and is generated into
./target/generated-sources/annotations
...
0
votes
1
answer
799
views
Gradle Annotation Processor dependency
General idea:
I want to build a simple annotation processor on Gradle and Java 17 (Gradle 7.5, Java 17.0.6). And use it in another project with the same setup.
here is my code:
annotation-processor ...
1
vote
0
answers
231
views
IntelliJ is not recognizing annotation-generated class files
I have a custom annotation in Java, that uses ByteBuddy to generate a new class based on the annotated one. Since ByteBuddy is already compiling the class, I am outputting the bytecode directly, ...