[JAVA] I'm stuck trying to get my own annotations working in Eclipse

I made a note when I tried to make my own annotation process and make it work in Eclipse.

environment

Java

openjdk 10.0.2

Eclipse

Photon (4.8.0)Pleiades All in One

OS

Windows 10

Premise

See Pluggable Annotation Processing API Usage Memo-Qiita for an explanation of the annotation processing itself and how to run it in Eclipse.

Load fails

Symptoms

apt.jpg

I get the error "The annotation processor factory ... could not be loaded" in the project that set the annotation process. I was at a loss because I didn't know what was going on because I didn't have detailed information.

Cause

--The version of the JVM running Eclipse is older than the code that wrote the annotation process. ――After trying various things, the annotation process got stuck even in the old version of Eclipse. --In that Eclipse, a detailed error message was displayed and the error "Unsupported major.minor version xxx" occurred. --Since the Java version used in the project was the same, I noticed that the program running the annotation processing = Eclipse's JVM version seems to be the cause.

Check the version of the JVM running Eclipse

--Launch the command line on the machine running Eclipse and run jcmd

> jcmd
6184 sun.tools.jcmd.JCmd
18860

--Eclipse Java process that only outputs the process ID --Output VM.version with this process ID as an argument

> jcmd 18860 VM.version
18860:
Java HotSpot(TM) 64-Bit Server VM version 25.162-b12
JDK 8.0_162

You can see that it works at ―― 8.

How to respond

--Run Eclipse on a version of Java that is compatible with the version of the annotation processing code

NoClassDefFoundError occurs

Status

--Attempted to automatically generate source code using JavaPoet during annotation processing

Symptoms

apt.jpg

apt.jpg

--The JavaPoet class used in the annotation process cannot be found and results in NoClassDefFoundError.

Cause

--A library that depends on the factory path is not added in the annotation processing settings of Eclipse.

How to respond

--Add the library used during annotation processing (JavaPoet in this case) to the factory path as well.

apt.jpg

Recommended Posts

I'm stuck trying to get my own annotations working in Eclipse
I tried to summarize object orientation in my own way.
What to do if you get a JNI shared library error when trying to build in Eclipse
A funny story stuck in a mess when trying to import fx-clj
A solution to Docker errors that beginners tend to get stuck in
I got stuck trying to write a where in clause in ActiveRecord
How to run JUnit in Eclipse
How to get parameters in Spark
Handle your own annotations in Java
How to set Lombok in Eclipse
Get stuck in a Java primer
[Java Spring MVC] I want to use DI in my own class
How to create your own annotation in Java and get the value