David M. Lloyd wrote:
:
No, the concern is just that the SocketAddress hierarchy is just kind
of broken (the indicators are the fact that it's an empty abstract
class, and that anywhere it's used, it's immediately casted to a more
specific type). You could change this, but it still seems to me like
a kneejerk "make it look like Unix" kind of thing to do.
Doing this: UnixSocketChannel.open(String) or similar seems more
correct to me. If you go the route of using
SocketChannel.open(SocketAddress), for example, now you've got
instanceof checks for each socket type. Does this not seem like a
so-called "code smell" to you?
SocketAddress has existed for a long time (1.4). Jessie may be able to
provide more background.
When I mentioned adding support for other protocols in SocketChannel
then it involved new factory methods that selected the appropriate
SocketChannel or ServerSocketChannel to return based on the protocol
(and optionally the protocol family). This isn't too differ from the
factory method you are suggesting except that there isn't a new channel
type.
-Alan.