8231171: remove remaining sun.java.launcher.pid references
authormbaesken
Fri, 20 Sep 2019 10:28:48 +0200
changeset 58280 ef8c8cf9256a
parent 58279 448fe2bfd505
child 58281 49836127542b
8231171: remove remaining sun.java.launcher.pid references Reviewed-by: alanb, dholmes
src/hotspot/os/bsd/os_bsd.cpp
src/hotspot/share/runtime/arguments.cpp
src/hotspot/share/runtime/arguments.hpp
src/java.base/macosx/native/libjli/java_md_macosx.m
src/java.base/share/native/libjli/java.c
src/java.base/share/native/libjli/java.h
src/java.base/unix/native/libjli/java_md_solinux.c
src/java.base/windows/native/libjli/java_md.c
test/jdk/tools/launcher/TestSpecialArgs.java
--- a/src/hotspot/os/bsd/os_bsd.cpp	Tue Sep 24 08:54:39 2019 +0200
+++ b/src/hotspot/os/bsd/os_bsd.cpp	Fri Sep 20 10:28:48 2019 +0200
@@ -136,8 +136,6 @@
 static sigset_t check_signal_done;
 static bool check_signals = true;
 
-static pid_t _initial_pid = 0;
-
 // Signal number used to suspend/resume a thread
 
 // do not use any signal number less than SIGSEGV, see 4355769
@@ -1124,24 +1122,7 @@
 }
 
 int os::current_process_id() {
-
-  // Under the old bsd thread library, bsd gives each thread
-  // its own process id. Because of this each thread will return
-  // a different pid if this method were to return the result
-  // of getpid(2). Bsd provides no api that returns the pid
-  // of the launcher thread for the vm. This implementation
-  // returns a unique pid, the pid of the launcher thread
-  // that starts the vm 'process'.
-
-  // Under the NPTL, getpid() returns the same pid as the
-  // launcher thread rather than a unique pid per thread.
-  // Use gettid() if you want the old pre NPTL behaviour.
-
-  // if you are looking for the result of a call to getpid() that
-  // returns a unique pid for the calling thread, then look at the
-  // OSThread::thread_id() method in osThread_bsd.hpp file
-
-  return (int)(_initial_pid ? _initial_pid : getpid());
+  return (int)(getpid());
 }
 
 // DLL functions
@@ -3087,16 +3068,6 @@
 void os::init(void) {
   char dummy;   // used to get a guess on initial stack address
 
-  // With BsdThreads the JavaMain thread pid (primordial thread)
-  // is different than the pid of the java launcher thread.
-  // So, on Bsd, the launcher thread pid is passed to the VM
-  // via the sun.java.launcher.pid property.
-  // Use this property instead of getpid() if it was correctly passed.
-  // See bug 6351349.
-  pid_t java_launcher_pid = (pid_t) Arguments::sun_java_launcher_pid();
-
-  _initial_pid = (java_launcher_pid > 0) ? java_launcher_pid : getpid();
-
   clock_tics_per_sec = CLK_TCK;
 
   init_random(1234567);
--- a/src/hotspot/share/runtime/arguments.cpp	Tue Sep 24 08:54:39 2019 +0200
+++ b/src/hotspot/share/runtime/arguments.cpp	Fri Sep 20 10:28:48 2019 +0200
@@ -82,7 +82,6 @@
 bool   Arguments::_xdebug_mode                  = false;
 const char*  Arguments::_java_vendor_url_bug    = DEFAULT_VENDOR_URL_BUG;
 const char*  Arguments::_sun_java_launcher      = DEFAULT_JAVA_LAUNCHER;
-int    Arguments::_sun_java_launcher_pid        = -1;
 bool   Arguments::_sun_java_launcher_is_altjvm  = false;
 
 // These parameters are reset in method parse_vm_init_args()
@@ -361,8 +360,7 @@
 
 // Process java launcher properties.
 void Arguments::process_sun_java_launcher_properties(JavaVMInitArgs* args) {
-  // See if sun.java.launcher, sun.java.launcher.is_altjvm or
-  // sun.java.launcher.pid is defined.
+  // See if sun.java.launcher or sun.java.launcher.is_altjvm is defined.
   // Must do this before setting up other system properties,
   // as some of them may depend on launcher type.
   for (int index = 0; index < args->nOptions; index++) {
@@ -379,10 +377,6 @@
       }
       continue;
     }
-    if (match_option(option, "-Dsun.java.launcher.pid=", &tail)) {
-      _sun_java_launcher_pid = atoi(tail);
-      continue;
-    }
   }
 }
 
