On Tue, 10 May 2022 04:00:29 GMT, Ioi Lam <ik...@openjdk.org> wrote:

> The `mode` parameter for ` jdk.internal.perf.Perf.attach()` has never 
> supported the value `"rw"` since the source code was imported to the openjdk 
> repo more than 15 years ago. In fact HotSpot throws 
> `IllegalArgumentException` when such a mode is specified.
> 
> It's unlikely such a mode will be required for future enhancements. Support 
> for `"rw"` is removed. The "mode" parameter is also removed, since now `"r"` 
> is the only supported mode.
> 
> I also cleaned up related code in the JDK and HotSpot.
> 
> Testing:
> - Passed tiers 1 and 2
> - Tiers 3, 4, 5 are in progress

src/jdk.internal.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/protocol/file/PerfDataBuffer.java
 line 60:

> 58:             FileChannel fc = new RandomAccessFile(f, "r").getChannel();
> 59:             ByteBuffer bb = fc.map(FileChannel.MapMode.READ_ONLY, 0L, 
> (int)fc.size());
> 60:             fc.close();               // doesn't need to remain open

I think you can change this to:


        try (FileChannel fc = FileChannel.open(f.toPath())) {
            ByteBuffer bb = ...
            createPerfDataBuffer(bb, 0);
        }

-------------

PR: https://git.openjdk.java.net/jdk/pull/8622

Reply via email to