hg: jdk7/jsn/jdk: 6717876: Make java.net.NetworkInterface.getIndex() public

Jean-Christophe Collet Jean-Christophe.Collet at Sun.COM
Thu Aug 28 04:02:27 PDT 2008


Andrew John Hughes wrote:
> On 27/08/2008, Mark Wielaard <mark at klomp.org> wrote:
>   
>> Hi,
>>
>>
>>  On Mon, Aug 25, 2008 at 12:43:59PM +0000, jean-christophe.collet at sun.com wrote:
>>  > URL:       http://hg.openjdk.java.net/jdk7/jsn/jdk/rev/f4289d75cd29
>>  >
>>  > 6717876: Make java.net.NetworkInterface.getIndex() public
>>  > Summary: Make getIndex() and getByIndex() public. Required a name change in native code
>>  > Reviewed-by: alanb, chegar, michaelm
>>
>>
>> This seems to introduce a new public API in the java.net package.
>>  I was wondering how that works for someone that wants to introduce
>>  such things in openjdk. I do see the bug report that mentions making
>>  this public should be done for JDK7. But there seems to missing a real
>>  justification for adding these new interfaces. Is there any policy for
>>  introducing such new public interfaces?
>>
>>  I might be reading this wrongly but it seems the only thing this API
>>  does is expose some random internal "index" numbers for an
>>  NetworkInterface. Seeing that there are no guarantees on whether there
>>  are index numbers in the first place for any or all interfaces it seems
>>  not that useful imho. An example of how an application would use this
>>  new interface would be nice to get a better idea in what situations
>>  this would be used.
>>
>>  Thanks,
>>
>>
>>  Mark
>>
>>     
>
> I also thought the change was odd, given it adds two methods based on
> otherwise undefined 'system specific' values.  From the methods given,
> there is no information as to how many of these index numbers are in
> use.  The only way I can see to enumerate them is to get all instances
> of NetworkInterface and call getIndex() on each.  I assume that the
> application of these methods is to resolve ambiguity between two
> interfaces with the same name but a different index, but it would be
> more helpful if the Javadoc included example usage and some
> information on what these numbers might be.
>
> More generally, it's not clear where the decision was made to make
> this part of the (as yet non-existent) JDK7 platform JSR.  Will there
> be more insight into this process from outside Sun in the near future

A network interface index is hardly a "random internal number".
This is a value attributed by the operating system and is as significant 
as an interface name.
The reason it was made public is because it's an information that is 
needed by other APIs (like NIO) and applications.
An example is that such an index can be used inside an IPv6 address to 
force routing through a specific interface.
There are multiple, legitimate, uses of an interface index.
Initially these 2 methods were kept private because of some security 
concerns. After consideration and maturation of  the NetworkInterface 
class, these concerns were deemed not justified any longer.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: jean-christophe_collet.vcf
Type: text/x-vcard
Size: 256 bytes
Desc: not available
Url : http://mail.openjdk.java.net/pipermail/net-dev/attachments/20080828/b53892b7/jean-christophe_collet.vcf 


More information about the net-dev mailing list