datagramchannel on a specified port - API change?

With the 1.4.0 API you could specifiy a port to open a DatagramChannel on by calling the static method DatagramChannel.open(port)
http://www.infres.enst.fr/docs/jdk1.4.0/api/java/nio/channels/DatagramChannel.html#open(int)

Apparently, this method is no longer around in 1.4.1
http://java.sun.com/j2se/1.4.1/docs/api/java/nio/channels/DatagramChannel.html

What is the methodology for opening one, and how does something disappear from the API like that?

{grumble grumble}

the syntax for this is apparently


channel = DatagramChannel.open();
channel.socket().bind(new InetSocketAddress(port));

Still irks me though :stuck_out_tongue:

It not in the 1.4 JavaDocs on sun’s site:
http://java.sun.com/j2se/1.4/docs/api/java/nio/channels/DatagramChannel.html
and I cracked open the DatagramChannel class from a 1.4.0 jre and it didn’t have that method. You sure those are accurate JavaDocs over at www.infres.enst.fr (You know you can’t trust those crazy french :))

I’m rather sure you can do what you want by getting the java.net.DatagramSocket from DatagramChannel.socket() and callling DatagramSocket.bind(SocketAddress)

It was also in some NIO tutorial code I googled up (the reason I was doing it this way in the first place). Other than that, I don’t know why someone would fake javadocs – quite a mystery :o

That methodology was something that you could do in the early beta’s of NIO, but not something you can do in the final or later.