ChrisHegarty commented on code in PR #12677: URL: https://github.com/apache/lucene/pull/12677#discussion_r1359852957
########## lucene/core/src/java/org/apache/lucene/internal/vectorization/VectorizationProvider.java: ########## @@ -120,24 +124,21 @@ static VectorizationProvider lookup(boolean testMode) { } else if (runtimeVersion >= 22) { LOG.warning( "You are running with Java 22 or later. To make full use of the Vector API, please update Apache Lucene."); - } else if (vectorModulePresentAndReadable()) { + } else if (lookupVectorModule().isPresent()) { LOG.warning( "Java vector incubator module was enabled by command line flags, but your Java version is too old: " + runtimeVersion); } return new DefaultVectorizationProvider(); } - private static boolean vectorModulePresentAndReadable() { - var opt = - ModuleLayer.boot().modules().stream() - .filter(m -> m.getName().equals("jdk.incubator.vector")) - .findFirst(); - if (opt.isPresent()) { - VectorizationProvider.class.getModule().addReads(opt.get()); - return true; - } - return false; + /** + * Looks up the vector module from Lucene's {@link ModuleLayer} or the root layer (if unnamed). + */ + private static Optional<Module> lookupVectorModule() { + return Optional.ofNullable(VectorizationProvider.class.getModule().getLayer()) + .orElse(ModuleLayer.boot()) + .findModule("jdk.incubator.vector"); Review Comment: > The main reason for this PR was also to not apply the addReads as side effect of the module lookup ++ -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org