7197637: (ch) sun.nio.ch.Default* cause providers for other platforms to be included in rt.jar

Mandy Chung mandy.chung at oracle.com
Wed Sep 12 10:23:10 PDT 2012



On 9/11/2012 7:40 AM, Alan Bateman wrote:
>
> sun.nio.ch.DefaultSelectorProvider and 
> DefaultAsycnhronousChannelProvider select the appropriate provider 
> based on the OS. As there are static references to each of the 
> provider classes it means the classes for other platforms get compiled 
> implicitly and so there are additional classes in rt.jar that are 
> never used. The real issue here is that we don't separate Solaris and 
> Linux specific code and this is something that I think that we will 
> need to addressed some day. In the mean-time I've changed the create 
> methods to use reflection, in the same way that we already have in 
> sun.nio.fs.DefaultFileSystemProvider.
>
> Mandy - while I was there I also changed the class loader specified to 
> Class.forName to be the defining loader of the Default* class, this 
> change has no effect for now but may avoid us needing to change this 
> again when we eventually move to modules.
>
> The webrev with the proposed changes is here:
>
> http://cr.openjdk.java.net/~alanb/7197637/webrev/
>

Looks good to me.

It's good to avoid compiling platform-dependent classes that are not 
target for the target platform.    Like you said, it'd be good to 
resolve the real issue and separate the platform-dependent code rather 
than using reflection to avoid classes compiled implicitly.  That'd be 
work for another day.

It's also good cleanup remove the conditional test in 
DefaultSelectorProvider.java of the linux kernel version as that's our 
supported configuration.

Mandy


More information about the nio-dev mailing list