File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed
graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/socket Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change 50
50
import com .oracle .graal .python .builtins .objects .PNone ;
51
51
import com .oracle .graal .python .builtins .objects .object .PythonBuiltinObject ;
52
52
import com .oracle .graal .python .builtins .objects .type .LazyPythonClass ;
53
+ import com .oracle .truffle .api .CompilerDirectives ;
54
+ import com .oracle .truffle .api .CompilerDirectives .CompilationFinal ;
53
55
import com .oracle .truffle .api .CompilerDirectives .TruffleBoundary ;
54
56
55
57
public class PSocket extends PythonBuiltinObject implements Channel {
@@ -81,7 +83,14 @@ public class PSocket extends PythonBuiltinObject implements Channel {
81
83
82
84
public static final int IPPROTO_TCP = 6 ;
83
85
84
- private static final InetSocketAddress EPHEMERAL_ADDRESS = new InetSocketAddress (0 );
86
+ @ CompilationFinal private static InetSocketAddress EPHEMERAL_ADDRESS ;
87
+ private static InetSocketAddress getEphemeralAddress () {
88
+ if (EPHEMERAL_ADDRESS == null ) {
89
+ CompilerDirectives .transferToInterpreterAndInvalidate ();
90
+ EPHEMERAL_ADDRESS = new InetSocketAddress (0 );
91
+ }
92
+ return EPHEMERAL_ADDRESS ;
93
+ }
85
94
86
95
private final int family ;
87
96
private final int type ;
@@ -94,7 +103,7 @@ public class PSocket extends PythonBuiltinObject implements Channel {
94
103
95
104
private double timeout ;
96
105
97
- private InetSocketAddress address = EPHEMERAL_ADDRESS ;
106
+ private InetSocketAddress address = getEphemeralAddress () ;
98
107
99
108
private SocketChannel socket ;
100
109
You can’t perform that action at this time.
0 commit comments