This commit is contained in:
Jesper Wilhelmsson 2021-07-06 00:12:23 +00:00
commit a18a112963
3 changed files with 26 additions and 22 deletions

View File

@ -412,7 +412,7 @@ void os::init_system_properties_values() {
// ...
// 7: The default directories, normally /lib and /usr/lib.
#ifndef OVERRIDE_LIBPATH
#if defined(AMD64) || (defined(_LP64) && defined(SPARC)) || defined(PPC64) || defined(S390)
#if defined(_LP64)
#define DEFAULT_LIBPATH "/usr/lib64:/lib64:/lib:/usr/lib"
#else
#define DEFAULT_LIBPATH "/lib:/usr/lib"

View File

@ -510,20 +510,19 @@ public class JPasswordField extends JTextField {
* @since 1.6
*/
public String getAtIndex(int part, int index) {
String str = null;
if (part == AccessibleText.CHARACTER) {
str = super.getAtIndex(part, index);
return getEchoString(super.getAtIndex(part, index));
} else {
// Treat the text displayed in the JPasswordField
// as one word and sentence.
char[] password = getPassword();
if (password == null ||
index < 0 || index >= password.length) {
int length = getDocument().getLength();
if (index < 0 || index >= length) {
return null;
}
str = new String(password);
char[] password = new char[length];
Arrays.fill(password, getEchoChar());
return new String(password);
}
return getEchoString(str);
}
/**
@ -544,8 +543,7 @@ public class JPasswordField extends JTextField {
*/
public String getAfterIndex(int part, int index) {
if (part == AccessibleText.CHARACTER) {
String str = super.getAfterIndex(part, index);
return getEchoString(str);
return getEchoString(super.getAfterIndex(part, index));
} else {
// There is no word or sentence after the text
// displayed in the JPasswordField.
@ -571,8 +569,7 @@ public class JPasswordField extends JTextField {
*/
public String getBeforeIndex(int part, int index) {
if (part == AccessibleText.CHARACTER) {
String str = super.getBeforeIndex(part, index);
return getEchoString(str);
return getEchoString(super.getBeforeIndex(part, index));
} else {
// There is no word or sentence before the text
// displayed in the JPasswordField.
@ -627,14 +624,14 @@ public class JPasswordField extends JTextField {
} else {
// Treat the text displayed in the JPasswordField
// as one word, sentence, line and attribute run
char[] password = getPassword();
if (password == null ||
index < 0 || index >= password.length) {
int length = getDocument().getLength();
if (index < 0 || index >= length) {
return null;
}
char[] password = new char[length];
Arrays.fill(password, getEchoChar());
String text = new String(password);
return new AccessibleTextSequence(0, password.length - 1,
getEchoString(text));
return new AccessibleTextSequence(0, password.length - 1, text);
}
}

View File

@ -33,8 +33,10 @@ import jdk.jfr.Event;
import jdk.jfr.Recording;
import jdk.jfr.consumer.RecordedEvent;
import jdk.jfr.consumer.RecordingFile;
import jdk.test.lib.JDKToolFinder;
import jdk.test.lib.jfr.EventNames;
import jdk.test.lib.process.OutputAnalyzer;
import jdk.test.lib.process.ProcessTools;
/**
* @test
@ -53,9 +55,9 @@ public class TestJcmdDump {
private static final String[] names = { null, "r1" };
private static final boolean booleanValues[] = { true, false };
private static final long timeoutMillis = 50000;
public static void main(String[] args) throws Exception {
// Create a stopped recording in the repository to complicate things
Recording r = new Recording();
r.start();
@ -105,8 +107,10 @@ public class TestJcmdDump {
leakList.add(new Object[1000_0000]);
System.gc(); // This will shorten time for object to be emitted.
File recording = new File("TestJCMdDump.jfr");
String[] params = buildParameters(pathToGCRoots, name, recording);
OutputAnalyzer output = JcmdHelper.jcmd(params);
List<String> params = buildParameters(pathToGCRoots, name, recording);
System.out.println(params);
OutputAnalyzer output = ProcessTools.executeProcess(new ProcessBuilder(params));
output.reportDiagnosticSummary();
JcmdAsserts.assertRecordingDumpedToFile(output, recording);
int rootCount = 0;
int oldObjectCount = 0;
@ -155,8 +159,11 @@ public class TestJcmdDump {
}
}
private static String[] buildParameters(Boolean pathToGCRoots, String name, File recording) {
private static List<String> buildParameters(Boolean pathToGCRoots, String name, File recording) {
List<String> params = new ArrayList<>();
params.add(JDKToolFinder.getJDKTool("jcmd"));
params.add("-J-Dsun.tools.attach.attachTimeout=" + timeoutMillis);
params.add(String.valueOf(ProcessHandle.current().pid()));
params.add("JFR.dump");
params.add("filename=" + recording.getAbsolutePath());
if (pathToGCRoots != null) { // if path-to-gc-roots is omitted, default is used (disabled).
@ -165,6 +172,6 @@ public class TestJcmdDump {
if (name != null) { // if name is omitted, all recordings will be dumped
params.add("name=" + name);
}
return params.toArray(new String[0]);
return params;
}
}