Skip to content

Commit e2ebf7b

Browse files
committed
8231171: remove remaining sun.java.launcher.pid references
Reviewed-by: alanb, dholmes
1 parent bb56c02 commit e2ebf7b

File tree

9 files changed

+6
-110
lines changed

9 files changed

+6
-110
lines changed

src/hotspot/os/bsd/os_bsd.cpp

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,6 @@ static int clock_tics_per_sec = 100;
136136
static sigset_t check_signal_done;
137137
static bool check_signals = true;
138138

139-
static pid_t _initial_pid = 0;
140-
141139
// Signal number used to suspend/resume a thread
142140

143141
// do not use any signal number less than SIGSEGV, see 4355769
@@ -1124,24 +1122,7 @@ intx os::current_thread_id() {
11241122
}
11251123

11261124
int os::current_process_id() {
1127-
1128-
// Under the old bsd thread library, bsd gives each thread
1129-
// its own process id. Because of this each thread will return
1130-
// a different pid if this method were to return the result
1131-
// of getpid(2). Bsd provides no api that returns the pid
1132-
// of the launcher thread for the vm. This implementation
1133-
// returns a unique pid, the pid of the launcher thread
1134-
// that starts the vm 'process'.
1135-
1136-
// Under the NPTL, getpid() returns the same pid as the
1137-
// launcher thread rather than a unique pid per thread.
1138-
// Use gettid() if you want the old pre NPTL behaviour.
1139-
1140-
// if you are looking for the result of a call to getpid() that
1141-
// returns a unique pid for the calling thread, then look at the
1142-
// OSThread::thread_id() method in osThread_bsd.hpp file
1143-
1144-
return (int)(_initial_pid ? _initial_pid : getpid());
1125+
return (int)(getpid());
11451126
}
11461127

