On Tue, 28 Apr 2026 04:44:23 GMT, Jaikiran Pai <[email protected]> wrote:
>> Volkan Yazici has updated the pull request incrementally with one additional
>> commit since the last revision:
>>
>> Add `ofString` static factory method
>
> src/java.base/share/classes/javax/net/ssl/SNIHostName.java line 132:
>
>> 130: IDN.USE_STD3_ASCII_RULES))
>> 131: .getBytes(StandardCharsets.US_ASCII));
>> 132: checkHostName(strict);
>
> With the newer relaxed rules for constructors which allows for additional
> methods to be called before the `super`, could this `checkHostName` method be
> made static and pass it the `hostname` to verify? That way, we could then
> call checkHostName before calling super? Something like the following (I
> haven't tried to see if it compiles):
>
>
> private SNIHostName(final String hostname, final boolean allowIPLiteral) {
> Objects.requireNonNull(hostname, "Server name value of host_name cannot
> be null");
> // `IDN::toASCII` throws `IllegalArgumentException` on illegal input
> final String asciiHostName = IDN.toASCII(hostname,
> IDN.USE_STD3_ASCII_RULES);
> checkHostName(asciiHostName, allowIPLiteral);
> super(StandardConstants.SNI_HOST_NAME,
> asciiHostName.getBytes(StandardCharsets.US_ASCII));
> }
>
> private static checkHostName(final String hostname, final boolean
> allowIPLiteral) {
> ...
> }
I had already implemented this, pushed it in 9596a5b2ca0.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/30747#discussion_r3153703845