On Thu, 30 Mar 2023 16:42:45 GMT, Varada M <[email protected]> wrote:
>> src/jdk.net/aix/classes/jdk/net/AIXSocketOptions.java line 38:
>>
>>> 36: class AIXSocketOptions extends PlatformSocketOptions {
>>> 37:
>>> 38: public AIXSocketOptions() {
>>
>> It would be good to make this package private constructor instead of
>> `public`, but I see that the current existing `LinuxSocketOptions` class too
>> uses `public`.
>
> `newInstance("jdk.net.AIXSocketOptions")` will try to invoke the default
> constructor `AIXSocketOptions() {}`. When we make it as private constructor
> PlatformSocketOptions instance will try to find jdk.net.AIXSocketOptions and
> within the time span it won't be able to find hence throws error (`Cannot get
> VM for test: java.net.SocketTimeoutException: Accept timed out`)
Hello Varada,
I went back and looked at how this class instance gets instantiated. The code
uses reflection to do it:
private static PlatformSocketOptions newInstance(String cn) {
Class<PlatformSocketOptions> c;
try {
c = (Class<PlatformSocketOptions>)Class.forName(cn);
return c.getConstructor(new Class<?>[] { }).newInstance();
so yes, this expects a `public` constructor and that explains why the existing
`LinuxSocketOptions` has a public constructor.
What you have right now, in this class, looks fine to me then.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13240#discussion_r1153924822