From d08c612b4059f0ffa0dc97b5df45a5d7e4b2de8a Mon Sep 17 00:00:00 2001 From: Andrey Turbanov Date: Fri, 4 Dec 2020 06:32:14 +0000 Subject: [PATCH] 8257708: Remove redundant unmodifiableSet wrapper from already immutable set returned by Collections.singleton Reviewed-by: shade, sspitsyn --- .../DefaultPlatformMBeanProvider.java | 32 +++++++------------ .../internal/PlatformMBeanProviderImpl.java | 8 ++--- 2 files changed, 14 insertions(+), 26 deletions(-) diff --git a/src/java.management/share/classes/java/lang/management/DefaultPlatformMBeanProvider.java b/src/java.management/share/classes/java/lang/management/DefaultPlatformMBeanProvider.java index ba8661c5bcb..7e928227e57 100644 --- a/src/java.management/share/classes/java/lang/management/DefaultPlatformMBeanProvider.java +++ b/src/java.management/share/classes/java/lang/management/DefaultPlatformMBeanProvider.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2020, 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 @@ -56,8 +56,7 @@ class DefaultPlatformMBeanProvider extends PlatformMBeanProvider { */ initMBeanList.add(new PlatformComponent() { private final Set classLoadingInterfaceNames = - Collections.unmodifiableSet(Collections.singleton( - "java.lang.management.ClassLoadingMXBean")); + Collections.singleton("java.lang.management.ClassLoadingMXBean"); @Override public Set> mbeanInterfaces() { @@ -87,8 +86,7 @@ class DefaultPlatformMBeanProvider extends PlatformMBeanProvider { */ initMBeanList.add(new PlatformComponent() { private final Set compilationMXBeanInterfaceNames - = Collections.unmodifiableSet(Collections.singleton( - "java.lang.management.CompilationMXBean")); + = Collections.singleton("java.lang.management.CompilationMXBean"); @Override public Set> mbeanInterfaces() { @@ -123,8 +121,7 @@ class DefaultPlatformMBeanProvider extends PlatformMBeanProvider { */ initMBeanList.add(new PlatformComponent() { private final Set memoryMXBeanInterfaceNames - = Collections.unmodifiableSet(Collections.singleton( - "java.lang.management.MemoryMXBean")); + = Collections.singleton("java.lang.management.MemoryMXBean"); @Override public Set> mbeanInterfaces() { @@ -203,8 +200,7 @@ class DefaultPlatformMBeanProvider extends PlatformMBeanProvider { */ initMBeanList.add(new PlatformComponent() { private final Set memoryManagerMXBeanInterfaceNames - = Collections.unmodifiableSet(Collections.singleton( - "java.lang.management.MemoryManagerMXBean")); + = Collections.singleton("java.lang.management.MemoryManagerMXBean"); @Override public Set> mbeanInterfaces() { @@ -252,8 +248,7 @@ class DefaultPlatformMBeanProvider extends PlatformMBeanProvider { */ initMBeanList.add(new PlatformComponent() { private final Set memoryPoolMXBeanInterfaceNames - = Collections.unmodifiableSet(Collections.singleton( - "java.lang.management.MemoryPoolMXBean")); + = Collections.singleton("java.lang.management.MemoryPoolMXBean"); @Override public Set> mbeanInterfaces() { @@ -298,8 +293,7 @@ class DefaultPlatformMBeanProvider extends PlatformMBeanProvider { */ initMBeanList.add(new PlatformComponent() { private final Set runtimeMXBeanInterfaceNames - = Collections.unmodifiableSet(Collections.singleton( - "java.lang.management.RuntimeMXBean")); + = Collections.singleton("java.lang.management.RuntimeMXBean"); @Override public Set> mbeanInterfaces() { @@ -329,8 +323,7 @@ class DefaultPlatformMBeanProvider extends PlatformMBeanProvider { */ initMBeanList.add(new PlatformComponent() { private final Set threadMXBeanInterfaceNames - = Collections.unmodifiableSet(Collections.singleton( - "java.lang.management.ThreadMXBean")); + = Collections.singleton("java.lang.management.ThreadMXBean"); @Override public Set> mbeanInterfaces() { @@ -361,8 +354,7 @@ class DefaultPlatformMBeanProvider extends PlatformMBeanProvider { */ initMBeanList.add(new PlatformComponent() { private final Set platformLoggingMXBeanInterfaceNames - = Collections.unmodifiableSet(Collections.singleton( - "java.lang.management.PlatformLoggingMXBean")); + = Collections.singleton("java.lang.management.PlatformLoggingMXBean"); @Override public Set> mbeanInterfaces() { @@ -393,8 +385,7 @@ class DefaultPlatformMBeanProvider extends PlatformMBeanProvider { */ initMBeanList.add(new PlatformComponent() { private final Set bufferPoolMXBeanInterfaceNames - = Collections.unmodifiableSet(Collections.singleton( - "java.lang.management.BufferPoolMXBean")); + = Collections.singleton("java.lang.management.BufferPoolMXBean"); @Override public Set> mbeanInterfaces() { @@ -437,8 +428,7 @@ class DefaultPlatformMBeanProvider extends PlatformMBeanProvider { */ initMBeanList.add(new PlatformComponent() { private final Set operatingSystemMXBeanInterfaceNames - = Collections.unmodifiableSet(Collections.singleton( - "java.lang.management.OperatingSystemMXBean")); + = Collections.singleton("java.lang.management.OperatingSystemMXBean"); @Override public Set> mbeanInterfaces() { diff --git a/src/jdk.management/share/classes/com/sun/management/internal/PlatformMBeanProviderImpl.java b/src/jdk.management/share/classes/com/sun/management/internal/PlatformMBeanProviderImpl.java index 24fbbb54c93..da1558f59a8 100644 --- a/src/jdk.management/share/classes/com/sun/management/internal/PlatformMBeanProviderImpl.java +++ b/src/jdk.management/share/classes/com/sun/management/internal/PlatformMBeanProviderImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2020, 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 @@ -204,8 +204,7 @@ public final class PlatformMBeanProviderImpl extends PlatformMBeanProvider { */ initMBeanList.add(new PlatformComponent() { private final Set hotSpotDiagnosticMXBeanInterfaceNames = - Collections.unmodifiableSet(Collections.singleton( - "com.sun.management.HotSpotDiagnosticMXBean")); + Collections.singleton("com.sun.management.HotSpotDiagnosticMXBean"); @Override public Set> mbeanInterfaces() { @@ -237,8 +236,7 @@ public final class PlatformMBeanProviderImpl extends PlatformMBeanProvider { if (diagMBean != null) { initMBeanList.add(new PlatformComponent() { final Set dynamicMBeanInterfaceNames - = Collections.unmodifiableSet(Collections.singleton( - "javax.management.DynamicMBean")); + = Collections.singleton("javax.management.DynamicMBean"); @Override public Set mbeanInterfaceNames() {