@@ -1411,10 +1405,9 @@
   if (strcmp(key, "java.compiler") == 0) {
     process_java_compiler_argument(value);
     // Record value in Arguments, but let it get passed to Java.
-  } else if (strcmp(key, "sun.java.launcher.is_altjvm") == 0 ||
-             strcmp(key, "sun.java.launcher.pid") == 0) {
-    // sun.java.launcher.is_altjvm and sun.java.launcher.pid property are
-    // private and are processed in process_sun_java_launcher_properties();
+  } else if (strcmp(key, "sun.java.launcher.is_altjvm") == 0) {
+    // sun.java.launcher.is_altjvm property is
+    // private and is processed in process_sun_java_launcher_properties();
     // the sun.java.launcher property is passed on to the java application
   } else if (strcmp(key, "sun.boot.library.path") == 0) {
     // append is true, writable is true, internal is false
--- a/src/hotspot/share/runtime/arguments.hpp	Tue Sep 24 08:54:39 2019 +0200
+++ b/src/hotspot/share/runtime/arguments.hpp	Fri Sep 20 10:28:48 2019 +0200
@@ -322,9 +322,6 @@
   // java launcher
   static const char* _sun_java_launcher;
 
-  // sun.java.launcher.pid, private property
-  static int    _sun_java_launcher_pid;
-
   // was this VM created via the -XXaltjvm=<path> option
   static bool   _sun_java_launcher_is_altjvm;
 
@@ -548,8 +545,6 @@
   static bool created_by_java_launcher();
   // -Dsun.java.launcher.is_altjvm
   static bool sun_java_launcher_is_altjvm();
-  // -Dsun.java.launcher.pid
-  static int sun_java_launcher_pid()        { return _sun_java_launcher_pid; }
 
   // -Xrun
   static AgentLibrary* libraries()          { return _libraryList.first(); }
--- a/src/java.base/macosx/native/libjli/java_md_macosx.m	Tue Sep 24 08:54:39 2019 +0200
+++ b/src/java.base/macosx/native/libjli/java_md_macosx.m	Fri Sep 20 10:28:48 2019 +0200
@@ -757,10 +757,6 @@
     return rslt;
 }
 
-void SetJavaLauncherPlatformProps() {
-   /* Linux only */
-}
-
 static JavaVM* jvmInstance = NULL;
 static jboolean sameThread = JNI_FALSE; /* start VM in current thread */
 
--- a/src/java.base/share/native/libjli/java.c	Tue Sep 24 08:54:39 2019 +0200
+++ b/src/java.base/share/native/libjli/java.c	Fri Sep 20 10:28:48 2019 +0200
@@ -338,9 +338,6 @@
     /* Set the -Dsun.java.launcher pseudo property */
     SetJavaLauncherProp();
 
-    /* set the -Dsun.java.launcher.* platform properties */
-    SetJavaLauncherPlatformProps();
-
     return JVMInit(&ifn, threadStackSize, argc, argv, mode, what, ret);
 }
 /*
--- a/src/java.base/share/native/libjli/java.h	Tue Sep 24 08:54:39 2019 +0200
+++ b/src/java.base/share/native/libjli/java.h	Fri Sep 20 10:28:48 2019 +0200
@@ -161,7 +161,6 @@
 int CallJavaMainInNewThread(jlong stack_size, void* args);
 
 /* sun.java.launcher.* platform properties. */
-void SetJavaLauncherPlatformProps(void);
 void SetJavaCommandLineProp(char* what, int argc, char** argv);
 void SetJavaLauncherProp(void);
 
