Skip to content

Commit 8c26d02

Browse files
committed
8295315: [REDO] 8276687 Remove support for JDK 1.4.1 PerfData shared memory files
Reviewed-by: dholmes, kevinw, sspitsyn
1 parent 8752bb4 commit 8c26d02

File tree

3 files changed

+8
-80
lines changed

3 files changed

+8
-80
lines changed

src/jdk.internal.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/protocol/local/LocalVmManager.java

+3-27
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2004, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2004, 2022, 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
@@ -44,7 +44,6 @@
4444
public class LocalVmManager {
4545
private FilenameFilter userDirFilter;
4646
private FilenameFilter userDirFileFilter;
47-
private FilenameFilter oldtmpFileFilter;
4847

4948
/**
5049
* Creates a LocalVmManager instance for the local system.
@@ -53,7 +52,7 @@ public class LocalVmManager {
5352
* has appropriate permissions.
5453
*/
5554
public LocalVmManager() {
56-
// 1.4.2 and later: The files are in {tmpdir}/hsperfdata_{any_user_name}/[0-9]+
55+
// The files are in {tmpdir}/hsperfdata_{any_user_name}/[0-9]+
5756
Pattern userDirPattern = Pattern.compile(PerfDataFile.userDirNamePattern);
5857
userDirFilter = new FilenameFilter() {
5958
public boolean accept(File dir, String name) {
@@ -67,15 +66,6 @@ public boolean accept(File dir, String name) {
6766
return userDirFilePattern.matcher(name).matches();
6867
}
6968
};
70-
71-
// 1.4.1 (or earlier?): the files are stored directly under {tmpdir}/ with
72-
// the following pattern.
73-
Pattern oldtmpFilePattern = Pattern.compile(PerfDataFile.tmpFileNamePattern);
74-
oldtmpFileFilter = new FilenameFilter() {
75-
public boolean accept(File dir, String name) {
76-
return oldtmpFilePattern.matcher(name).matches();
77-
}
78-
};
7969
}
8070

8171
/**
@@ -100,7 +90,7 @@ public synchronized Set<Integer> activeVms() {
10090
}
10191

10292

103-
// 1.4.2 and later: Look for the files {tmpdir}/hsperfdata_{any_user_name}/[0-9]+
93+
// Look for the files {tmpdir}/hsperfdata_{any_user_name}/[0-9]+
10494
// that are readable by the current user.
10595
File[] dirs = tmpdir.listFiles(userDirFilter);
10696
for (File subDir : dirs) {
@@ -121,20 +111,6 @@ public synchronized Set<Integer> activeVms() {
121111
}
122112
}
123113
}
124-
125-
// look for any 1.4.1 files that are readable by the current user.
126-
File[] files = tmpdir.listFiles(oldtmpFileFilter);
127-
if (files != null) {
128-
for (File file : files) {
129-
if (file.isFile() && file.canRead()) {
130-
int vmid = PerfDataFile.getLocalVmId(file);
131-
if (vmid != -1) {
132-
jvmSet.add(vmid);
133-
}
134-
}
135-
}
136-
}
137-
138114
}
139115
return jvmSet;
140116
}

src/jdk.internal.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/protocol/local/PerfDataBuffer.java

+1-26
Original file line numberDiff line numberDiff line change
@@ -61,34 +61,9 @@ public class PerfDataBuffer extends AbstractPerfDataBuffer {
6161
*/
6262
public PerfDataBuffer(VmIdentifier vmid) throws MonitorException {
6363
try {
64-
// Try 1.4.2 and later first
6564
ByteBuffer bb = perf.attach(vmid.getLocalVmId());
6665
createPerfDataBuffer(bb, vmid.getLocalVmId());
67-
68-
} catch (IllegalArgumentException e) {
69-
// now try 1.4.1 by attempting to directly map the files.
70-
try {
71-
String filename = PerfDataFile.getTempDirectory()
72-
+ PerfDataFile.dirNamePrefix
73-
+ Integer.toString(vmid.getLocalVmId());
74-
75-
File f = new File(filename);
76-
77-
FileChannel fc = new RandomAccessFile(f, "r").getChannel();
78-
ByteBuffer bb = fc.map(FileChannel.MapMode.READ_ONLY, 0L,
79-
(int)fc.size());
80-
fc.close();
81-
createPerfDataBuffer(bb, vmid.getLocalVmId());
82-
83-
} catch (FileNotFoundException e2) {
84-
// re-throw the exception from the 1.4.2 attach method
85-
throw new MonitorException(vmid.getLocalVmId() + " not found",
86-
e);
87-
} catch (IOException e2) {
88-
throw new MonitorException("Could not map 1.4.1 file for "
89-
+ vmid.getLocalVmId(), e2);
90-
}
91-
} catch (IOException e) {
66+
} catch (IOException | IllegalArgumentException e) {
9267
throw new MonitorException("Could not attach to "
9368
+ vmid.getLocalVmId(), e);
9469
}

src/jdk.internal.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/protocol/local/PerfDataFile.java

+4-27
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2004, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2004, 2022, 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
@@ -64,20 +64,11 @@ public class PerfDataFile {
6464
* The file name pattern for PerfData shared memory files.
6565
* <p>
6666
* This pattern must be kept in synch with the file name pattern
67-
* used by the 1.4.2 and later HotSpot JVM.
67+
* used by the 1.4.2 and later HotSpot JVM. Earlier versions are
68+
* no longer supported.
6869
*/
6970
public static final String fileNamePattern = "^[0-9]+$";
7071

71-
/**
72-
* The file name pattern for 1.4.1 PerfData shared memory files.
73-
* <p>
74-
* This pattern must be kept in synch with the file name pattern
75-
* used by the 1.4.1 HotSpot JVM.
76-
*/
77-
public static final String tmpFileNamePattern =
78-
"^hsperfdata_[0-9]+(_[1-2]+)?$";
79-
80-
8172
/**
8273
* Platform Specific methods for looking up temporary directories
8374
* and process IDs.
@@ -97,24 +88,10 @@ public class PerfDataFile {
9788
*/
9889
public static int getLocalVmId(File file) {
9990
try {
100-
// try 1.4.2 and later format first
10191
return(platSupport.getLocalVmId(file));
10292
} catch (NumberFormatException e) { }
10393

104-
// now try the 1.4.1 format
105-
String name = file.getName();
106-
if (name.startsWith(dirNamePrefix)) {
107-
int first = name.indexOf('_');
108-
int last = name.lastIndexOf('_');
109-
try {
110-
if (first == last) {
111-
return Integer.parseInt(name.substring(first + 1));
112-
} else {
113-
return Integer.parseInt(name.substring(first + 1, last));
114-
}
115-
} catch (NumberFormatException e) { }
116-
}
117-
throw new IllegalArgumentException("file name does not match pattern");
94+
throw new IllegalArgumentException("Cannot convert '" + file + "' to VM id");
11895
}
11996

12097
/**

0 commit comments

Comments
 (0)