< prev index next >

test/jdk/java/net/ServerSocket/AcceptInheritHandle.java

Print this page
*** 1,7 ***
  /*
!  * Copyright (c) 2015, 2019, 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
   * under the terms of the GNU General Public License version 2 only, as
   * published by the Free Software Foundation.
--- 1,7 ---
  /*
!  * 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
   * under the terms of the GNU General Public License version 2 only, as
   * published by the Free Software Foundation.

*** 32,14 ***
--- 32,16 ---
  import java.io.*;
  import java.net.*;
  import java.nio.channels.ServerSocketChannel;
  import java.util.ArrayList;
  import java.util.Arrays;
+ import java.util.Collections;
  import java.util.List;
  import java.util.concurrent.TimeUnit;
  import java.util.function.Supplier;
  import jdk.test.lib.net.IPSupport;
+ import jdk.test.lib.process.ProcessTools;
  
  public class AcceptInheritHandle {
  
      enum ServerSocketProducer {
          JAVA_NET(() -> {

*** 93,20 ***
  
      static void test(ServerSocketProducer ssp, String... jvmArgs) throws Exception {
          System.out.println("\nStarting test for " + ssp.name());
  
          List<String> commands = new ArrayList<>();
!         commands.add(JAVA);
-         for (String arg : jvmArgs)
-             commands.add(arg);
-         commands.add("-cp");
-         commands.add(CLASSPATH);
          commands.add("AcceptInheritHandle");
          commands.add(ssp.name());
  
          System.out.println("Executing: "+ commands);
!         ProcessBuilder pb = new ProcessBuilder(commands);
          pb.redirectError(ProcessBuilder.Redirect.INHERIT);
          Process serverProcess = pb.start();
          DataInputStream dis = new DataInputStream(serverProcess.getInputStream());
  
          int port = dis.readInt();
--- 95,16 ---
  
      static void test(ServerSocketProducer ssp, String... jvmArgs) throws Exception {
          System.out.println("\nStarting test for " + ssp.name());
  
          List<String> commands = new ArrayList<>();
!         Collections.addAll(commands, jvmArgs);
          commands.add("AcceptInheritHandle");
          commands.add(ssp.name());
  
          System.out.println("Executing: "+ commands);
!         ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder(commands);
          pb.redirectError(ProcessBuilder.Redirect.INHERIT);
          Process serverProcess = pb.start();
          DataInputStream dis = new DataInputStream(serverProcess.getInputStream());
  
          int port = dis.readInt();
< prev index next >