1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package io.netty5.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
26 @TargetClass(NetUtil.class)
27 final class NetUtilSubstitutions {
28 private NetUtilSubstitutions() {
29 }
30
31 @Alias
32 @InjectAccessors(NetUtilLocalhost4Accessor.class)
33 public static Inet4Address LOCALHOST4;
34
35 @Alias
36 @InjectAccessors(NetUtilLocalhost6Accessor.class)
37 public static Inet6Address LOCALHOST6;
38
39 @Alias
40 @InjectAccessors(NetUtilLocalhostAccessor.class)
41 public static InetAddress LOCALHOST;
42
43 private static final class NetUtilLocalhost4Accessor {
44 static Inet4Address get() {
45
46 return NetUtilLocalhost4LazyHolder.LOCALHOST4;
47 }
48
49 static void set(Inet4Address ignored) {
50
51 }
52 }
53
54 private static final class NetUtilLocalhost4LazyHolder {
55 private static final Inet4Address LOCALHOST4 = NetUtilInitializations.createLocalhost4();
56 }
57
58 private static final class NetUtilLocalhost6Accessor {
59 static Inet6Address get() {
60
61 return NetUtilLocalhost6LazyHolder.LOCALHOST6;
62 }
63
64 static void set(Inet6Address ignored) {
65
66 }
67 }
68
69 private static final class NetUtilLocalhost6LazyHolder {
70 private static final Inet6Address LOCALHOST6 = NetUtilInitializations.createLocalhost6();
71 }
72
73 private static final class NetUtilLocalhostAccessor {
74 static InetAddress get() {
75
76 return NetUtilLocalhostLazyHolder.LOCALHOST;
77 }
78
79 static void set(InetAddress ignored) {
80
81 }
82 }
83
84 private static final class NetUtilLocalhostLazyHolder {
85 private static final InetAddress LOCALHOST = NetUtilInitializations
86 .determineLoopback(NetUtilLocalhost4LazyHolder.LOCALHOST4, NetUtilLocalhost6LazyHolder.LOCALHOST6)
87 .address();
88 }
89 }
90