The example in the class description of `DrbgParameters.Capability` does not 
compile as written.

This patch fixes two issues in the Javadoc example:

- `DrbgParameters(-1, requested, null)` → `DrbgParameters.instantiation(-1, 
requested, null)`.
  The constructor is private; `instantiation()` is the factory method used by 
every other
  example in this file.
- `(DrbgParametes.Initiate)` → `(DrbgParameters.Instantiation)`. Class name 
typo and a
  nested type that does not exist.

Javadoc-only change; no behavior change.

### Testing

Copied the example into a standalone program and ran it on JDK 27 (build 27+35) 
for all
three `Capability` values.

Original snippet fails to compile:
    error: cannot find symbol  method DrbgParameters(int,Capability,<null>)
    error: package DrbgParametes does not exist

Corrected snippet compiles and the effective capabilities match the table in 
the Javadoc:
    PR_AND_RESEED -> PR_AND_RESEED
    RESEED_ONLY   -> RESEED_ONLY    NONE          -> RESEED_ONLY   (one of the 
allowed values for NONE)

<details>

 ```java
import java.security.DrbgParameters;
import java.security.DrbgParameters.Capability;
import java.security.SecureRandom;

public class CapabilityExample {
    public static void main(String[] args) throws Exception {
        for (Capability requested : Capability.values()) {
            SecureRandom s = SecureRandom.getInstance("DRBG",
                    DrbgParameters.instantiation(-1, requested, null));
            Capability effective = ((DrbgParameters.Instantiation) 
s.getParameters())
                    .getCapability();
            System.out.println(requested.name() + " -> " + effective.name());
        }
    }
}

</details>

Discussion: 
https://mail.openjdk.org/archives/list/[email protected]/thread/U24LZRYEMIUT5PIQ6OJZVOKO4Y4G2BJ3/

@wangweij Could you take a look? Thanks!

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

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

Commit messages:
 - 8392624: Example in DRBGParameters.Capability class description has typo and 
is incorrect

Changes: https://git.openjdk.org/jdk/pull/33086/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=33086&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8392624
  Stats: 3 lines in 1 file changed: 0 ins; 0 del; 3 mod
  Patch: https://git.openjdk.org/jdk/pull/33086.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/33086/head:pull/33086

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

Reply via email to