desruisseaux commented on code in PR #959:
URL:
https://github.com/apache/maven-compiler-plugin/pull/959#discussion_r2405575694
##########
src/main/java/org/apache/maven/plugin/compiler/ToolExecutor.java:
##########
@@ -254,26 +260,21 @@ protected ToolExecutor(final AbstractCompilerMojo mojo,
DiagnosticListener<? sup
/*
* Get the dependencies. If the module-path contains any automatic
(filename-based)
* dependency and the MOJO is compiling the main code, then a warning
will be logged.
- *
- * NOTE: this code assumes that the map and the list values are
modifiable.
- * This code performs a deep copies for safety. They are unnecessary
copies when
- * the implementation is
`org.apache.maven.impl.DefaultDependencyResolverResult`,
- * but we assume for now that it is not worth an optimization. The
copies also
- * protect `dependencyResolution` from changes in `dependencies`.
*/
dependencyResolution = mojo.resolveDependencies(hasModuleDeclaration);
if (dependencyResolution != null) {
dependencies.putAll(dependencyResolution.getDispatchedPaths());
- dependencies.entrySet().forEach((e) -> e.setValue(new
ArrayList<>(e.getValue())));
+ copyDependencyValues();
}
mojo.resolveProcessorPathEntries(dependencies);
}
/**
- * {@return the source files to compile}.
+ * Copies all values of the dependency map in unmodifiable lists.
+ * This is used for creating a snapshot of the current state of the
dependency map.
*/
- public Stream<Path> getSourceFiles() {
- return sourceFiles.stream().map((s) -> s.file);
+ private void copyDependencyValues() {
+ dependencies.entrySet().forEach((entry) ->
entry.setValue(List.copyOf(entry.getValue())));
Review Comment:
An immutable list was intended here, and this behaviour is documented in the
Javadoc of this method. This is done in a context where we ensure that map
entries are frozen before to take a snapshot of the map.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]