From 7efe16038e5df9894a265ea1214068060f595c4e Mon Sep 17 00:00:00 2001 From: Erik Gahlin Date: Fri, 5 Jul 2024 16:44:41 +0000 Subject: [PATCH] 8335730: JFR: Clean up jdk.jfr Reviewed-by: mgronlun --- .../share/classes/jdk/jfr/consumer/RecordedClass.java | 4 ++-- .../share/classes/jdk/jfr/consumer/RecordedFrame.java | 6 +++--- .../share/classes/jdk/jfr/consumer/RecordedMethod.java | 4 ++-- .../share/classes/jdk/jfr/consumer/RecordedObject.java | 5 ++++- .../share/classes/jdk/jfr/consumer/RecordedThread.java | 6 +++--- .../jdk/jfr/events/AbstractBufferStatisticsEvent.java | 4 ++-- .../classes/jdk/jfr/events/ActiveRecordingEvent.java | 1 - .../share/classes/jdk/jfr/events/ActiveSettingEvent.java | 1 - .../classes/jdk/jfr/events/ExceptionStatisticsEvent.java | 1 - .../share/classes/jdk/jfr/internal/EventControl.java | 1 - .../classes/jdk/jfr/internal/MetadataRepository.java | 2 -- .../share/classes/jdk/jfr/internal/OldObjectSample.java | 3 +-- .../share/classes/jdk/jfr/internal/RepositoryChunk.java | 5 +---- .../share/classes/jdk/jfr/internal/ShutdownHook.java | 2 -- .../classes/jdk/jfr/internal/dcmd/QueryRecording.java | 7 +------ src/jdk.jfr/share/classes/jdk/jfr/internal/jfc/JFC.java | 4 ++-- .../classes/jdk/jfr/internal/jfc/model/XmlSetting.java | 4 ++-- src/jdk.jfr/share/classes/jdk/jfr/internal/query/Row.java | 4 ++-- .../share/classes/jdk/jfr/internal/query/TableSorter.java | 5 +---- .../classes/jdk/jfr/internal/settings/LevelSetting.java | 4 ++-- .../share/classes/jdk/jfr/internal/tool/Disassemble.java | 8 ++++---- .../share/classes/jdk/jfr/internal/tool/PrettyWriter.java | 3 +-- src/jdk.jfr/share/classes/jdk/jfr/internal/tool/View.java | 3 +-- .../share/classes/jdk/jfr/internal/util/ValueParser.java | 4 ++-- 24 files changed, 36 insertions(+), 55 deletions(-) diff --git a/src/jdk.jfr/share/classes/jdk/jfr/consumer/RecordedClass.java b/src/jdk.jfr/share/classes/jdk/jfr/consumer/RecordedClass.java index 8d6b5647f2f..d0ae1e7d297 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/consumer/RecordedClass.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/consumer/RecordedClass.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2024, 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 @@ -49,7 +49,7 @@ public final class RecordedClass extends RecordedObject { * @see java.lang.reflect.Modifier */ public int getModifiers() { - return getTyped("modifiers", Integer.class, -1); + return getTyped("modifiers", Integer.class, INTEGER_MINUS_ONE); } /** diff --git a/src/jdk.jfr/share/classes/jdk/jfr/consumer/RecordedFrame.java b/src/jdk.jfr/share/classes/jdk/jfr/consumer/RecordedFrame.java index 9640330fca2..cdb893274ac 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/consumer/RecordedFrame.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/consumer/RecordedFrame.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2024, 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 @@ -65,7 +65,7 @@ public final class RecordedFrame extends RecordedObject { * @return byte code index, or {@code -1} if doesn't exist */ public int getBytecodeIndex() { - return getTyped("bytecodeIndex", Integer.class, Integer.valueOf(-1)); + return getTyped("bytecodeIndex", Integer.class, INTEGER_MINUS_ONE); } /** @@ -75,7 +75,7 @@ public final class RecordedFrame extends RecordedObject { * @return the line number, or {@code -1} if doesn't exist */ public int getLineNumber() { - return getTyped("lineNumber", Integer.class, Integer.valueOf(-1)); + return getTyped("lineNumber", Integer.class, INTEGER_MINUS_ONE); } /** diff --git a/src/jdk.jfr/share/classes/jdk/jfr/consumer/RecordedMethod.java b/src/jdk.jfr/share/classes/jdk/jfr/consumer/RecordedMethod.java index a82b43ffc36..6c8f23aa02a 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/consumer/RecordedMethod.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/consumer/RecordedMethod.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2024, 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 @@ -94,7 +94,7 @@ public final class RecordedMethod extends RecordedObject { * @see RecordedFrame#isJavaFrame */ public int getModifiers() { - return getTyped("modifiers", Integer.class, Integer.valueOf(0)); + return getTyped("modifiers", Integer.class, INTEGER_ZERO); } /** diff --git a/src/jdk.jfr/share/classes/jdk/jfr/consumer/RecordedObject.java b/src/jdk.jfr/share/classes/jdk/jfr/consumer/RecordedObject.java index e5825b8ea07..21bd30a8248 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/consumer/RecordedObject.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/consumer/RecordedObject.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2024, 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 @@ -154,6 +154,9 @@ public sealed class RecordedObject private static final record UnsignedValue(Object value) { } + static final Integer INTEGER_MINUS_ONE = Integer.valueOf(-1); + static final Integer INTEGER_ZERO = Integer.valueOf(0); + static final Long LONG_MINUS_ONE = Long.valueOf(-1L); final Object[] objects; final ObjectContext objectContext; diff --git a/src/jdk.jfr/share/classes/jdk/jfr/consumer/RecordedThread.java b/src/jdk.jfr/share/classes/jdk/jfr/consumer/RecordedThread.java index 4031e70d24b..d12d65faf10 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/consumer/RecordedThread.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/consumer/RecordedThread.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2024, 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 @@ -59,7 +59,7 @@ public final class RecordedThread extends RecordedObject { if (isVirtual()) { return -1L; } - Long l = getTyped("osThreadId", Long.class, -1L); + Long l = getTyped("osThreadId", Long.class, LONG_MINUS_ONE); return l.longValue(); } @@ -92,7 +92,7 @@ public final class RecordedThread extends RecordedObject { * @see java.lang.Thread#threadId() */ public long getJavaThreadId() { - Long l = getTyped("javaThreadId", Long.class, -1L); + Long l = getTyped("javaThreadId", Long.class, LONG_MINUS_ONE); long id = l.longValue(); return id == 0 ? -1L : id; } diff --git a/src/jdk.jfr/share/classes/jdk/jfr/events/AbstractBufferStatisticsEvent.java b/src/jdk.jfr/share/classes/jdk/jfr/events/AbstractBufferStatisticsEvent.java index d436b32db83..f7a03c7446e 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/events/AbstractBufferStatisticsEvent.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/events/AbstractBufferStatisticsEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, 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 @@ -30,7 +30,7 @@ import jdk.internal.misc.VM; import jdk.jfr.*; @Category({ "Java Application", "Statistics" }) -public abstract class AbstractBufferStatisticsEvent extends AbstractPeriodicEvent { +abstract class AbstractBufferStatisticsEvent extends AbstractPeriodicEvent { protected AbstractBufferStatisticsEvent(BufferPool bufferPool) { count = bufferPool.getCount(); diff --git a/src/jdk.jfr/share/classes/jdk/jfr/events/ActiveRecordingEvent.java b/src/jdk.jfr/share/classes/jdk/jfr/events/ActiveRecordingEvent.java index 352a8b6a073..ffb45caa42c 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/events/ActiveRecordingEvent.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/events/ActiveRecordingEvent.java @@ -29,7 +29,6 @@ import jdk.jfr.Category; import jdk.jfr.Label; import jdk.jfr.DataAmount; import jdk.jfr.Name; -import jdk.jfr.StackTrace; import jdk.jfr.Timespan; import jdk.jfr.Timestamp; import jdk.jfr.internal.RemoveFields; diff --git a/src/jdk.jfr/share/classes/jdk/jfr/events/ActiveSettingEvent.java b/src/jdk.jfr/share/classes/jdk/jfr/events/ActiveSettingEvent.java index 3658b06eb14..6aade8e01f5 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/events/ActiveSettingEvent.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/events/ActiveSettingEvent.java @@ -28,7 +28,6 @@ package jdk.jfr.events; import jdk.jfr.Category; import jdk.jfr.Label; import jdk.jfr.Name; -import jdk.jfr.StackTrace; import jdk.jfr.internal.RemoveFields; import jdk.jfr.internal.Type; diff --git a/src/jdk.jfr/share/classes/jdk/jfr/events/ExceptionStatisticsEvent.java b/src/jdk.jfr/share/classes/jdk/jfr/events/ExceptionStatisticsEvent.java index 795f618b4e6..0cdd9872271 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/events/ExceptionStatisticsEvent.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/events/ExceptionStatisticsEvent.java @@ -29,7 +29,6 @@ import jdk.jfr.Category; import jdk.jfr.Description; import jdk.jfr.Label; import jdk.jfr.Name; -import jdk.jfr.StackTrace; import jdk.jfr.internal.MirrorEvent; import jdk.jfr.internal.RemoveFields; import jdk.jfr.internal.Type; diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/EventControl.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/EventControl.java index 2a758aa8add..71569c30273 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/EventControl.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/EventControl.java @@ -46,7 +46,6 @@ import jdk.jfr.StackTrace; import jdk.jfr.Threshold; import jdk.jfr.events.ActiveSettingEvent; import jdk.jfr.events.StackFilter; -import jdk.jfr.internal.JVM; import jdk.jfr.internal.settings.CutoffSetting; import jdk.jfr.internal.settings.EnabledSetting; import jdk.jfr.internal.settings.LevelSetting; diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/MetadataRepository.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/MetadataRepository.java index 75be70a0d1d..4a7bc734d75 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/MetadataRepository.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/MetadataRepository.java @@ -44,8 +44,6 @@ import jdk.jfr.Event; import jdk.jfr.EventType; import jdk.jfr.Name; import jdk.jfr.Period; -import jdk.jfr.StackTrace; -import jdk.jfr.Threshold; import jdk.jfr.ValueDescriptor; import jdk.jfr.internal.consumer.RepositoryFiles; import jdk.jfr.internal.event.EventConfiguration; diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/OldObjectSample.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/OldObjectSample.java index 5fa9eb709ef..21079fab3a9 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/OldObjectSample.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/OldObjectSample.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2024, 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 @@ -33,7 +33,6 @@ import jdk.jfr.Enabled; import jdk.jfr.RecordingState; import jdk.jfr.internal.settings.CutoffSetting; import jdk.jfr.internal.test.WhiteBox; -import jdk.jfr.internal.util.Utils; // The Old Object event could have been implemented as a periodic event, but // due to chunk rotations and how settings are calculated when multiple recordings diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/RepositoryChunk.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/RepositoryChunk.java index 72d3a719452..e46b6020d5d 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/RepositoryChunk.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/RepositoryChunk.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2024, 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 @@ -29,10 +29,7 @@ import java.io.IOException; import java.io.RandomAccessFile; import java.nio.channels.ReadableByteChannel; import java.time.Instant; -import java.time.Period; -import java.time.Duration; import java.util.Comparator; -import java.util.Optional; import jdk.jfr.internal.SecuritySupport.SafePath; diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/ShutdownHook.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/ShutdownHook.java index afd9ec09bd9..8375dab0bcc 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/ShutdownHook.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/ShutdownHook.java @@ -25,14 +25,12 @@ package jdk.jfr.internal; -import java.io.IOException; import java.security.AccessControlContext; import java.security.AccessController; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import jdk.jfr.RecordingState; -import jdk.jfr.internal.util.Utils; /** * Class responsible for dumping recordings on exit diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/QueryRecording.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/QueryRecording.java index 75fefca0f08..fa60079b522 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/QueryRecording.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/QueryRecording.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2024, 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 @@ -27,7 +27,6 @@ package jdk.jfr.internal.dcmd; import java.io.IOException; import java.time.Duration; import java.time.Instant; -import java.util.ArrayList; import java.util.List; import java.util.ListIterator; @@ -37,12 +36,8 @@ import jdk.jfr.internal.PlatformRecorder; import jdk.jfr.internal.PrivateAccess; import jdk.jfr.internal.RepositoryChunk; import jdk.jfr.internal.query.Configuration; -import jdk.jfr.internal.query.QueryPrinter; -import jdk.jfr.internal.query.ViewPrinter; import jdk.jfr.internal.query.Configuration.Truncate; import jdk.jfr.internal.util.UserDataException; -import jdk.jfr.internal.util.UserSyntaxException; -import jdk.jfr.internal.util.Output; /** * Helper class that holds recording chunks alive during a query. It also helps diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/jfc/JFC.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/jfc/JFC.java index 6d7cccfb2a6..0511ce57001 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/jfc/JFC.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/jfc/JFC.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2024, 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 @@ -293,7 +293,7 @@ public final class JFC { public static String formatException(String prefix, Exception e, String input) { String message = prefix + " " + JFC.exceptionToVerb(e) + " file '" + input + "'"; String details = e.getMessage(); - if (e instanceof JFCModelException m) { + if (e instanceof JFCModelException) { return message + ". " + details; } if (e instanceof ParseException && !details.isEmpty()) { diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/jfc/model/XmlSetting.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/jfc/model/XmlSetting.java index 56f2208ded3..536c5051f54 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/jfc/model/XmlSetting.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/jfc/model/XmlSetting.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2024, 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 @@ -59,7 +59,7 @@ final class XmlSetting extends XmlElement { @Override final void setContent(String value) { super.setContent(value); - if (getParent() instanceof XmlEvent event) { + if (getParent() instanceof XmlEvent) { SettingsLog.log(this, value); } } diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/query/Row.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/query/Row.java index da32f86c171..cb54b6b651a 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/query/Row.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/query/Row.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2024, 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 @@ -53,6 +53,6 @@ final class Row { @Override public String toString() { - return Arrays.asList(values).toString(); + return Arrays.toString(values); } } diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/query/TableSorter.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/query/TableSorter.java index 65f664018ba..88695162809 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/query/TableSorter.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/query/TableSorter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2024, 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 @@ -24,10 +24,7 @@ */ package jdk.jfr.internal.query; -import java.util.ArrayList; -import java.util.Collections; import java.util.Comparator; -import java.util.List; import java.util.function.Predicate; import jdk.jfr.internal.query.Query.OrderElement; diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/settings/LevelSetting.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/settings/LevelSetting.java index acf67c0aa06..b6aa7500d4b 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/settings/LevelSetting.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/settings/LevelSetting.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2024, 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 @@ -39,7 +39,7 @@ import jdk.jfr.internal.Type; @MetadataDefinition @Label("Level") @Name(Type.SETTINGS_PREFIX + "Level") -public class LevelSetting extends JDKSettingControl { +public final class LevelSetting extends JDKSettingControl { private final PlatformEventType eventType; private final List levels; private String value; diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/tool/Disassemble.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/tool/Disassemble.java index 06616771cf9..48dd5247568 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/tool/Disassemble.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/tool/Disassemble.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2024, 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 @@ -223,9 +223,9 @@ final class Disassemble extends Command { Path p = directory.resolve(formattedFilename); File splittedFile = p.toFile(); println("Writing " + splittedFile + " ... " + bytes.length); - FileOutputStream fos = new FileOutputStream(splittedFile); - fos.write(bytes); - fos.close(); + try (var fos = new FileOutputStream(splittedFile)) { + fos.write(bytes); + } } } catch (IOException ioe) { throw new UserDataException("i/o error writing file " + file); diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/tool/PrettyWriter.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/tool/PrettyWriter.java index aec1f18546c..77b3f4d1e8c 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/tool/PrettyWriter.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/tool/PrettyWriter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2024, 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 @@ -30,7 +30,6 @@ import java.time.Duration; import java.time.OffsetDateTime; import java.time.format.DateTimeFormatter; import java.time.temporal.ChronoUnit; -import java.util.ArrayList; import java.util.List; import java.util.StringJoiner; diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/tool/View.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/tool/View.java index a22c64c931e..613e315ff13 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/tool/View.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/tool/View.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2024, 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 @@ -33,7 +33,6 @@ import java.util.Deque; import java.util.List; import jdk.jfr.consumer.EventStream; -import jdk.jfr.internal.util.Columnizer; import jdk.jfr.internal.query.ViewPrinter; import jdk.jfr.internal.query.Configuration; import jdk.jfr.internal.query.Configuration.Truncate; diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/util/ValueParser.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/util/ValueParser.java index 1c6561f45c4..730c83daaae 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/util/ValueParser.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/util/ValueParser.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2024, 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 @@ -31,7 +31,7 @@ import static java.util.concurrent.TimeUnit.MILLISECONDS; import static java.util.concurrent.TimeUnit.MINUTES; import static java.util.concurrent.TimeUnit.SECONDS; -public class ValueParser { +public final class ValueParser { private static final String INFINITY = "infinity"; public static long parseTimespanWithInfinity(String s) {