jvm-operators / abstract-operator

Library/SDK for creating the operators for Kubernetes and Openshift.
Apache License 2.0
60 stars 17 forks source link

Java 12 and Operator detection #46

Open despondency opened 5 years ago

despondency commented 5 years ago

It appears that using Java 12, Reflections library does not detect the @Operator'ed class and says there are none. Any ideas? Probably Reflections does not support Java 12?

Best,

Mario

jkremser commented 5 years ago

Mario, abstract operator uses this Java library for finding all annotated classes. If I recall correctly, the library also has a feature for finding all the sub-classes of a certain class at run-time, and it should be also turned on in the abstract operator . This way one can create a operator in languages that doesn't support java annotations, like JavaScript (example).

Could you please provide a reproducer for this? Were you doing some module optimization with jlink? If I am not mistaken, reflection in some form should be still there in Java 12. However, there were some changes in the recent versions of Java so it is possible that the https://github.com/ronmamo/reflections may not work as expected in the newest Java.

It's possible that in the future, we will migrate to https://github.com/classgraph/classgraph or some other mechanism that actually also works for the native images in Graal VM.

despondency commented 5 years ago

Jiri,

The reproducing case is, just use openjdk 12 and you will see that the @Operator annotation is not getting scanned by the Reflections library, even though the class is extending AbstractOperator and has @Operator on it. Looking it through the debugger it just returns 0 as the List size for classes which are subclassing AbstractOperator and are annotated with @Operator.

Best,

Mario