RFR: 8272215: Add InetAddress methods for parsing IP address literals

Mark Sheppard msheppar at openjdk.org
Mon Oct 16 16:18:19 UTC 2023


On Mon, 18 Sep 2023 13:43:47 GMT, Daniel Fuchs <dfuchs at openjdk.org> wrote:

> The main motivation here is to have a method that will create an InetAddress from an IP literal, and throw if the string given as parameters doesn't correspond to an IP literal. By comparison, `getByName` will try to parse the given name as an IP literal, and if it can't parse it as an IP literal, pass it to the resolver. The new method will never invoke the resolver and throw in that case. I find the name `ofLiteral` to be closer to what the method does than it would be if we provided it as an override to e.g. `getByAddress`, but naming can be discussed.

Well, the getByAddress methods are already providing a variation on the proposed functionality, and as such it makes sense from an OO perspective (polymorphism) to provide an overloaded method to perform the proposed functionality.  getByAddress is doing "what is says on the tin" ... ofLiteral conveys no semantics  and is more cryptic or nuanced

-------------

PR Comment: https://git.openjdk.org/jdk/pull/15775#issuecomment-1723598856


More information about the net-dev mailing list