On Mon, 16 May 2022 10:31:25 GMT, Pavel Rappo <pra...@openjdk.org> wrote:
>> Please review a small fix to address use of snippets in source code in the >> unnamed package. >> >> The core of the fix is to replace `packageName(pkg, utils)` (which returns >> `"<Unnamed>"` for the unnamed package) with plain old >> `pkg.getQualifiedName().toString()` (which returns an empty string for the >> unnamed package.) >> >> There's some minor localized cleanup and rearrangement as well. >> >> The test verifies behavior without and then with a source path, since that >> is the likely path of discovery by a user playing with the unnamed package. > > test/langtools/jdk/javadoc/doclet/testSnippetTag/TestSnippetUnnamedPackage.java > line 82: > >> 80: >> 81: javadoc(args.toArray(String[]::new)); >> 82: checkExit(useSourcePath ? Exit.OK : Exit.ERROR); > > Thanks for taking into account our discussion in #8583. > > On the one hand, this way of conditionally adding an option is more mouthful. > On the other hand, it doesn't make a first-time reader scratch their head and > makes for a cleaner test. Going forward, how about an `Args` builder, with fluent methods `add(String)`, `addAll(String...)`, `addAll(List<String>)` and `add(Optional<String>)` ... although that last one will cause warnings from javac which grumbles about using `Optional` as a parameter type. Instead of using `Optional`, we could have overloads `addIf(boolean, String)` etc. I'm open to suggestions for a better/neater methodology here. ------------- PR: https://git.openjdk.java.net/jdk/pull/8708