Skip to content

getAddress() in ARecord/AAAARecord should return Inet4Address/Inet6Address #101

Description

@maffe

To avoid having to cast in client code,

  • ARecord.getAddress() should return Inet4Address
  • AAAARecord.getAddress() should return Inet6Address (not feasible since Java creates Inet4Address instances for ::ffff:0.0.0.0/96)

I tried to change the return type (adding casts inside the method), but then I got

Failed to execute goal com.github.siom79.japicmp:japicmp-maven-plugin:0.14.0:cmp (check-compatibility) on project dnsjava: Versions of archives indicate a minor change but binary incompatible changes found.

While this changes the public API, usages of those methods should work like before, as the new return types can still be assigned to InetAddress. What could fail with this change is overriding those methods. Maybe the methods or the classes should be final.

Activity

  1. ibauersachs commented on May 2, 2020

    @ibauersachs
    Member

    Unfortunately apicmp is right. While the change is source compatible, it isn't binary compatible and would result in java.lang.NoSuchMethodError: org.xbill.DNS.ARecord.getAddress()Ljava/net/InetAddress.

    I'll stick to semver for this project, so I will consider this for the next major version.

  2. added this to the v4 milestone on May 2, 2020
  3. maffe commented on Sep 12, 2024

    @maffe
    Author

    Since Java creates Inet4Address instances for IPv4 mapped addresses (::ffff:0:0/96, Java 22 example: Inet6Address.ofLiteral("::ffff:192.0.2.1")), it’s not possible to map all AAAA records to Inet6Address. But Inet4Address would always be possible for A records.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions