atteo / classindex

Index classes, do not scan them!
Apache License 2.0
263 stars 43 forks source link

Internal error: Unknown element: "number" #80

Open AttiliaTheHun opened 7 months ago

AttiliaTheHun commented 7 months ago

In my project (a JavaFX desktop app) I use the version 3.4 of ClassIndex. When I try to build my project in IntelliJ, I get this message java: [ClassIndexProcessor] Internal error: Unknown element: "number" which I traced to ClassIndexProcessor#process(Set<? extends TypeElement>, RoundEnvironment) but do not really understand.

My use case of ClassIndex library is to automatically load my Plugin classes that have the @AutoRegister annotation.

AutoRegister.java excerpt

@IndexAnnotated
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE})
public @interface AutoRegister { }

The only interaction with the library beside that is here in my PluginManager:

PluginManager.java excerpt

private void autoRegisterPlugins() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
        Iterable<Class<?>> autoRegisterPlugins = ClassIndex.getAnnotated(AutoRegister.class);

        for (final Class c : autoRegisterPlugins) {
            System.out.println(c.getSimpleName());
            if (c.getSuperclass() != null && c.getSuperclass().equals(Plugin.class)) {
                ((Plugin)c.getMethod("getInstance").invoke(null)).register();
            }
        }
    }

However from my understanding of compile-time annotation processing, this code never even gets executed (so I do not really know if it works lol) and so the problem can not be in my code, but somewhere within the library or my environment.

As mentioned, my environment is Windows 10, IntelliJ somewhere from 2021 I think and Java 19. My current course of action would be to try to implement the functionality myself as I do not require all the features of the library.