Adding values to enum java.net.StandardProtocolFamily
Can we add further enumeration values to java.net.StandardProtocolFamily? The spec does not say so, unlike javax.lang.model.SourceVersion, and the code in the JDK expects a binary flag, so I think the answer is "no". Does this mean the expected way to add support for further protocol families would be to create a separate implementation of java.net.ProtocolFamily? -- Florian Weimer / Red Hat Product Security Team
Re: Adding values to enum java.net.StandardProtocolFamily
On 13/02/2014 12:54, Florian Weimer wrote: Can we add further enumeration values to java.net.StandardProtocolFamily? The spec does not say so, unlike javax.lang.model.SourceVersion, and the code in the JDK expects a binary flag, so I think the answer is "no". Does this mean the expected way to add support for further protocol families would be to create a separate implementation of java.net.ProtocolFamily? If there are protocol families that will be part of Java SE and supported in all implementations then they could be added StandardProtocolFamily. On the other hand, if this is platform or JDK implementation specific then implementing ProtocolFamily is the way to go (the enum extending interface pattern is something that we've used in other areas too). -Alan
Re: Adding values to enum java.net.StandardProtocolFamily
On 02/13/2014 02:21 PM, Alan Bateman wrote: On 13/02/2014 12:54, Florian Weimer wrote: Can we add further enumeration values to java.net.StandardProtocolFamily? The spec does not say so, unlike javax.lang.model.SourceVersion, and the code in the JDK expects a binary flag, so I think the answer is "no". Does this mean the expected way to add support for further protocol families would be to create a separate implementation of java.net.ProtocolFamily? If there are protocol families that will be part of Java SE and supported in all implementations then they could be added StandardProtocolFamily. On the other hand, if this is platform or JDK implementation specific then implementing ProtocolFamily is the way to go (the enum extending interface pattern is something that we've used in other areas too). Okay, sounds reasonable. The PF_LOCAL protocol family is not available with Winsock, so I guess it will have to be a separate enum then, with a single member, although OpenJDK already requires PF_LOCAL support on the non-Windows platforms. -- Florian Weimer / Red Hat Product Security Team
Re: Adding values to enum java.net.StandardProtocolFamily
On 02/13/2014 07:33 AM, Florian Weimer wrote: On 02/13/2014 02:21 PM, Alan Bateman wrote: On 13/02/2014 12:54, Florian Weimer wrote: Can we add further enumeration values to java.net.StandardProtocolFamily? The spec does not say so, unlike javax.lang.model.SourceVersion, and the code in the JDK expects a binary flag, so I think the answer is "no". Does this mean the expected way to add support for further protocol families would be to create a separate implementation of java.net.ProtocolFamily? If there are protocol families that will be part of Java SE and supported in all implementations then they could be added StandardProtocolFamily. On the other hand, if this is platform or JDK implementation specific then implementing ProtocolFamily is the way to go (the enum extending interface pattern is something that we've used in other areas too). Okay, sounds reasonable. The PF_LOCAL protocol family is not available with Winsock, so I guess it will have to be a separate enum then, with a single member, although OpenJDK already requires PF_LOCAL support on the non-Windows platforms. Windows "named pipes" seem similar enough to UNIX sockets for a uniform implementation (full-duplex, socket-like connection, byte- or message-oriented, reliable delivery, file-like API, to list a few things off of wikipedia). It was my intent to support them in XNIO on Windows at some point, equivalently to UNIX sockets on other OSes, which I already have some support for. For this reason it was always a pet peeve of mine that OpenJDK hasn't gone in for UNIX sockets. -- - DML
Re: Adding values to enum java.net.StandardProtocolFamily
On 02/13/2014 03:23 PM, David M. Lloyd wrote: Okay, sounds reasonable. The PF_LOCAL protocol family is not available with Winsock, so I guess it will have to be a separate enum then, with a single member, although OpenJDK already requires PF_LOCAL support on the non-Windows platforms. Windows "named pipes" seem similar enough to UNIX sockets for a uniform implementation (full-duplex, socket-like connection, byte- or message-oriented, reliable delivery, file-like API, to list a few things off of wikipedia). It was my intent to support them in XNIO on Windows at some point, equivalently to UNIX sockets on other OSes, which I already have some support for. Naming is fundamentally different. With that caveat, it would be possible to expose a socket-based interface, but application code would have to adhere to the platform naming convention. -- Florian Weimer / Red Hat Product Security Team
Re: Adding values to enum java.net.StandardProtocolFamily
On 13/02/2014 15:04, Florian Weimer wrote: Naming is fundamentally different. With that caveat, it would be possible to expose a socket-based interface, but application code would have to adhere to the platform naming convention. When we prototyped this in the past then we used a new SocketAddress type for naming. In general, this requirement has been around for a long time, it just has never been high priority so this is why it hasn't been done. -Alan.