File 0006-revert-Fix-native-image-build.patch of Package netty.23695

From 861651892abefc94b459d6fd78c4172372ec9643 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fridrich=20=C5=A0trba?= <fridrich.strba@bluewin.ch>
Date: Thu, 11 Feb 2021 12:46:20 +0100
Subject: [PATCH 6/7] revert Fix native image build...

---
 .../src/main/java/io/netty/util/NetUtil.java  | 114 +++++++++++-
 .../io/netty/util/NetUtilInitializations.java | 172 ------------------
 .../io/netty/util/NetUtilSubstitutions.java   |  90 ---------
 .../io.netty/common/native-image.properties   |   5 +-
 pom.xml                                       |   2 -
 .../resolver-dns/native-image.properties      |  18 --
 .../pom.xml                                   | 102 -----------
 .../NativeClientWithNettyInitAtRuntime.java   |  36 ----
 .../testsuite/svm/client/package-info.java    |  21 ---
 testsuite-native-image-client/pom.xml         | 108 -----------
 .../testsuite/svm/client/DnsNativeClient.java |  48 -----
 .../testsuite/svm/client/package-info.java    |  20 --
 .../src/main/resources/reflection-config.json |   8 -
 .../socket/InternetProtocolFamily.java        |  17 +-
 .../socket/InternetProtocolFamilyTest.java    |  36 ----
 15 files changed, 115 insertions(+), 682 deletions(-)
 delete mode 100644 common/src/main/java/io/netty/util/NetUtilInitializations.java
 delete mode 100644 common/src/main/java/io/netty/util/NetUtilSubstitutions.java
 delete mode 100644 resolver-dns/src/main/resources/META-INF/native-image/io.netty/resolver-dns/native-image.properties
 delete mode 100644 testsuite-native-image-client-runtime-init/pom.xml
 delete mode 100644 testsuite-native-image-client-runtime-init/src/main/java/io/netty/testsuite/svm/client/NativeClientWithNettyInitAtRuntime.java
 delete mode 100644 testsuite-native-image-client-runtime-init/src/main/java/io/netty/testsuite/svm/client/package-info.java
 delete mode 100644 testsuite-native-image-client/pom.xml
 delete mode 100644 testsuite-native-image-client/src/main/java/io/netty/testsuite/svm/client/DnsNativeClient.java
 delete mode 100644 testsuite-native-image-client/src/main/java/io/netty/testsuite/svm/client/package-info.java
 delete mode 100644 testsuite-native-image-client/src/main/resources/reflection-config.json
 delete mode 100644 transport/src/test/java/io/netty/channel/socket/InternetProtocolFamilyTest.java

diff --git a/common/src/main/java/io/netty/util/NetUtil.java b/common/src/main/java/io/netty/util/NetUtil.java
index 3d2744f745..687b2b7cc9 100644
--- a/common/src/main/java/io/netty/util/NetUtil.java
+++ b/common/src/main/java/io/netty/util/NetUtil.java
@@ -15,8 +15,8 @@
  */
 package io.netty.util;
 
-import io.netty.util.NetUtilInitializations.NetworkIfaceAndInetAddress;
 import io.netty.util.internal.PlatformDependent;
+import io.netty.util.internal.SocketUtils;
 import io.netty.util.internal.StringUtil;
 import io.netty.util.internal.SystemPropertyUtil;
 import io.netty.util.internal.logging.InternalLogger;
@@ -33,10 +33,14 @@ import java.net.Inet6Address;
 import java.net.InetAddress;
 import java.net.InetSocketAddress;
 import java.net.NetworkInterface;
+import java.net.SocketException;
 import java.net.UnknownHostException;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
+import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Enumeration;
+import java.util.List;
 
 import static io.netty.util.AsciiString.indexOf;
 
