1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package io.netty.util;
17
18 import com.oracle.svm.core.annotate.Alias;
19 import com.oracle.svm.core.annotate.InjectAccessors;
20 import com.oracle.svm.core.annotate.TargetClass;
21
22 import java.net.Inet4Address;
23 import java.net.Inet6Address;
24 import java.net.InetAddress;
25 import java.net.NetworkInterface;
26 import java.util.Collection;
27
28 @TargetClass(NetUtil.class)
29 final class NetUtilSubstitutions {
30 private NetUtilSubstitutions() {
31 }
32
33 @Alias
34 @InjectAccessors(NetUtilLocalhost4Accessor.class)
35 public static Inet4Address LOCALHOST4;
36
37 @Alias
38 @InjectAccessors(NetUtilLocalhost6Accessor.class)
39 public static Inet6Address LOCALHOST6;
40
41 @Alias
42 @InjectAccessors(NetUtilLocalhostAccessor.class)
43 public static InetAddress LOCALHOST;
44
45 @Alias
46 @InjectAccessors(NetUtilNetworkInterfacesAccessor.class)
47 public static Collection<NetworkInterface> NETWORK_INTERFACES;
48
49 private static final class NetUtilLocalhost4Accessor {
50 static Inet4Address get() {
51
52 return NetUtilLocalhost4LazyHolder.LOCALHOST4;
53 }
54
55 static void set(Inet4Address ignored) {
56
57 }
58 }
59
60 private static final class NetUtilLocalhost4LazyHolder {
61 private static final Inet4Address LOCALHOST4 = NetUtilInitializations.createLocalhost4();
62 }
63
64 private static final class NetUtilLocalhost6Accessor {
65 static Inet6Address get() {
66
67 return NetUtilLocalhost6LazyHolder.LOCALHOST6;
68 }
69
70 static void set(Inet6Address ignored) {
71
72 }
73 }
74
75 private static final class NetUtilLocalhost6LazyHolder {
76 private static final Inet6Address LOCALHOST6 = NetUtilInitializations.createLocalhost6();
77 }
78
79 private static final class NetUtilLocalhostAccessor {
80 static InetAddress get() {
81
82 return NetUtilLocalhostLazyHolder.LOCALHOST;
83 }
84
85 static void set(InetAddress ignored) {
86
87 }
88 }
89
90 private static final class NetUtilLocalhostLazyHolder {
91 private static final InetAddress LOCALHOST = NetUtilInitializations
92 .determineLoopback(NetUtilNetworkInterfacesLazyHolder.NETWORK_INTERFACES,
93 NetUtilLocalhost4LazyHolder.LOCALHOST4, NetUtilLocalhost6LazyHolder.LOCALHOST6)
94 .address();
95 }
96
97 private static final class NetUtilNetworkInterfacesAccessor {
98 static Collection<NetworkInterface> get() {
99
100 return NetUtilNetworkInterfacesLazyHolder.NETWORK_INTERFACES;
101 }
102
103 static void set(Collection<NetworkInterface> ignored) {
104
105 }
106 }
107
108 private static final class NetUtilNetworkInterfacesLazyHolder {
109 private static final Collection<NetworkInterface> NETWORK_INTERFACES =
110 NetUtilInitializations.networkInterfaces();
111 }
112 }
113