diff --git a/test/hotspot/jtreg/compiler/compilercontrol/share/actions/BaseAction.java b/test/hotspot/jtreg/compiler/compilercontrol/share/actions/BaseAction.java index 424e7e80ad0d1..67e4263d3ae17 100644 --- a/test/hotspot/jtreg/compiler/compilercontrol/share/actions/BaseAction.java +++ b/test/hotspot/jtreg/compiler/compilercontrol/share/actions/BaseAction.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -87,7 +87,7 @@ protected void communicate(String[] args) { System.out.println("INFO: Client connection port = " + port); List lines; try ( - Socket socket = new Socket(InetAddress.getLocalHost(), port); + Socket socket = new Socket(InetAddress.getLoopbackAddress(), port); BufferedReader in = new BufferedReader( new InputStreamReader(socket.getInputStream())); PrintWriter out = new PrintWriter( diff --git a/test/hotspot/jtreg/compiler/compilercontrol/share/scenario/Executor.java b/test/hotspot/jtreg/compiler/compilercontrol/share/scenario/Executor.java index 799fabf95090c..9b5b68b98c75d 100644 --- a/test/hotspot/jtreg/compiler/compilercontrol/share/scenario/Executor.java +++ b/test/hotspot/jtreg/compiler/compilercontrol/share/scenario/Executor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,6 +36,8 @@ import java.io.InputStreamReader; import java.io.PrintWriter; import java.lang.reflect.Executable; +import java.net.InetAddress; +import java.net.InetSocketAddress; import java.net.ServerSocket; import java.net.Socket; import java.util.ArrayList; @@ -80,8 +82,9 @@ public List execute() { // Add class name that would be executed in a separate VM vmOptions.add(execClass); OutputAnalyzer output; - try (ServerSocket serverSocket = new ServerSocket(0)) { + try (ServerSocket serverSocket = new ServerSocket()) { { + serverSocket.bind(new InetSocketAddress(InetAddress.getLoopbackAddress(), 0)); // Get port test VM will connect to int port = serverSocket.getLocalPort(); if (port == -1) {