@@ -136,15 +140,113 @@ public final class NetUtil {
         logger.debug("-Djava.net.preferIPv4Stack: {}", IPV4_PREFERRED);
         logger.debug("-Djava.net.preferIPv6Addresses: {}", IPV6_ADDRESSES_PREFERRED);
 
+        byte[] LOCALHOST4_BYTES = {127, 0, 0, 1};
+        byte[] LOCALHOST6_BYTES = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
+
         // Create IPv4 loopback address.
-        LOCALHOST4 = NetUtilInitializations.createLocalhost4();
+        Inet4Address localhost4 = null;
+        try {
+            localhost4 = (Inet4Address) InetAddress.getByAddress("localhost", LOCALHOST4_BYTES);
+        } catch (Exception e) {
+            // We should not get here as long as the length of the address is correct.
+            PlatformDependent.throwException(e);
+        }
+        LOCALHOST4 = localhost4;
 
         // Create IPv6 loopback address.
-        LOCALHOST6 = NetUtilInitializations.createLocalhost6();
+        Inet6Address localhost6 = null;
+        try {
+            localhost6 = (Inet6Address) InetAddress.getByAddress("localhost", LOCALHOST6_BYTES);
+        } catch (Exception e) {
+            // We should not get here as long as the length of the address is correct.
+            PlatformDependent.throwException(e);
+        }
+        LOCALHOST6 = localhost6;
+
+        // Retrieve the list of available network interfaces.
+        List<NetworkInterface> ifaces = new ArrayList<NetworkInterface>();
+        try {
+            Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces();
+            if (interfaces != null) {
+                while (interfaces.hasMoreElements()) {
+                    NetworkInterface iface = interfaces.nextElement();
+                    // Use the interface with proper INET addresses only.
+                    if (SocketUtils.addressesFromNetworkInterface(iface).hasMoreElements()) {
+                        ifaces.add(iface);
+                    }
+                }
+            }
+        } catch (SocketException e) {
+            logger.warn("Failed to retrieve the list of available network interfaces", e);
+        }
+
+        // Find the first loopback interface available from its INET address (127.0.0.1 or ::1)
+        // Note that we do not use NetworkInterface.isLoopback() in the first place because it takes long time
+        // on a certain environment. (e.g. Windows with -Djava.net.preferIPv4Stack=true)
+        NetworkInterface loopbackIface = null;
+        InetAddress loopbackAddr = null;
+        loop: for (NetworkInterface iface: ifaces) {
+            for (Enumeration<InetAddress> i = SocketUtils.addressesFromNetworkInterface(iface); i.hasMoreElements();) {
+                InetAddress addr = i.nextElement();
+                if (addr.isLoopbackAddress()) {
+                    // Found
+                    loopbackIface = iface;
+                    loopbackAddr = addr;
+                    break loop;
+                }
+            }
+        }
+
+        // If failed to find the loopback interface from its INET address, fall back to isLoopback().
+        if (loopbackIface == null) {
+            try {
+                for (NetworkInterface iface: ifaces) {
+                    if (iface.isLoopback()) {
+                        Enumeration<InetAddress> i = SocketUtils.addressesFromNetworkInterface(iface);
+                        if (i.hasMoreElements()) {
+                            // Found the one with INET address.
+                            loopbackIface = iface;
+                            loopbackAddr = i.nextElement();
+                            break;
+                        }
+                    }
+                }
+
+                if (loopbackIface == null) {
+                    logger.warn("Failed to find the loopback interface");
+                }
+            } catch (SocketException e) {
+                logger.warn("Failed to find the loopback interface", e);
+            }
+        }
+
+        if (loopbackIface != null) {
+            // Found the loopback interface with an INET address.
+            logger.debug(
+                    "Loopback interface: {} ({}, {})",
+                    loopbackIface.getName(), loopbackIface.getDisplayName(), loopbackAddr.getHostAddress());
+        } else {
+            // Could not find the loopback interface, but we can't leave LOCALHOST as null.
+            // Use LOCALHOST6 or LOCALHOST4, preferably the IPv6 one.
+            if (loopbackAddr == null) {
+                try {
+                    if (NetworkInterface.getByInetAddress(LOCALHOST6) != null) {
+                        logger.debug("Using hard-coded IPv6 localhost address: {}", localhost6);
+                        loopbackAddr = localhost6;
+                    }
+                } catch (Exception e) {
+                    // Ignore
+                } finally {
+                    if (loopbackAddr == null) {
+                        logger.debug("Using hard-coded IPv4 localhost address: {}", localhost4);
+                        loopbackAddr = localhost4;
+                    }
+                }
+            }
+        }
 
-        NetworkIfaceAndInetAddress loopback = NetUtilInitializations.determineLoopback(LOCALHOST4, LOCALHOST6);
-        LOOPBACK_IF = loopback.iface();
-        LOCALHOST = loopback.address();
+        LOOPBACK_IF = loopbackIface;
+        LOCALHOST = loopbackAddr;
 
         // As a SecurityManager may prevent reading the somaxconn file we wrap this in a privileged block.
         //
diff --git a/common/src/main/java/io/netty/util/NetUtilInitializations.java b/common/src/main/java/io/netty/util/NetUtilInitializations.java
deleted file mode 100644
index f2d65a5c6e..0000000000
--- a/common/src/main/java/io/netty/util/NetUtilInitializations.java
+++ /dev/null
@@ -1,172 +0,0 @@
-/*
- * Copyright 2020 The Netty Project
- *
- * The Netty Project licenses this file to you under the Apache License,
- * version 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at:
- *
- *   https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- */
-package io.netty.util;
-
-import io.netty.util.internal.PlatformDependent;
-import io.netty.util.internal.SocketUtils;
-import io.netty.util.internal.logging.InternalLogger;
-import io.netty.util.internal.logging.InternalLoggerFactory;
-
-import java.net.Inet4Address;
-import java.net.Inet6Address;
-import java.net.InetAddress;
-import java.net.NetworkInterface;
-import java.net.SocketException;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.List;
-
-final class NetUtilInitializations {
-    /**
-     * The logger being used by this class
-     */
-    private static final InternalLogger logger = InternalLoggerFactory.getInstance(NetUtilInitializations.class);
-
-    private NetUtilInitializations() {
-    }
-
-    static Inet4Address createLocalhost4() {
-        byte[] LOCALHOST4_BYTES = {127, 0, 0, 1};
-
-        Inet4Address localhost4 = null;
-        try {
-            localhost4 = (Inet4Address) InetAddress.getByAddress("localhost", LOCALHOST4_BYTES);
-        } catch (Exception e) {
-            // We should not get here as long as the length of the address is correct.
-            PlatformDependent.throwException(e);
-        }
-
-        return localhost4;
-    }
-
-    static Inet6Address createLocalhost6() {
-        byte[] LOCALHOST6_BYTES = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
-
-        Inet6Address localhost6 = null;
-        try {
-            localhost6 = (Inet6Address) InetAddress.getByAddress("localhost", LOCALHOST6_BYTES);
-        } catch (Exception e) {
-            // We should not get here as long as the length of the address is correct.
-            PlatformDependent.throwException(e);
-        }
-
-        return localhost6;
-    }
-
-    static NetworkIfaceAndInetAddress determineLoopback(Inet4Address localhost4, Inet6Address localhost6) {
-        // Retrieve the list of available network interfaces.
-        List<NetworkInterface> ifaces = new ArrayList<NetworkInterface>();
-        try {
-            Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces();
-            if (interfaces != null) {
-                while (interfaces.hasMoreElements()) {
-                    NetworkInterface iface = interfaces.nextElement();
-                    // Use the interface with proper INET addresses only.
-                    if (SocketUtils.addressesFromNetworkInterface(iface).hasMoreElements()) {
-                        ifaces.add(iface);
-                    }
-                }
-            }
-        } catch (SocketException e) {
-            logger.warn("Failed to retrieve the list of available network interfaces", e);
-        }
-
-        // Find the first loopback interface available from its INET address (127.0.0.1 or ::1)
-        // Note that we do not use NetworkInterface.isLoopback() in the first place because it takes long time
-        // on a certain environment. (e.g. Windows with -Djava.net.preferIPv4Stack=true)
-        NetworkInterface loopbackIface = null;
-        InetAddress loopbackAddr = null;
-        loop: for (NetworkInterface iface: ifaces) {
-            for (Enumeration<InetAddress> i = SocketUtils.addressesFromNetworkInterface(iface); i.hasMoreElements();) {
-                InetAddress addr = i.nextElement();
-                if (addr.isLoopbackAddress()) {
-                    // Found
-                    loopbackIface = iface;
-                    loopbackAddr = addr;
-                    break loop;
-                }
-            }
-        }
-
-        // If failed to find the loopback interface from its INET address, fall back to isLoopback().
-        if (loopbackIface == null) {
-            try {
-                for (NetworkInterface iface: ifaces) {
-                    if (iface.isLoopback()) {
-                        Enumeration<InetAddress> i = SocketUtils.addressesFromNetworkInterface(iface);
-                        if (i.hasMoreElements()) {
-                            // Found the one with INET address.
-                            loopbackIface = iface;
-                            loopbackAddr = i.nextElement();
-                            break;
-                        }
-                    }
-                }
-
-                if (loopbackIface == null) {
-                    logger.warn("Failed to find the loopback interface");
-                }
-            } catch (SocketException e) {
-                logger.warn("Failed to find the loopback interface", e);
-            }
-        }
-
-        if (loopbackIface != null) {
-            // Found the loopback interface with an INET address.
-            logger.debug(
-                    "Loopback interface: {} ({}, {})",
-                    loopbackIface.getName(), loopbackIface.getDisplayName(), loopbackAddr.getHostAddress());
-        } else {
-            // Could not find the loopback interface, but we can't leave LOCALHOST as null.
-            // Use LOCALHOST6 or LOCALHOST4, preferably the IPv6 one.
-            if (loopbackAddr == null) {
-                try {
-                    if (NetworkInterface.getByInetAddress(localhost6) != null) {
-                        logger.debug("Using hard-coded IPv6 localhost address: {}", localhost6);
-                        loopbackAddr = localhost6;
-                    }
-                } catch (Exception e) {
-                    // Ignore
-                } finally {
-                    if (loopbackAddr == null) {
-                        logger.debug("Using hard-coded IPv4 localhost address: {}", localhost4);
-                        loopbackAddr = localhost4;
-                    }
-                }
-            }
-        }
-
-        return new NetworkIfaceAndInetAddress(loopbackIface, loopbackAddr);
-    }
-
-    static final class NetworkIfaceAndInetAddress {
-        private final NetworkInterface iface;
-        private final InetAddress address;
-
-        NetworkIfaceAndInetAddress(NetworkInterface iface, InetAddress address) {
-            this.iface = iface;
-            this.address = address;
-        }
-
-        public NetworkInterface iface() {
-            return iface;
-        }
-
-        public InetAddress address() {
-            return address;
-        }
-    }
-}
diff --git a/common/src/main/java/io/netty/util/NetUtilSubstitutions.java b/common/src/main/java/io/netty/util/NetUtilSubstitutions.java
deleted file mode 100644
index 7894037e4e..0000000000
--- a/common/src/main/java/io/netty/util/NetUtilSubstitutions.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright 2020 The Netty Project
- *
- * The Netty Project licenses this file to you under the Apache License,
- * version 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at:
- *
- *   https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- */
-package io.netty.util;
-
-import com.oracle.svm.core.annotate.Alias;
-import com.oracle.svm.core.annotate.InjectAccessors;
-import com.oracle.svm.core.annotate.TargetClass;
-
-import java.net.Inet4Address;
-import java.net.Inet6Address;
-import java.net.InetAddress;
-
-@TargetClass(NetUtil.class)
-final class NetUtilSubstitutions {
-    private NetUtilSubstitutions() {
-    }
-
-    @Alias
-    @InjectAccessors(NetUtilLocalhost4Accessor.class)
-    public static Inet4Address LOCALHOST4;
-
-    @Alias
-    @InjectAccessors(NetUtilLocalhost6Accessor.class)
-    public static Inet6Address LOCALHOST6;
-
-    @Alias
-    @InjectAccessors(NetUtilLocalhostAccessor.class)
-    public static InetAddress LOCALHOST;
-
-    private static final class NetUtilLocalhost4Accessor {
-        static Inet4Address get() {
-            // using https://en.wikipedia.org/wiki/Initialization-on-demand_holder_idiom
-            return NetUtilLocalhost4LazyHolder.LOCALHOST4;
-        }
-
-        static void set(Inet4Address ignored) {
-            // a no-op setter to avoid exceptions when NetUtil is initialized at run-time
-        }
-    }
-
-    private static final class NetUtilLocalhost4LazyHolder {
-        private static final Inet4Address LOCALHOST4 = NetUtilInitializations.createLocalhost4();
-    }
-
-    private static final class NetUtilLocalhost6Accessor {
-        static Inet6Address get() {
-            // using https://en.wikipedia.org/wiki/Initialization-on-demand_holder_idiom
-            return NetUtilLocalhost6LazyHolder.LOCALHOST6;
-        }
-
-        static void set(Inet6Address ignored) {
-            // a no-op setter to avoid exceptions when NetUtil is initialized at run-time
-        }
-    }
-
-    private static final class NetUtilLocalhost6LazyHolder {
-        private static final Inet6Address LOCALHOST6 = NetUtilInitializations.createLocalhost6();
-    }
-
-    private static final class NetUtilLocalhostAccessor {
-        static InetAddress get() {
-            // using https://en.wikipedia.org/wiki/Initialization-on-demand_holder_idiom
-            return NetUtilLocalhostLazyHolder.LOCALHOST;
-        }
-
-        static void set(InetAddress ignored) {
-            // a no-op setter to avoid exceptions when NetUtil is initialized at run-time
-        }
-    }
-
-    private static final class NetUtilLocalhostLazyHolder {
-        private static final InetAddress LOCALHOST = NetUtilInitializations
-                .determineLoopback(NetUtilLocalhost4LazyHolder.LOCALHOST4, NetUtilLocalhost6LazyHolder.LOCALHOST6)
-                .address();
-    }
-}
-
diff --git a/common/src/main/resources/META-INF/native-image/io.netty/common/native-image.properties b/common/src/main/resources/META-INF/native-image/io.netty/common/native-image.properties
index d2f607f492..1e4620fab2 100644
--- a/common/src/main/resources/META-INF/native-image/io.netty/common/native-image.properties
+++ b/common/src/main/resources/META-INF/native-image/io.netty/common/native-image.properties
@@ -12,7 +12,4 @@
 # License for the specific language governing permissions and limitations
 # under the License.
 
-Args = --initialize-at-run-time=io.netty.util.AbstractReferenceCounted,io.netty.util.concurrent.GlobalEventExecutor,io.netty.util.concurrent.ImmediateEventExecutor,io.netty.util.concurrent.ScheduledFutureTask,io.netty.util.internal.ThreadLocalRandom \
-       --initialize-at-run-time=io.netty.util.NetUtilSubstitutions$NetUtilLocalhost4LazyHolder \
-       --initialize-at-run-time=io.netty.util.NetUtilSubstitutions$NetUtilLocalhost6LazyHolder \
-       --initialize-at-run-time=io.netty.util.NetUtilSubstitutions$NetUtilLocalhostLazyHolder
+Args = --initialize-at-run-time=io.netty.util.AbstractReferenceCounted,io.netty.util.concurrent.GlobalEventExecutor,io.netty.util.concurrent.ImmediateEventExecutor,io.netty.util.concurrent.ScheduledFutureTask,io.netty.util.internal.ThreadLocalRandom
diff --git a/pom.xml b/pom.xml
index c743bd97f3..781ba61ba0 100644
--- a/pom.xml
+++ b/pom.xml
@@ -609,8 +609,6 @@
     <module>testsuite-shading</module>
     <module>testsuite-native</module>
     <module>testsuite-native-image</module>
-    <module>testsuite-native-image-client</module>
-    <module>testsuite-native-image-client-runtime-init</module>
     <module>microbench</module>
     <module>bom</module>
   </modules>
diff --git a/resolver-dns/src/main/resources/META-INF/native-image/io.netty/resolver-dns/native-image.properties b/resolver-dns/src/main/resources/META-INF/native-image/io.netty/resolver-dns/native-image.properties
deleted file mode 100644
index 43af984157..0000000000
--- a/resolver-dns/src/main/resources/META-INF/native-image/io.netty/resolver-dns/native-image.properties
+++ /dev/null
@@ -1,18 +0,0 @@
-# Copyright 2020 The Netty Project
-#
-# The Netty Project licenses this file to you under the Apache License,
-# version 2.0 (the "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at:
-#
-#   https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-Args = --initialize-at-run-time=io.netty.resolver.dns.DefaultDnsServerAddressStreamProvider \
-       --initialize-at-run-time=io.netty.resolver.dns.DnsServerAddressStreamProviders$DefaultProviderHolder \
-       --initialize-at-run-time=io.netty.resolver.dns.DnsNameResolver \
-       --initialize-at-run-time=io.netty.resolver.HostsFileEntriesResolver
diff --git a/testsuite-native-image-client-runtime-init/pom.xml b/testsuite-native-image-client-runtime-init/pom.xml
deleted file mode 100644
index 3e7b50069f..0000000000
--- a/testsuite-native-image-client-runtime-init/pom.xml
+++ /dev/null
@@ -1,102 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-  ~ Copyright 2020 The Netty Project
-  ~
-  ~ The Netty Project licenses this file to you under the Apache License,
-  ~ version 2.0 (the "License"); you may not use this file except in compliance
-  ~ with the License. You may obtain a copy of the License at:
-  ~
-  ~   https://www.apache.org/licenses/LICENSE-2.0
-  ~
-  ~ Unless required by applicable law or agreed to in writing, software
-  ~ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-  ~ WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-  ~ License for the specific language governing permissions and limitations
-  ~ under the License.
-  -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/maven-v4_0_0.xsd">
-
-  <modelVersion>4.0.0</modelVersion>
-  <parent>
-    <groupId>io.netty</groupId>
-    <artifactId>netty-parent</artifactId>
-    <version>4.1.75.Final</version>
-  </parent>
-
-  <artifactId>netty-testsuite-native-image-client-runtime-init</artifactId>
-  <packaging>jar</packaging>
-
-  <name>Netty/Testsuite/NativeImage/ClientRuntimeInit</name>
-
-  <properties>
-    <japicmp.skip>true</japicmp.skip>
-    <!-- Do not deploy this module -->
-    <skipDeploy>true</skipDeploy>
-  </properties>
-
-  <dependencies>
-    <dependency>
-      <groupId>${project.groupId}</groupId>
-      <artifactId>netty-common</artifactId>
-      <version>${project.version}</version>
-    </dependency>
-  </dependencies>
-
-  <profiles>
-    <profile>
-      <id>skipTests</id>
-      <activation>
-        <property>
-          <name>skipTests</name>
-        </property>
-      </activation>
-      <properties>
-        <skipNativeImageTestsuite>true</skipNativeImageTestsuite>
-      </properties>
-    </profile>
-  </profiles>
-
-  <build>
-    <plugins>
-      <plugin>
-        <groupId>org.graalvm.nativeimage</groupId>
-        <artifactId>native-image-maven-plugin</artifactId>
-        <version>${graalvm.version}</version>
-        <executions>
-          <execution>
-            <goals>
-              <goal>native-image</goal>
-            </goals>
-            <phase>package</phase>
-          </execution>
-        </executions>
-        <configuration>
-          <skip>${skipNativeImageTestsuite}</skip>
-          <imageName>${project.artifactId}</imageName>
-          <mainClass>io.netty.testsuite.svm.client.NativeClientWithNettyInitAtRuntime</mainClass>
-          <buildArgs>--report-unsupported-elements-at-runtime --allow-incomplete-classpath --no-fallback --initialize-at-run-time=io.netty.util.NetUtil</buildArgs>
-        </configuration>
-      </plugin>
-      <plugin>
-        <groupId>org.codehaus.mojo</groupId>
-        <artifactId>exec-maven-plugin</artifactId>
-        <version>1.6.0</version>
-        <executions>
-          <!-- This will do a whitesmoke test: if the substitutions are missing the binary will fail to run -->
-          <!-- If the metadata is missing the build above will fail -->
-          <execution>
-            <id>verify-native-image</id>
-            <phase>verify</phase>
-            <goals>
-              <goal>exec</goal>
-            </goals>
-          </execution>
-        </executions>
-        <configuration>
-          <skip>${skipNativeImageTestsuite}</skip>
-          <executable>${project.build.directory}/${project.artifactId}</executable>
-        </configuration>
-      </plugin>
-    </plugins>
-  </build>
-</project>
diff --git a/testsuite-native-image-client-runtime-init/src/main/java/io/netty/testsuite/svm/client/NativeClientWithNettyInitAtRuntime.java b/testsuite-native-image-client-runtime-init/src/main/java/io/netty/testsuite/svm/client/NativeClientWithNettyInitAtRuntime.java
deleted file mode 100644
index 6c4aa22ba8..0000000000
--- a/testsuite-native-image-client-runtime-init/src/main/java/io/netty/testsuite/svm/client/NativeClientWithNettyInitAtRuntime.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright 2020 The Netty Project
- *
- * The Netty Project licenses this file to you under the Apache License,
- * version 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at:
- *
- *   https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- */
-package io.netty.testsuite.svm.client;
-
-import io.netty.util.NetUtil;
-
-/**
- * A client that triggers runtime initialization of NetUtil when
- * built to a native image.
- */
-public final class NativeClientWithNettyInitAtRuntime {
-    /**
-     * Main entry point (not instantiable)
-     */
-    private NativeClientWithNettyInitAtRuntime() {
-    }
-
-    public static void main(String[] args) {
-        System.out.println(NetUtil.LOCALHOST4);
-        System.out.println(NetUtil.LOCALHOST6);
-        System.out.println(NetUtil.LOCALHOST);
-    }
-}
diff --git a/testsuite-native-image-client-runtime-init/src/main/java/io/netty/testsuite/svm/client/package-info.java b/testsuite-native-image-client-runtime-init/src/main/java/io/netty/testsuite/svm/client/package-info.java
deleted file mode 100644
index c5d8a74b31..0000000000
--- a/testsuite-native-image-client-runtime-init/src/main/java/io/netty/testsuite/svm/client/package-info.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright 2020 The Netty Project
- *
- * The Netty Project licenses this file to you under the Apache License,
- * version 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at:
- *
- *   https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * A client that triggers runtime initialization of NetUtil when
- * built to a native image.
- */
-package io.netty.testsuite.svm.client;
diff --git a/testsuite-native-image-client/pom.xml b/testsuite-native-image-client/pom.xml
deleted file mode 100644
index 6bd531f954..0000000000
--- a/testsuite-native-image-client/pom.xml
+++ /dev/null
@@ -1,108 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-  ~ Copyright 2020 The Netty Project
-  ~
-  ~ The Netty Project licenses this file to you under the Apache License,
-  ~ version 2.0 (the "License"); you may not use this file except in compliance
-  ~ with the License. You may obtain a copy of the License at:
-  ~
-  ~   https://www.apache.org/licenses/LICENSE-2.0
-  ~
-  ~ Unless required by applicable law or agreed to in writing, software
-  ~ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-  ~ WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-  ~ License for the specific language governing permissions and limitations
-  ~ under the License.
-  -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/maven-v4_0_0.xsd">
-
-  <modelVersion>4.0.0</modelVersion>
-  <parent>
-    <groupId>io.netty</groupId>
-    <artifactId>netty-parent</artifactId>
-    <version>4.1.75.Final</version>
-  </parent>
-
-  <artifactId>netty-testsuite-native-image-client</artifactId>
-  <packaging>jar</packaging>
-
-  <name>Netty/Testsuite/NativeImage/Client</name>
-
-  <properties>
-    <japicmp.skip>true</japicmp.skip>
-    <!-- Do not deploy this module -->
-    <skipDeploy>true</skipDeploy>
-  </properties>
-
-  <dependencies>
-    <dependency>
-      <groupId>${project.groupId}</groupId>
-      <artifactId>netty-transport</artifactId>
-      <version>${project.version}</version>
-    </dependency>
-    <dependency>
-      <groupId>${project.groupId}</groupId>
-      <artifactId>netty-resolver-dns</artifactId>
-      <version>${project.version}</version>
-    </dependency>
-
-  </dependencies>
-
-  <profiles>
-    <profile>
-      <id>skipTests</id>
-      <activation>
-        <property>
-          <name>skipTests</name>
-        </property>
-      </activation>
-      <properties>
-        <skipNativeImageTestsuite>true</skipNativeImageTestsuite>
-      </properties>
-    </profile>
-  </profiles>
-
-  <build>
-    <plugins>
-      <plugin>
-        <groupId>org.graalvm.nativeimage</groupId>
-        <artifactId>native-image-maven-plugin</artifactId>
-        <version>${graalvm.version}</version>
-        <executions>
-          <execution>
-            <goals>
-              <goal>native-image</goal>
-            </goals>
-            <phase>package</phase>
-          </execution>
-        </executions>
-        <configuration>
-          <skip>${skipNativeImageTestsuite}</skip>
-          <imageName>${project.artifactId}</imageName>
-          <mainClass>io.netty.testsuite.svm.client.DnsNativeClient</mainClass>
-          <buildArgs>--report-unsupported-elements-at-runtime --allow-incomplete-classpath --no-fallback --initialize-at-build-time=io.netty -H:ReflectionConfigurationResources=reflection-config.json</buildArgs>
-        </configuration>
-      </plugin>
-      <plugin>
-        <groupId>org.codehaus.mojo</groupId>
-        <artifactId>exec-maven-plugin</artifactId>
-        <version>1.6.0</version>
-        <executions>
-          <!-- This will do a whitesmoke test: if the substitutions are missing the binary will fail to run -->
-          <!-- If the metadata is missing the build above will fail -->
-          <execution>
-            <id>verify-native-image</id>
-            <phase>verify</phase>
-            <goals>
-              <goal>exec</goal>
-            </goals>
-          </execution>
-        </executions>
-        <configuration>
-          <skip>${skipNativeImageTestsuite}</skip>
-          <executable>${project.build.directory}/${project.artifactId}</executable>
-        </configuration>
-      </plugin>
-    </plugins>
-  </build>
-</project>
diff --git a/testsuite-native-image-client/src/main/java/io/netty/testsuite/svm/client/DnsNativeClient.java b/testsuite-native-image-client/src/main/java/io/netty/testsuite/svm/client/DnsNativeClient.java
deleted file mode 100644
index afbbd61eb1..0000000000
--- a/testsuite-native-image-client/src/main/java/io/netty/testsuite/svm/client/DnsNativeClient.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright 2020 The Netty Project
- *
- * The Netty Project licenses this file to you under the Apache License,
- * version 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at:
- *
- *   https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- */
-package io.netty.testsuite.svm.client;
-
-import io.netty.channel.nio.NioEventLoopGroup;
-import io.netty.channel.socket.nio.NioDatagramChannel;
-import io.netty.resolver.AddressResolver;
-import io.netty.resolver.dns.DnsAddressResolverGroup;
-import io.netty.resolver.dns.DnsServerAddressStreamProviders;
-import io.netty.util.concurrent.DefaultThreadFactory;
-
-import java.net.InetSocketAddress;
-
-/**
- * A client that uses netty-dns and gets compiled to a native image.
- */
-public final class DnsNativeClient {
-    /**
-     * Main entry point (not instantiable)
-     */
-    private DnsNativeClient() {
-    }
-
-    public static void main(String[] args) throws Exception {
-        NioEventLoopGroup group = new NioEventLoopGroup(1, new DefaultThreadFactory("netty"));
-
-        DnsAddressResolverGroup resolverGroup = new DnsAddressResolverGroup(NioDatagramChannel.class,
-                DnsServerAddressStreamProviders.platformDefault());
-        AddressResolver<InetSocketAddress> resolver = resolverGroup.getResolver(group.next());
-        System.out.println(resolver);
-
-        resolver.close();
-        group.shutdownGracefully().get();
-    }
-}
diff --git a/testsuite-native-image-client/src/main/java/io/netty/testsuite/svm/client/package-info.java b/testsuite-native-image-client/src/main/java/io/netty/testsuite/svm/client/package-info.java
deleted file mode 100644
index 7b575e6835..0000000000
--- a/testsuite-native-image-client/src/main/java/io/netty/testsuite/svm/client/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2020 The Netty Project
- *
- * The Netty Project licenses this file to you under the Apache License,
- * version 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at:
- *
- *   https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * A client that uses netty-dns and gets compiled to a native image.
- */
-package io.netty.testsuite.svm.client;
diff --git a/testsuite-native-image-client/src/main/resources/reflection-config.json b/testsuite-native-image-client/src/main/resources/reflection-config.json
deleted file mode 100644
index 2d1c8edff5..0000000000
--- a/testsuite-native-image-client/src/main/resources/reflection-config.json
+++ /dev/null
@@ -1,8 +0,0 @@
-[
-    {
-      "name": "io.netty.channel.socket.nio.NioDatagramChannel",
-      "methods": [
-        { "name": "<init>", "parameterTypes": [] }
-      ]
-    }
-]
diff --git a/transport/src/main/java/io/netty/channel/socket/InternetProtocolFamily.java b/transport/src/main/java/io/netty/channel/socket/InternetProtocolFamily.java
index 57f7cf7d2c..369cdd28b5 100644
--- a/transport/src/main/java/io/netty/channel/socket/InternetProtocolFamily.java
+++ b/transport/src/main/java/io/netty/channel/socket/InternetProtocolFamily.java
@@ -25,15 +25,17 @@ import java.net.InetAddress;
  * Internet Protocol (IP) families used byte the {@link DatagramChannel}
  */
 public enum InternetProtocolFamily {
-    IPv4(Inet4Address.class, 1),
-    IPv6(Inet6Address.class, 2);
+    IPv4(Inet4Address.class, 1, NetUtil.LOCALHOST4),
+    IPv6(Inet6Address.class, 2, NetUtil.LOCALHOST6);
 
     private final Class<? extends InetAddress> addressType;
     private final int addressNumber;
+    private final InetAddress localHost;
 
-    InternetProtocolFamily(Class<? extends InetAddress> addressType, int addressNumber) {
+    InternetProtocolFamily(Class<? extends InetAddress> addressType, int addressNumber, InetAddress localHost) {
         this.addressType = addressType;
         this.addressNumber = addressNumber;
+        this.localHost = localHost;
     }
 
     /**
@@ -56,14 +58,7 @@ public enum InternetProtocolFamily {
      * Returns the {@link InetAddress} that represent the {@code LOCALHOST} for the family.
      */
     public InetAddress localhost() {
-        switch (this) {
-            case IPv4:
-                return NetUtil.LOCALHOST4;
-            case IPv6:
-                return NetUtil.LOCALHOST6;
-            default:
-                throw new IllegalStateException("Unsupported family " + this);
-        }
+        return localHost;
     }
 
     /**
diff --git a/transport/src/test/java/io/netty/channel/socket/InternetProtocolFamilyTest.java b/transport/src/test/java/io/netty/channel/socket/InternetProtocolFamilyTest.java
deleted file mode 100644
index 6fe225b850..0000000000
--- a/transport/src/test/java/io/netty/channel/socket/InternetProtocolFamilyTest.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright 2020 The Netty Project
- *
- * The Netty Project licenses this file to you under the Apache License,
- * version 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at:
- *
- *   https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- */
-package io.netty.channel.socket;
-
-import io.netty.util.NetUtil;
-import org.junit.jupiter.api.Test;
-
-import java.net.InetAddress;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-public class InternetProtocolFamilyTest {
-    @Test
-    public void ipv4ShouldHaveLocalhostOfIpV4() {
-        assertThat(InternetProtocolFamily.IPv4.localhost(), is((InetAddress) NetUtil.LOCALHOST4));
-    }
-
-    @Test
-    public void ipv6ShouldHaveLocalhostOfIpV6() {
-        assertThat(InternetProtocolFamily.IPv6.localhost(), is((InetAddress) NetUtil.LOCALHOST6));
-    }
-}
-- 
2.35.1

openSUSE Build Service is sponsored by