--- a/src/java.base/unix/native/libjli/java_md_solinux.c	Tue Sep 24 08:54:39 2019 +0200
+++ b/src/java.base/unix/native/libjli/java_md_solinux.c	Fri Sep 20 10:28:48 2019 +0200
@@ -790,16 +790,6 @@
 /* Coarse estimation of number of digits assuming the worst case is a 64-bit pid. */
 #define MAX_PID_STR_SZ   20
 
-void SetJavaLauncherPlatformProps() {
-   /* Linux only */
-#ifdef __linux__
-    const char *substr = "-Dsun.java.launcher.pid=";
-    char *pid_prop_str = (char *)JLI_MemAlloc(JLI_StrLen(substr) + MAX_PID_STR_SZ + 1);
-    sprintf(pid_prop_str, "%s%d", substr, getpid());
-    AddOption(pid_prop_str, NULL);
-#endif /* __linux__ */
-}
-
 int
 JVMInit(InvocationFunctions* ifn, jlong threadStackSize,
         int argc, char **argv,
--- a/src/java.base/windows/native/libjli/java_md.c	Tue Sep 24 08:54:39 2019 +0200
+++ b/src/java.base/windows/native/libjli/java_md.c	Fri Sep 20 10:28:48 2019 +0200
@@ -803,9 +803,6 @@
     return rslt;
 }
 
-/* Unix only, empty on windows. */
-void SetJavaLauncherPlatformProps() {}
-
 /*
  * The implementation for finding classes from the bootstrap
  * class loader, refer to java.h
--- a/test/jdk/tools/launcher/TestSpecialArgs.java	Tue Sep 24 08:54:39 2019 +0200
+++ b/test/jdk/tools/launcher/TestSpecialArgs.java	Fri Sep 20 10:28:48 2019 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 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
@@ -132,11 +132,9 @@
          *       Code to create env variable not executed.
          * 4) give and invalid value and check to make sure JVM commented
          */
-        String launcherPidString = "launcher.pid=";
         String envVarPidString = "TRACER_MARKER: NativeMemoryTracking: env var is NMT_LEVEL_";
         String NMT_Option_Value = "off";
         String myClassName = "helloworld";
-        boolean haveLauncherPid = false;
 
         // === Run the tests ===
         // ---Test 1a
@@ -163,46 +161,6 @@
             throw new RuntimeException("Error: env Var Pid in tracking info is empty string");
         }
 
-        /*
-         * On Linux, Launcher Tracking will print the PID.  Use this info
-         * to validate what we got as the PID in the Launcher itself.
-         * Linux is the only one that prints this, and trying to get it
-         * here for win is awful.  So let the linux test make sure we get
-         * the valid pid, and for non-linux, just make sure pid string is
-         * non-zero.
-         */
-        if (isLinux) {
-            // get what the test says is the launcher pid
-            String launcherPid = null;
-            for (String line : tr.testOutput) {
-                int index = line.indexOf(launcherPidString);
-                if (index >= 0) {
-                    int sindex = index + launcherPidString.length();
-                    int tindex = sindex + line.substring(sindex).indexOf("'");
-                    System.out.println("DEBUG INFO: sindex = " + sindex);
-                    System.out.println("DEBUG INFO: searching substring: " + line.substring(sindex));
-                    System.out.println("DEBUG INFO: tindex = " + tindex);
-                    // DEBUG INFO
-                    System.out.println(tr);
-                    launcherPid = line.substring(sindex, tindex);
-                    break;
-                }
-            }
-            if (launcherPid == null) {
-                System.out.println(tr);
-                throw new RuntimeException("Error: failed to find launcher Pid in launcher tracking info");
-            }
-
-            // did we create the env var with the correct pid?
-            if (!launcherPid.equals(envVarPid)) {
-                System.out.println(tr);
-                System.out.println("Error: wrong pid in creating env var");
-                System.out.println("Error Info: launcherPid = " + launcherPid);
-                System.out.println("Error Info: envVarPid   = " + envVarPid);
-                throw new RuntimeException("Error: wrong pid in creating env var");
-            }
-        }
-
         // --- Test 1b
         if (!tr.contains("NativeMemoryTracking: got value " + NMT_Option_Value)) {
             System.out.println(tr);