Clone of https://github.com/openjdk/jdk/pull/30110, original description:
As part of @david-beaumont's work on https://github.com/openjdk/valhalla/pull/2180, it turned out warnings are sometimes reported to a wrong file when annotation processors are present, and, as a consequence, these warnings are not properly suppressed by @SuppressWarnings. The reason is simple: the log.useSource is misplaced, and the source in the Log may not be correctly reset. The source is correctly reset if tree == null, which is the normal case without annotation processing. But with annotation processing combined with implicit compilation, tree != null, and the source is never reset to the original value. And subsequent diagnostic then may be assigned to a wrong file. This PR is moving setting the source to the correct place. Note that for testCorrectSource, there are multiple warnings printed. This is an pre-existing problem that is sadly harder to fix albeit hopefully with a smaller severity. I think it would be better tackled separately. I've filled https://bugs.openjdk.org/browse/JDK-8378950 for it. ------------- Commit messages: - 8378740: Suppressed warnings reported when implicit compilation is combined with annotation processing Changes: https://git.openjdk.org/valhalla/pull/2221/files Webrev: https://webrevs.openjdk.org/?repo=valhalla&pr=2221&range=00 Issue: https://bugs.openjdk.org/browse/JDK-8379906 Stats: 166 lines in 2 files changed: 164 ins; 1 del; 1 mod Patch: https://git.openjdk.org/valhalla/pull/2221.diff Fetch: git fetch https://git.openjdk.org/valhalla.git pull/2221/head:pull/2221 PR: https://git.openjdk.org/valhalla/pull/2221
