flow
flow copied to clipboard
Vaadin Maven plugin is incompatible with projects that use --enable-preview
Description of the bug
The Vaadin plugin task com.vaadin:vaadin-maven-plugin:24.7.0:build-frontend will fail at build time if you build your Java project using --enable-preview.
The exception looks like this:
Caused by: java.lang.NullPointerException: Cannot invoke "java.lang.Class.isInterface()" because the return value of "org.reflections.Reflections.forClass(String, java.lang.ClassLoader[])" is null
at org.reflections.Reflections.lambda$getTypesAnnotatedWith$12 (Reflections.java:405)
at java.util.stream.ReferencePipeline$2$1.accept (ReferencePipeline.java:196)
at java.util.Iterator.forEachRemaining (Iterator.java:133)
at java.util.Spliterators$IteratorSpliterator.forEachRemaining (Spliterators.java:1939)
at java.util.stream.AbstractPipeline.copyInto (AbstractPipeline.java:570)
at java.util.stream.AbstractPipeline.wrapAndCopyInto (AbstractPipeline.java:560)
at java.util.stream.ReduceOps$ReduceOp.evaluateSequential (ReduceOps.java:921)
at java.util.stream.AbstractPipeline.evaluate (AbstractPipeline.java:265)
at java.util.stream.ReferencePipeline.collect (ReferencePipeline.java:727)
at org.reflections.util.QueryFunction.lambda$filter$3 (QueryFunction.java:32)
at org.reflections.util.QueryFunction.lambda$add$9 (QueryFunction.java:66)
at org.reflections.util.QueryFunction.lambda$add$9 (QueryFunction.java:66)
at org.reflections.util.QueryFunction.lambda$asClass$13 (QueryFunction.java:89)
at org.reflections.Reflections.get (Reflections.java:365)
at org.reflections.Reflections.getTypesAnnotatedWith (Reflections.java:403)
at com.vaadin.flow.server.scanner.ReflectionsClassFinder.getAnnotatedClasses (ReflectionsClassFinder.java:91)
at com.vaadin.flow.server.frontend.scanner.FrontendDependencies.collectEntryPoints (FrontendDependencies.java:461)
at com.vaadin.flow.server.frontend.scanner.FrontendDependencies.<init> (FrontendDependencies.java:163)
at com.vaadin.flow.server.frontend.scanner.FrontendDependenciesScanner$FrontendDependenciesScannerFactory.createScanner (FrontendDependenciesScanner.java:106)
This stackoverflow question gives a good explanation as to what's going on.
Basically, the Vaadin plugin barfs when introspecting classes that have been compiled with --enable-preview.
The plugin needs to be more robust. Ideally, it should not try to instrospect classes by loading them into the build JVM which creates incompatibility issues; instead it should read them as regular data files like Spring does.
Expected behavior
Successful build.
Minimal reproducible example
Should be easy to reproduce: add --enable-preview to compiler flags and use any preview feature in one of your classes.
Versions
- Vaadin / Flow version: 24.7.0
- Java version: 24
- OS version: Mac OS