Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
package todo;
import javax.annotation.processing.*;
import javax.lang.model.SourceVersion;
import javax.lang.model.element.Element;
import javax.lang.model.element.TypeElement;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.Set;
public class ToDoProcessor extends AbstractProcessor {
public boolean process(Set<? extends TypeElement> typeElements, RoundEnvironment roundEnv) {
Messager messager = super.processingEnv.getMessager();
for (TypeElement typeElement : typeElements) {
Set<? extends Element> elements = roundEnv.getElementsAnnotatedWith(typeElement);
for (Element element : elements) {
ToDo todo = element.getAnnotation(ToDo.class);
messager.printMessage(Kind.WARNING, "@ToDo at " + element + " : " + todo.message());
LocalDate expirationDate = LocalDate.parse(todo.expiration(), DateTimeFormatter.ofPattern("yyyyMMdd"));
if ( {
messager.printMessage(Kind.ERROR, "ToDoの対応期限が切れています。対応期限" + expirationDate, element);
return true;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment