Please review this small fix.

**Problem:**

`Statement.targets` is a `LinkedHashSet`, so duplicate targets in directives 
such as `exports p1 to m1, m2, m1;` are silently ignored. As a result, 
`GenModuleInfoSource` accepts invalid input instead of reporting an error.

**Fix:**

Use a local `HashSet` while parsing each directive and report an error when 
`add()` returns `false`.

**Testing:**

- Added tests for duplicate targets in `exports`, `opens`, and `provides`, 
`ModuleInfoExtraTest`: passed



---------
- [x] I confirm that I make this contribution in accordance with the [OpenJDK 
Interim AI Policy](https://openjdk.org/legal/ai).

-------------

Commit messages:
 - 8371851: Build tool GenModuleInfoSource does not report duplicate targets of 
export

Changes: https://git.openjdk.org/jdk/pull/32698/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=32698&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8371851
  Stats: 21 lines in 2 files changed: 17 ins; 0 del; 4 mod
  Patch: https://git.openjdk.org/jdk/pull/32698.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/32698/head:pull/32698

PR: https://git.openjdk.org/jdk/pull/32698

Reply via email to