11471128
// DLL functions
@@ -3087,16 +3068,6 @@ extern void report_error(char* file_name, int line_no, char* title,
30873068
void os::init(void) {
30883069
char dummy; // used to get a guess on initial stack address
30893070

3090-
// With BsdThreads the JavaMain thread pid (primordial thread)
3091-
// is different than the pid of the java launcher thread.
3092-
// So, on Bsd, the launcher thread pid is passed to the VM
3093-
// via the sun.java.launcher.pid property.
3094-
// Use this property instead of getpid() if it was correctly passed.
3095-
// See bug 6351349.
3096-
pid_t java_launcher_pid = (pid_t) Arguments::sun_java_launcher_pid();
3097-
3098-
_initial_pid = (java_launcher_pid > 0) ? java_launcher_pid : getpid();
3099-
31003071
clock_tics_per_sec = CLK_TCK;
31013072

31023073
init_random(1234567);

src/hotspot/share/runtime/arguments.cpp

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ bool Arguments::_java_compiler = false;
8282
bool Arguments::_xdebug_mode = false;
8383
const char* Arguments::_java_vendor_url_bug = DEFAULT_VENDOR_URL_BUG;
8484
const char* Arguments::_sun_java_launcher = DEFAULT_JAVA_LAUNCHER;
85-
int Arguments::_sun_java_launcher_pid = -1;
8685
bool Arguments::_sun_java_launcher_is_altjvm = false;
8786

8887
// These parameters are reset in method parse_vm_init_args()
@@ -361,8 +360,7 @@ bool Arguments::is_internal_module_property(const char* property) {
361360

362361
// Process java launcher properties.
363362
void Arguments::process_sun_java_launcher_properties(JavaVMInitArgs* args) {
364-
// See if sun.java.launcher, sun.java.launcher.is_altjvm or
365-
// sun.java.launcher.pid is defined.
363+
// See if sun.java.launcher or sun.java.launcher.is_altjvm is defined.
366364
// Must do this before setting up other system properties,
367365
// as some of them may depend on launcher type.
368366
for (int index = 0; index < args->nOptions; index++) {
@@ -379,10 +377,6 @@ void Arguments::process_sun_java_launcher_properties(JavaVMInitArgs* args) {
379377
}
380378
continue;
381379
}
382-
if (match_option(option, "-Dsun.java.launcher.pid=", &tail)) {
383-
_sun_java_launcher_pid = atoi(tail);
384-
continue;
385-
}
386380
}
387381
}
388382

@@ -1411,10 +1405,9 @@ bool Arguments::add_property(const char* prop, PropertyWriteable writeable, Prop
14111405
if (strcmp(key, "java.compiler") == 0) {
14121406
process_java_compiler_argument(value);
14131407
// Record value in Arguments, but let it get passed to Java.
1414-
} else if (strcmp(key, "sun.java.launcher.is_altjvm") == 0 ||
1415-
strcmp(key, "sun.java.launcher.pid") == 0) {
1416-
// sun.java.launcher.is_altjvm and sun.java.launcher.pid property are
1417-
// private and are processed in process_sun_java_launcher_properties();
1408+
} else if (strcmp(key, "sun.java.launcher.is_altjvm") == 0) {
1409+
// sun.java.launcher.is_altjvm property is
1410+
// private and is processed in process_sun_java_launcher_properties();
14181411
// the sun.java.launcher property is passed on to the java application
14191412
} else if (strcmp(key, "sun.boot.library.path") == 0) {
14201413
// append is true, writable is true, internal is false

src/hotspot/share/runtime/arguments.hpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -322,9 +322,6 @@ class Arguments : AllStatic {
322322
// java launcher
323323
static const char* _sun_java_launcher;
324324

325-
// sun.java.launcher.pid, private property
326-
static int _sun_java_launcher_pid;
327-
328325
// was this VM created via the -XXaltjvm=<path> option
329326
static bool _sun_java_launcher_is_altjvm;
330327

@@ -548,8 +545,6 @@ class Arguments : AllStatic {
548545
static bool created_by_java_launcher();
549546
// -Dsun.java.launcher.is_altjvm
550547
static bool sun_java_launcher_is_altjvm();
551-
// -Dsun.java.launcher.pid
552-
static int sun_java_launcher_pid() { return _sun_java_launcher_pid; }
553548

554549
// -Xrun
555550
static AgentLibrary* libraries() { return _libraryList.first(); }

src/java.base/macosx/native/libjli/java_md_macosx.m

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -757,10 +757,6 @@ void SplashFreeLibrary() {
757757
return rslt;
758758
}
759759

760-
void SetJavaLauncherPlatformProps() {
761-
/* Linux only */
762-
}
763-
764760
static JavaVM* jvmInstance = NULL;
765761
static jboolean sameThread = JNI_FALSE; /* start VM in current thread */
766762

src/java.base/share/native/libjli/java.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -338,9 +338,6 @@ JLI_Launch(int argc, char ** argv, /* main argc, argv */
338338
/* Set the -Dsun.java.launcher pseudo property */
339339
SetJavaLauncherProp();
340340

341-
/* set the -Dsun.java.launcher.* platform properties */
342-
SetJavaLauncherPlatformProps();
343-
344341
return JVMInit(&ifn, threadStackSize, argc, argv, mode, what, ret);
345342
}
346343
/*

src/java.base/share/native/libjli/java.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,6 @@ void PrintMachineDependentOptions();
161161
int CallJavaMainInNewThread(jlong stack_size, void* args);
162162

163163
/* sun.java.launcher.* platform properties. */
164-
void SetJavaLauncherPlatformProps(void);
165164
void SetJavaCommandLineProp(char* what, int argc, char** argv);
166165
void SetJavaLauncherProp(void);
167166

src/java.base/unix/native/libjli/java_md_solinux.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -790,16 +790,6 @@ CallJavaMainInNewThread(jlong stack_size, void* args) {
790790
/* Coarse estimation of number of digits assuming the worst case is a 64-bit pid. */
791791
#define MAX_PID_STR_SZ 20
792792

793-
void SetJavaLauncherPlatformProps() {
794-
/* Linux only */
795-
#ifdef __linux__
796-
const char *substr = "-Dsun.java.launcher.pid=";
797-
char *pid_prop_str = (char *)JLI_MemAlloc(JLI_StrLen(substr) + MAX_PID_STR_SZ + 1);
798-
sprintf(pid_prop_str, "%s%d", substr, getpid());
799-
AddOption(pid_prop_str, NULL);
800-
#endif /* __linux__ */
801-
}
802-
803793
int
804794
JVMInit(InvocationFunctions* ifn, jlong threadStackSize,
805795
int argc, char **argv,

src/java.base/windows/native/libjli/java_md.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -803,9 +803,6 @@ CallJavaMainInNewThread(jlong stack_size, void* args) {
803803
return rslt;
804804
}
805805

806-
/* Unix only, empty on windows. */
807-
void SetJavaLauncherPlatformProps() {}
808-
809806
/*
810807
* The implementation for finding classes from the bootstrap
811808
* class loader, refer to java.h

test/jdk/tools/launcher/TestSpecialArgs.java

Lines changed: 1 addition & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -132,11 +132,9 @@ void testNativeMemoryTracking() {
132132
* Code to create env variable not executed.
133133
* 4) give and invalid value and check to make sure JVM commented
134134
*/
135-
String launcherPidString = "launcher.pid=";
136135
String envVarPidString = "TRACER_MARKER: NativeMemoryTracking: env var is NMT_LEVEL_";
137136
String NMT_Option_Value = "off";
138137
String myClassName = "helloworld";
139-
boolean haveLauncherPid = false;
140138

141139
// === Run the tests ===
142140
// ---Test 1a
@@ -163,46 +161,6 @@ void testNativeMemoryTracking() {
163161
throw new RuntimeException("Error: env Var Pid in tracking info is empty string");
164162
}
165163

166-
/*
167-
* On Linux, Launcher Tracking will print the PID. Use this info
168-
* to validate what we got as the PID in the Launcher itself.
169-
* Linux is the only one that prints this, and trying to get it
170-
* here for win is awful. So let the linux test make sure we get
171-
* the valid pid, and for non-linux, just make sure pid string is
172-
* non-zero.
173-
*/
174-
if (isLinux) {
175-
// get what the test says is the launcher pid
176-
String launcherPid = null;
177-
for (String line : tr.testOutput) {
178-
int index = line.indexOf(launcherPidString);
179-
if (index >= 0) {
180-
int sindex = index + launcherPidString.length();
181-
int tindex = sindex + line.substring(sindex).indexOf("'");
182-
System.out.println("DEBUG INFO: sindex = " + sindex);
183-
System.out.println("DEBUG INFO: searching substring: " + line.substring(sindex));
184-
System.out.println("DEBUG INFO: tindex = " + tindex);
185-
// DEBUG INFO
186-
System.out.println(tr);
187-
launcherPid = line.substring(sindex, tindex);
188-
break;
189-
}
190-
}
191-
if (launcherPid == null) {
192-
System.out.println(tr);
193-
throw new RuntimeException("Error: failed to find launcher Pid in launcher tracking info");
194-
}
195-
196-
// did we create the env var with the correct pid?
197-
if (!launcherPid.equals(envVarPid)) {
198-
System.out.println(tr);
199-
System.out.println("Error: wrong pid in creating env var");
200-
System.out.println("Error Info: launcherPid = " + launcherPid);
201-
System.out.println("Error Info: envVarPid = " + envVarPid);
202-
throw new RuntimeException("Error: wrong pid in creating env var");
203-
}
204-
}
205-
206164
// --- Test 1b
207165
if (!tr.contains("NativeMemoryTracking: got value " + NMT_Option_Value)) {
208166
System.out.println(tr);

0 commit comments

Comments
 (0)