8293432: Use diamond operator in java.management

Reviewed-by: rriggs, sspitsyn
This commit is contained in:
Andrey Turbanov 2022-09-08 11:05:54 +00:00
parent ffc249ae21
commit 98da03af50
61 changed files with 291 additions and 361 deletions
src/java.management/share/classes
com/sun/jmx
java/lang/management
javax/management
sun/management

@ -129,9 +129,7 @@ public class DefaultMBeanServerInterceptor implements MBeanServerInterceptor {
/* See the comment before addNotificationListener below. */
private final transient
WeakHashMap<ListenerWrapper, WeakReference<ListenerWrapper>>
listenerWrappers =
new WeakHashMap<ListenerWrapper,
WeakReference<ListenerWrapper>>();
listenerWrappers = new WeakHashMap<>();
/** The default domain of the object names */
private final String domain;
@ -340,8 +338,7 @@ public class DefaultMBeanServerInterceptor implements MBeanServerInterceptor {
return mbeanToRegister.getClass().getName();
}
private final Set<ObjectName> beingUnregistered =
new HashSet<ObjectName>();
private final Set<ObjectName> beingUnregistered = new HashSet<>();
public void unregisterMBean(ObjectName name)
throws InstanceNotFoundException, MBeanRegistrationException {
@ -476,8 +473,7 @@ public class DefaultMBeanServerInterceptor implements MBeanServerInterceptor {
// Check if the caller has the right to invoke 'queryMBeans'
// on each specific classname/objectname in the list.
//
Set<ObjectInstance> allowedList =
new HashSet<ObjectInstance>(list.size());
Set<ObjectInstance> allowedList = new HashSet<>(list.size());
for (ObjectInstance oi : list) {
try {
checkMBeanPermission(oi.getClassName(), null,
@ -523,8 +519,7 @@ public class DefaultMBeanServerInterceptor implements MBeanServerInterceptor {
// Check if the caller has the right to invoke 'queryNames'
// on each specific classname/objectname in the list.
//
Set<ObjectInstance> allowedList =
new HashSet<ObjectInstance>(list.size());
Set<ObjectInstance> allowedList = new HashSet<>(list.size());
for (ObjectInstance oi : list) {
try {
checkMBeanPermission(oi.getClassName(), null,
@ -539,7 +534,7 @@ public class DefaultMBeanServerInterceptor implements MBeanServerInterceptor {
//
Set<ObjectInstance> queryObjectInstanceList =
filterListOfObjectInstances(allowedList, query);
queryList = new HashSet<ObjectName>(queryObjectInstanceList.size());
queryList = new HashSet<>(queryObjectInstanceList.size());
for (ObjectInstance oi : queryObjectInstanceList) {
queryList.add(oi.getObjectName());
}
@ -589,7 +584,7 @@ public class DefaultMBeanServerInterceptor implements MBeanServerInterceptor {
// Check if the caller has the right to invoke 'getDomains'
// on each specific domain in the list.
//
List<String> result = new ArrayList<String>(domains.length);
List<String> result = new ArrayList<>(domains.length);
for (int i = 0; i < domains.length; i++) {
try {
ObjectName dom = Util.newObjectName(domains[i] + ":x=x");
@ -684,8 +679,7 @@ public class DefaultMBeanServerInterceptor implements MBeanServerInterceptor {
// Check if the caller has the right to invoke 'getAttribute'
// on each specific attribute
//
List<String> allowedList =
new ArrayList<String>(attributes.length);
List<String> allowedList = new ArrayList<>(attributes.length);
for (String attr : attributes) {
try {
checkMBeanPermission(classname, attr, name, "getAttribute");
@ -1473,7 +1467,7 @@ public class DefaultMBeanServerInterceptor implements MBeanServerInterceptor {
private Set<ObjectName>
objectNamesFromFilteredNamedObjects(Set<NamedObject> list,
QueryExp query) {
Set<ObjectName> result = new HashSet<ObjectName>();
Set<ObjectName> result = new HashSet<>();
// No query ...
if (query == null) {
for (NamedObject no : list) {
@ -1517,7 +1511,7 @@ public class DefaultMBeanServerInterceptor implements MBeanServerInterceptor {
private Set<ObjectInstance>
objectInstancesFromFilteredNamedObjects(Set<NamedObject> list,
QueryExp query) {
Set<ObjectInstance> result = new HashSet<ObjectInstance>();
Set<ObjectInstance> result = new HashSet<>();
// No query ...
if (query == null) {
for (NamedObject no : list) {
@ -1582,7 +1576,7 @@ public class DefaultMBeanServerInterceptor implements MBeanServerInterceptor {
if (query == null) {
return list;
} else {
Set<ObjectInstance> result = new HashSet<ObjectInstance>();
Set<ObjectInstance> result = new HashSet<>();
// Access the filter.
//
for (ObjectInstance oi : list) {
@ -1643,7 +1637,7 @@ public class DefaultMBeanServerInterceptor implements MBeanServerInterceptor {
return existing;
}
if (create) {
ref = new WeakReference<ListenerWrapper>(wrapper);
ref = new WeakReference<>(wrapper);
listenerWrappers.put(wrapper, ref);
return wrapper;
} else
@ -1791,7 +1785,7 @@ public class DefaultMBeanServerInterceptor implements MBeanServerInterceptor {
if (sm != null) {
Permission perm = new MBeanTrustPermission("register");
PrivilegedAction<ProtectionDomain> act =
new PrivilegedAction<ProtectionDomain>() {
new PrivilegedAction<>() {
public ProtectionDomain run() {
return theClass.getProtectionDomain();
}
@ -2014,7 +2008,7 @@ public class DefaultMBeanServerInterceptor implements MBeanServerInterceptor {
@SuppressWarnings("removal")
private ModifiableClassLoaderRepository getInstantiatorCLR() {
return AccessController.doPrivileged(new PrivilegedAction<ModifiableClassLoaderRepository>() {
return AccessController.doPrivileged(new PrivilegedAction<>() {
@Override
public ModifiableClassLoaderRepository run() {
return instantiator != null ? instantiator.getClassLoaderRepository() : null;

@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 2022, 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
@ -86,8 +86,7 @@ final class ClassLoaderRepositorySupport
* loader has been added.
**/
private synchronized boolean add(ObjectName name, ClassLoader cl) {
List<LoaderEntry> l =
new ArrayList<LoaderEntry>(Arrays.asList(loaders));
List<LoaderEntry> l = new ArrayList<>(Arrays.asList(loaders));
l.add(new LoaderEntry(name, cl));
loaders = l.toArray(EMPTY_LOADER_ARRAY);
return true;
@ -130,13 +129,13 @@ final class ClassLoaderRepositorySupport
* List of valid search
*/
private final Map<String,List<ClassLoader>> search =
new Hashtable<String,List<ClassLoader>>(10);
new Hashtable<>(10);
/**
* List of named class loaders.
*/
private final Map<ObjectName,ClassLoader> loadersWithNames =
new Hashtable<ObjectName,ClassLoader>(10);
new Hashtable<>(10);
// from javax.management.loading.DefaultLoaderRepository
public final Class<?> loadClass(String className)
@ -246,7 +245,7 @@ final class ClassLoaderRepositorySupport
// Add an entry
//
if (excluded == null) {
excluded = new ArrayList<ClassLoader>(1);
excluded = new ArrayList<>(1);
search.put(className, excluded);
}
excluded.add(aloader);

@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2022, 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
@ -177,8 +177,7 @@ public class DefaultMXBeanMappingFactory extends MXBeanMappingFactory {
}
private static synchronized void putMapping(Type type, MXBeanMapping mapping) {
WeakReference<MXBeanMapping> wr =
new WeakReference<MXBeanMapping>(mapping);
WeakReference<MXBeanMapping> wr = new WeakReference<>(mapping);
mappings.put(type, wr);
}
@ -303,7 +302,7 @@ public class DefaultMXBeanMappingFactory extends MXBeanMappingFactory {
private static <T extends Enum<T>> MXBeanMapping
makeEnumMapping(Class<?> enumClass, Class<T> fake) {
ReflectUtil.checkPackageAccess(enumClass);
return new EnumMapping<T>(Util.<Class<T>>cast(enumClass));
return new EnumMapping<>(Util.<Class<T>>cast(enumClass));
}
/* Make the converter for an array type, or a collection such as
@ -1286,7 +1285,7 @@ public class DefaultMXBeanMappingFactory extends MXBeanMappingFactory {
BitSet u = new BitSet();
u.or(a); u.or(b);
if (!getterIndexSets.contains(u)) {
Set<String> names = new TreeSet<String>();
Set<String> names = new TreeSet<>();
for (int i = u.nextSetBit(0); i >= 0;
i = u.nextSetBit(i+1))
names.add(itemNames[i]);

@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2022, 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
@ -51,7 +51,7 @@ public class DescriptorCache {
ImmutableDescriptor got = (wr == null) ? null : wr.get();
if (got != null)
return got;
map.put(descriptor, new WeakReference<ImmutableDescriptor>(descriptor));
map.put(descriptor, new WeakReference<>(descriptor));
return descriptor;
}
@ -62,6 +62,5 @@ public class DescriptorCache {
private static final DescriptorCache instance = new DescriptorCache();
private final WeakHashMap<ImmutableDescriptor,
WeakReference<ImmutableDescriptor>>
map = new WeakHashMap<ImmutableDescriptor,
WeakReference<ImmutableDescriptor>>();
map = new WeakHashMap<>();
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2022, 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
@ -397,7 +397,7 @@ public class Introspector {
public static Descriptor descriptorForAnnotations(Annotation[] annots) {
if (annots.length == 0)
return ImmutableDescriptor.EMPTY_DESCRIPTOR;
Map<String, Object> descriptorMap = new HashMap<String, Object>();
Map<String, Object> descriptorMap = new HashMap<>();
for (Annotation a : annots) {
Class<? extends Annotation> c = a.annotationType();
Method[] elements = c.getMethods();
@ -592,8 +592,7 @@ public class Introspector {
// cache to avoid repeated lookups
private static final Map<Class<?>,SoftReference<List<Method>>> cache =
Collections.synchronizedMap(
new WeakHashMap<Class<?>,SoftReference<List<Method>>> ());
Collections.synchronizedMap(new WeakHashMap<>());
/**
* Returns the list of methods cached for the given class, or {@code null}
@ -654,7 +653,7 @@ public class Introspector {
methods = MBeanAnalyzer.eliminateCovariantMethods(methods);
// filter out the non-getter methods
List<Method> result = new LinkedList<Method>();
List<Method> result = new LinkedList<>();
for (Method m: methods) {
if (isReadMethod(m)) {
// favor isXXX over getXXX
@ -667,7 +666,7 @@ public class Introspector {
}
// add result to cache
cache.put(clazz, new SoftReference<List<Method>>(result));
cache.put(clazz, new SoftReference<>(result));
return result;
}

@ -232,7 +232,7 @@ public final class JmxMBeanServer
final MBeanInstantiator fInstantiator = instantiator;
this.secureClr = new
SecureClassLoaderRepository(AccessController.doPrivileged(new PrivilegedAction<ClassLoaderRepository>() {
SecureClassLoaderRepository(AccessController.doPrivileged(new PrivilegedAction<>() {
@Override
public ClassLoaderRepository run() {
return fInstantiator.getClassLoaderRepository();
@ -1222,7 +1222,7 @@ public final class JmxMBeanServer
// Registers the MBeanServer identification MBean
try {
AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
AccessController.doPrivileged(new PrivilegedExceptionAction<>() {
public Object run() throws Exception {
mbsInterceptor.registerMBean(
mBeanServerDelegateObject,
@ -1251,7 +1251,7 @@ public final class JmxMBeanServer
class loader. The ClassLoaderRepository knows how
to handle that case. */
ClassLoader myLoader = outerShell.getClass().getClassLoader();
final ModifiableClassLoaderRepository loaders = AccessController.doPrivileged(new PrivilegedAction<ModifiableClassLoaderRepository>() {
final ModifiableClassLoaderRepository loaders = AccessController.doPrivileged(new PrivilegedAction<>() {
@Override
public ModifiableClassLoaderRepository run() {

@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2022, 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,7 +29,6 @@ import static com.sun.jmx.mbeanserver.Util.*;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.security.AccessController;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
@ -99,7 +98,7 @@ class MBeanAnalyzer<M> {
static <M> MBeanAnalyzer<M> analyzer(Class<?> mbeanType,
MBeanIntrospector<M> introspector)
throws NotCompliantMBeanException {
return new MBeanAnalyzer<M>(mbeanType, introspector);
return new MBeanAnalyzer<>(mbeanType, introspector);
}
private MBeanAnalyzer(Class<?> mbeanType,
@ -149,7 +148,7 @@ class MBeanAnalyzer<M> {
// Check we don't have both isX and getX
AttrMethods<M> am = attrMap.get(attrName);
if (am == null)
am = new AttrMethods<M>();
am = new AttrMethods<>();
else {
if (am.getter != null) {
final String msg = "Attribute " + attrName +
@ -166,7 +165,7 @@ class MBeanAnalyzer<M> {
attrName = name.substring(3);
AttrMethods<M> am = attrMap.get(attrName);
if (am == null)
am = new AttrMethods<M>();
am = new AttrMethods<>();
else if (am.setter != null) {
final String msg = "Attribute " + attrName +
" has more than one setter";

@ -761,7 +761,7 @@ public class MBeanInstantiator {
@SuppressWarnings("removal")
AccessControlContext ctx = new AccessControlContext(domains);
@SuppressWarnings("removal")
ClassLoader loader = AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
ClassLoader loader = AccessController.doPrivileged(new PrivilegedAction<>() {
public ClassLoader run() {
return clr.getClassLoader(name);
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2022, 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
@ -40,7 +40,6 @@ import java.util.WeakHashMap;
import javax.management.Descriptor;
import javax.management.ImmutableDescriptor;
import javax.management.IntrospectionException;
import javax.management.InvalidAttributeValueException;
import javax.management.MBeanAttributeInfo;
import javax.management.MBeanConstructorInfo;
@ -192,9 +191,9 @@ abstract class MBeanIntrospector<M> {
MBeanAnalyzer<M> analyzer = getAnalyzer(mbeanInterface);
MBeanInfo mbeanInfo =
makeInterfaceMBeanInfo(mbeanInterface, analyzer);
pi = new PerInterface<M>(mbeanInterface, this, analyzer,
pi = new PerInterface<>(mbeanInterface, this, analyzer,
mbeanInfo);
wr = new WeakReference<PerInterface<M>>(pi);
wr = new WeakReference<>(pi);
map.put(mbeanInterface, wr);
} catch (Exception x) {
throw Introspector.throwException(mbeanInterface,x);
@ -417,7 +416,7 @@ abstract class MBeanIntrospector<M> {
synchronized (map) {
WeakHashMap<Class<?>, MBeanInfo> intfMap = map.get(resourceClass);
if (intfMap == null) {
intfMap = new WeakHashMap<Class<?>, MBeanInfo>();
intfMap = new WeakHashMap<>();
map.put(resourceClass, intfMap);
}
Class<?> intfClass = perInterface.getMBeanInterface();

@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2022, 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
@ -25,8 +25,6 @@
package com.sun.jmx.mbeanserver;
import com.sun.jmx.mbeanserver.MBeanIntrospector.MBeanInfoMap;
import com.sun.jmx.mbeanserver.MBeanIntrospector.PerInterfaceMap;
import java.lang.annotation.Annotation;
import java.lang.reflect.GenericArrayType;
import java.lang.reflect.InvocationTargetException;
@ -359,7 +357,7 @@ class MXBeanIntrospector extends MBeanIntrospector<ConvertingMethod> {
}
private final PerInterfaceMap<ConvertingMethod>
perInterfaceMap = new PerInterfaceMap<ConvertingMethod>();
perInterfaceMap = new PerInterfaceMap<>();
private static final MBeanInfoMap mbeanInfoMap = new MBeanInfoMap();
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2022, 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
@ -95,7 +95,7 @@ public class MXBeanLookup {
MXBeanLookup lookup = (weakLookup == null) ? null : weakLookup.get();
if (lookup == null) {
lookup = new MXBeanLookup(mbsc);
mbscToLookup.put(mbsc, new WeakReference<MXBeanLookup>(lookup));
mbscToLookup.put(mbsc, new WeakReference<>(lookup));
}
return lookup;
}
@ -109,7 +109,7 @@ public class MXBeanLookup {
return type.cast(proxy);
}
T proxy = JMX.newMXBeanProxy(mbsc, name, type);
objectNameToProxy.put(name, new WeakReference<Object>(proxy));
objectNameToProxy.put(name, new WeakReference<>(proxy));
return proxy;
}
@ -176,7 +176,7 @@ public class MXBeanLookup {
}
private static final ThreadLocal<MXBeanLookup> currentLookup =
new ThreadLocal<MXBeanLookup>();
new ThreadLocal<>();
private final MBeanServerConnection mbsc;
private final WeakIdentityHashMap<Object, ObjectName>

@ -239,8 +239,7 @@ public class Repository {
final String dom,
final ObjectName name,
final RegistrationContext context) {
final Map<String,NamedObject> moiTb =
new HashMap<String,NamedObject>();
final Map<String,NamedObject> moiTb = new HashMap<>();
final String key = name.getCanonicalKeyPropertyListString();
addMoiToTb(object,name,key,moiTb,context);
domainTb.put(dom, moiTb);
@ -325,7 +324,7 @@ public class Repository {
public Repository(String domain, boolean fairLock) {
lock = new ReentrantReadWriteLock(fairLock);
domainTb = new HashMap<String,Map<String,NamedObject>>(5);
domainTb = new HashMap<>(5);
if (domain != null && domain.length() != 0)
this.domain = domain.intern(); // we use == domain later on...
@ -333,7 +332,7 @@ public class Repository {
this.domain = ServiceName.DOMAIN;
// Creates a new hashtable for the default domain
domainTb.put(this.domain, new HashMap<String,NamedObject>());
domainTb.put(this.domain, new HashMap<>());
}
/**
@ -347,7 +346,7 @@ public class Repository {
final List<String> result;
try {
// Temporary list
result = new ArrayList<String>(domainTb.size());
result = new ArrayList<>(domainTb.size());
for (Map.Entry<String,Map<String,NamedObject>> entry :
domainTb.entrySet()) {
// Skip domains that are in the table but have no
@ -507,7 +506,7 @@ public class Repository {
*/
public Set<NamedObject> query(ObjectName pattern, QueryExp query) {
final Set<NamedObject> result = new HashSet<NamedObject>();
final Set<NamedObject> result = new HashSet<>();
// The following filter cases are considered:
// null, "", "*:*" : names in all domains
@ -641,7 +640,7 @@ public class Repository {
// big buckets array size inside table, never cleared,
// thus the new !
if (dom == domain) // ES: OK dom and domain are interned.
domainTb.put(domain, new HashMap<String,NamedObject>());
domainTb.put(domain, new HashMap<>());
}
unregistering(context,name);

@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2022, 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
@ -184,10 +184,10 @@ class StandardMBeanIntrospector extends MBeanIntrospector<Method> {
}
}
private static final WeakHashMap<Class<?>, Boolean> definitelyImmutable =
new WeakHashMap<Class<?>, Boolean>();
new WeakHashMap<>();
private static final PerInterfaceMap<Method>
perInterfaceMap = new PerInterfaceMap<Method>();
perInterfaceMap = new PerInterfaceMap<>();
private static final MBeanInfoMap mbeanInfoMap = new MBeanInfoMap();
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2022, 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
@ -52,7 +52,7 @@ public class Util {
}
static <K, V> Map<K, V> newMap() {
return new HashMap<K, V>();
return new HashMap<>();
}
static <K, V> Map<K, V> newSynchronizedMap() {
@ -60,7 +60,7 @@ public class Util {
}
static <K, V> IdentityHashMap<K, V> newIdentityHashMap() {
return new IdentityHashMap<K, V>();
return new IdentityHashMap<>();
}
static <K, V> Map<K, V> newSynchronizedIdentityHashMap() {
@ -69,31 +69,31 @@ public class Util {
}
static <K, V> SortedMap<K, V> newSortedMap() {
return new TreeMap<K, V>();
return new TreeMap<>();
}
static <K, V> SortedMap<K, V> newSortedMap(Comparator<? super K> comp) {
return new TreeMap<K, V>(comp);
return new TreeMap<>(comp);
}
static <K, V> Map<K, V> newInsertionOrderMap() {
return new LinkedHashMap<K, V>();
return new LinkedHashMap<>();
}
static <E> Set<E> newSet() {
return new HashSet<E>();
return new HashSet<>();
}
static <E> Set<E> newSet(Collection<E> c) {
return new HashSet<E>(c);
return new HashSet<>(c);
}
static <E> List<E> newList() {
return new ArrayList<E>();
return new ArrayList<>();
}
static <E> List<E> newList(Collection<E> c) {
return new ArrayList<E>(c);
return new ArrayList<>(c);
}
/* This method can be used by code that is deliberately violating the

@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2022, 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
@ -60,7 +60,7 @@ class WeakIdentityHashMap<K, V> {
private WeakIdentityHashMap() {}
static <K, V> WeakIdentityHashMap<K, V> make() {
return new WeakIdentityHashMap<K, V>();
return new WeakIdentityHashMap<>();
}
V get(K key) {
@ -90,11 +90,11 @@ class WeakIdentityHashMap<K, V> {
}
private WeakReference<K> makeReference(K referent) {
return new IdentityWeakReference<K>(referent);
return new IdentityWeakReference<>(referent);
}
private WeakReference<K> makeReference(K referent, ReferenceQueue<K> q) {
return new IdentityWeakReference<K>(referent, q);
return new IdentityWeakReference<>(referent, q);
}
/**
@ -134,5 +134,5 @@ class WeakIdentityHashMap<K, V> {
}
private Map<WeakReference<K>, V> map = newMap();
private ReferenceQueue<K> refQueue = new ReferenceQueue<K>();
private ReferenceQueue<K> refQueue = new ReferenceQueue<>();
}

@ -116,8 +116,8 @@ public class ArrayNotificationBuffer implements NotificationBuffer {
private static final Object globalLock = new Object();
private static final
HashMap<MBeanServer,ArrayNotificationBuffer> mbsToBuffer =
new HashMap<MBeanServer,ArrayNotificationBuffer>(1);
private final Collection<ShareBuffer> sharers = new HashSet<ShareBuffer>(1);
new HashMap<>(1);
private final Collection<ShareBuffer> sharers = new HashSet<>(1);
public static NotificationBuffer getNotificationBuffer(
MBeanServer mbs, Map<String, ?> env) {
@ -251,7 +251,7 @@ public class ArrayNotificationBuffer implements NotificationBuffer {
this.mBeanServer = mbs;
this.queueSize = queueSize;
this.queue = new ArrayQueue<NamedNotification>(queueSize);
this.queue = new ArrayQueue<>(queueSize);
this.earliestSequenceNumber = System.currentTimeMillis();
this.nextSequenceNumber = this.earliestSequenceNumber;
@ -353,8 +353,7 @@ public class ArrayNotificationBuffer implements NotificationBuffer {
to the earliest notification we examined. */
long earliestSeq = -1;
long nextSeq = startSequenceNumber;
List<TargetedNotification> notifs =
new ArrayList<TargetedNotification>();
List<TargetedNotification> notifs = new ArrayList<>();
/* On exit from this loop, notifs, earliestSeq, and nextSeq must
all be correct values for the returned NotificationResult. */
@ -459,8 +458,7 @@ public class ArrayNotificationBuffer implements NotificationBuffer {
potentially slow filters. */
ObjectName name = candidate.getObjectName();
Notification notif = candidate.getNotification();
List<TargetedNotification> matchedNotifs =
new ArrayList<TargetedNotification>();
List<TargetedNotification> matchedNotifs = new ArrayList<>();
logger.debug("fetchNotifications",
"applying filter to candidate");
filter.apply(matchedNotifs, name, notif);
@ -601,7 +599,7 @@ public class ArrayNotificationBuffer implements NotificationBuffer {
logger.debug("createListeners", "starts");
synchronized (this) {
createdDuringQuery = new HashSet<ObjectName>();
createdDuringQuery = new HashSet<>();
}
try {
@ -618,7 +616,7 @@ public class ArrayNotificationBuffer implements NotificationBuffer {
/* Spec doesn't say whether Set returned by QueryNames can be modified
so we clone it. */
Set<ObjectName> names = queryNames(null, broadcasterQuery);
names = new HashSet<ObjectName>(names);
names = new HashSet<>(names);
synchronized (this) {
names.addAll(createdDuringQuery);
@ -696,7 +694,7 @@ public class ArrayNotificationBuffer implements NotificationBuffer {
private Set<ObjectName> queryNames(final ObjectName name,
final QueryExp query) {
PrivilegedAction<Set<ObjectName>> act =
new PrivilegedAction<Set<ObjectName>>() {
new PrivilegedAction<>() {
public Set<ObjectName> run() {
return mBeanServer.queryNames(name, query);
}
@ -715,7 +713,7 @@ public class ArrayNotificationBuffer implements NotificationBuffer {
final ObjectName name,
final String className) {
PrivilegedExceptionAction<Boolean> act =
new PrivilegedExceptionAction<Boolean>() {
new PrivilegedExceptionAction<>() {
public Boolean run() throws InstanceNotFoundException {
return mbs.isInstanceOf(name, className);
}

@ -193,9 +193,8 @@ public abstract class ClientNotifForwarder {
NotificationListener listener)
throws ListenerNotFoundException, IOException {
List<Integer> ids = new ArrayList<Integer>();
List<ClientListenerInfo> values =
new ArrayList<ClientListenerInfo>(infoList.values());
List<Integer> ids = new ArrayList<>();
List<ClientListenerInfo> values = new ArrayList<>(infoList.values());
for (int i=values.size()-1; i>=0; i--) {
ClientListenerInfo li = values.get(i);
@ -219,8 +218,7 @@ public abstract class ClientNotifForwarder {
Integer id = null;
List<ClientListenerInfo> values =
new ArrayList<ClientListenerInfo>(infoList.values());
List<ClientListenerInfo> values = new ArrayList<>(infoList.values());
for (int i=values.size()-1; i>=0; i--) {
ClientListenerInfo li = values.get(i);
if (li.sameAs(name, listener, filter, handback)) {
@ -280,10 +278,9 @@ public abstract class ClientNotifForwarder {
"Remove all listeners registered at "+name);
}
List<Integer> ids = new ArrayList<Integer>();
List<Integer> ids = new ArrayList<>();
List<ClientListenerInfo> values =
new ArrayList<ClientListenerInfo>(infoList.values());
List<ClientListenerInfo> values = new ArrayList<>(infoList.values());
for (int i=values.size()-1; i>=0; i--) {
ClientListenerInfo li = values.get(i);
if (li.sameAs(name)) {
@ -435,7 +432,7 @@ public abstract class ClientNotifForwarder {
throw new SecurityException("AccessControlContext must not be null");
}
return AccessController.doPrivileged(
new PrivilegedAction<ClassLoader>() {
new PrivilegedAction<>() {
public ClassLoader run() {
try {
// get context class loader - may throw
@ -509,7 +506,7 @@ public abstract class ClientNotifForwarder {
clientSequenceNumber = nr.getNextSequenceNumber();
listeners = new HashMap<Integer, ClientListenerInfo>();
listeners = new HashMap<>();
for (int i = 0 ; i < len ; i++) {
final TargetedNotification tn = notifs[i];
@ -909,8 +906,7 @@ public abstract class ClientNotifForwarder {
private final ClassLoader defaultClassLoader;
private Executor executor;
private final Map<Integer, ClientListenerInfo> infoList =
new HashMap<Integer, ClientListenerInfo>();
private final Map<Integer, ClientListenerInfo> infoList = new HashMap<>();
// notif stuff
private long clientSequenceNumber = -1;

@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 2022, 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
@ -96,7 +96,7 @@ public class ServerNotifForwarder {
@SuppressWarnings("removal")
boolean instanceOf =
AccessController.doPrivileged(
new PrivilegedExceptionAction<Boolean>() {
new PrivilegedExceptionAction<>() {
public Boolean run() throws InstanceNotFoundException {
return mbeanServer.isInstanceOf(name, broadcasterClass);
}
@ -134,7 +134,7 @@ public class ServerNotifForwarder {
set = Collections.singleton(idaf);
else {
if (set.size() == 1)
set = new HashSet<IdAndFilter>(set);
set = new HashSet<>(set);
set.add(idaf);
}
listenerMap.put(nn, set);
@ -384,7 +384,7 @@ public class ServerNotifForwarder {
ObjectInstance oi;
try {
oi = AccessController.doPrivileged(
new PrivilegedExceptionAction<ObjectInstance>() {
new PrivilegedExceptionAction<>() {
public ObjectInstance run()
throws InstanceNotFoundException {
return mbs.getObjectInstance(name);
@ -490,7 +490,7 @@ public class ServerNotifForwarder {
private NotificationBuffer notifBuffer;
private final Map<ObjectName, Set<IdAndFilter>> listenerMap =
new HashMap<ObjectName, Set<IdAndFilter>>();
new HashMap<>();
private boolean terminated = false;
private final int[] terminationLock = new int[0];

@ -317,7 +317,7 @@ private static class FileLoginConfig extends Configuration {
Map<String, String> options;
if (passwordFile != null) {
options = new HashMap<String, String>(1);
options = new HashMap<>(1);
options.put(PASSWORD_FILE_OPTION, passwordFile);
options.put(HASH_PASSWORDS, hashPasswords);
} else {

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2022, 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
@ -305,7 +305,7 @@ public class MBeanServerFileAccessController
final AccessControlContext acc = AccessController.getContext();
@SuppressWarnings("removal")
final Subject s =
AccessController.doPrivileged(new PrivilegedAction<Subject>() {
AccessController.doPrivileged(new PrivilegedAction<>() {
public Subject run() {
return Subject.getSubject(acc);
}
@ -388,7 +388,7 @@ public class MBeanServerFileAccessController
}
private void parseProperties(Properties props) {
this.accessMap = new HashMap<String, Access>();
this.accessMap = new HashMap<>();
for (Map.Entry<Object, Object> entry : props.entrySet()) {
String identity = (String) entry.getKey();
String accessString = (String) entry.getValue();
@ -447,7 +447,7 @@ public class MBeanServerFileAccessController
}
private Access parseReadWrite() {
List<String> createClasses = new ArrayList<String>();
List<String> createClasses = new ArrayList<>();
boolean unregister = false;
while (true) {
skipSpace();

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2022, 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
@ -63,7 +63,7 @@ public class SubjectDelegator {
permissions.add(new SubjectDelegationPermission(pname));
}
PrivilegedAction<Void> action =
new PrivilegedAction<Void>() {
new PrivilegedAction<>() {
public Void run() {
for (Permission sdp : permissions) {
AccessController.checkPermission(sdp);

@ -439,7 +439,7 @@ public class EnvHelp {
logger.trace("filterAttributes", "starts");
}
SortedMap<String, V> map = new TreeMap<String, V>(attributes);
SortedMap<String, V> map = new TreeMap<>(attributes);
purgeUnserializable(map.values());
hideAttributes(map);
return map;
@ -524,9 +524,9 @@ public class EnvHelp {
"jmx.remote.x.password.file ";
private static final SortedSet<String> defaultHiddenStrings =
new TreeSet<String>();
new TreeSet<>();
private static final SortedSet<String> defaultHiddenPrefixes =
new TreeSet<String>();
new TreeSet<>();
private static void hideAttributes(SortedMap<String, ?> map) {
if (map.isEmpty())
@ -541,8 +541,8 @@ public class EnvHelp {
hide = hide.substring(1);
else
hide += " " + DEFAULT_HIDDEN_ATTRIBUTES;
hiddenStrings = new TreeSet<String>();
hiddenPrefixes = new TreeSet<String>();
hiddenStrings = new TreeSet<>();
hiddenPrefixes = new TreeSet<>();
parseHiddenAttributes(hide, hiddenStrings, hiddenPrefixes);
} else {
hide = DEFAULT_HIDDEN_ATTRIBUTES;

@ -24,6 +24,7 @@
*/
package java.lang.management;
import java.io.FilePermission;
import java.io.IOException;
import javax.management.DynamicMBean;
@ -926,7 +927,7 @@ public class ManagementFactory {
// get all providers
@SuppressWarnings("removal")
List<PlatformMBeanProvider> providers = AccessController.doPrivileged(
new PrivilegedAction<List<PlatformMBeanProvider>>() {
new PrivilegedAction<>() {
@Override
public List<PlatformMBeanProvider> run() {
List<PlatformMBeanProvider> all = new ArrayList<>();

@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2022, 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
@ -48,7 +48,7 @@ public class AttributeChangeNotificationFilter implements NotificationFilter {
* @serial {@link Vector} that contains the enabled attribute names.
* The default value is an empty vector.
*/
private Vector<String> enabledAttributes = new Vector<String>();
private Vector<String> enabledAttributes = new Vector<>();
/**
* Constructs an {@code AttributeChangeNotificationFilter}.

@ -1,5 +1,5 @@
/*
* Copyright (c) 2004, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004, 2022, 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
@ -108,7 +108,7 @@ public class ImmutableDescriptor implements Descriptor {
if (fields == null)
throw new IllegalArgumentException("Null Map");
SortedMap<String, Object> map =
new TreeMap<String, Object>(String.CASE_INSENSITIVE_ORDER);
new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
for (Map.Entry<String, ?> entry : fields.entrySet()) {
String name = entry.getKey();
if (name == null || name.isEmpty())
@ -164,7 +164,7 @@ public class ImmutableDescriptor implements Descriptor {
if (fieldNames.length != fieldValues.length)
throw new IllegalArgumentException("Different size arrays");
SortedMap<String, Object> map =
new TreeMap<String, Object>(String.CASE_INSENSITIVE_ORDER);
new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
for (int i = 0; i < fieldNames.length; i++) {
String name = fieldNames[i];
if (name == null || name.isEmpty())
@ -238,8 +238,7 @@ public class ImmutableDescriptor implements Descriptor {
&& findNonEmpty(descriptors, index + 1) < 0)
return (ImmutableDescriptor) descriptors[index];
Map<String, Object> map =
new TreeMap<String, Object>(String.CASE_INSENSITIVE_ORDER);
Map<String, Object> map = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
ImmutableDescriptor biggestImmutable = EMPTY_DESCRIPTOR;
for (Descriptor d : descriptors) {
if (d != null) {

@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2022, 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
@ -531,7 +531,7 @@ public class MBeanInfo implements Cloneable, Serializable, DescriptorRead {
* garbage collected just because we know whether it's immutable.
*/
private static final Map<Class<?>, Boolean> arrayGettersSafeMap =
new WeakHashMap<Class<?>, Boolean>();
new WeakHashMap<>();
/**
* Return true if {@code subclass} is known to preserve the

@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2022, 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
@ -361,9 +361,9 @@ public class MBeanServerFactory {
checkPermission("findMBeanServer");
if (agentId == null)
return new ArrayList<MBeanServer>(mBeanServerList);
return new ArrayList<>(mBeanServerList);
ArrayList<MBeanServer> result = new ArrayList<MBeanServer>();
ArrayList<MBeanServer> result = new ArrayList<>();
for (MBeanServer mbs : mBeanServerList) {
String name = mBeanServerId(mbs);
if (agentId.equals(name))
@ -429,7 +429,7 @@ public class MBeanServerFactory {
}
private static final ArrayList<MBeanServer> mBeanServerList =
new ArrayList<MBeanServer>();
new ArrayList<>();
/**
* Load the builder class through the context class loader.

@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 2022, 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
@ -335,14 +335,13 @@ public class MBeanServerInvocationHandler implements InvocationHandler {
iae.setStackTrace(e.getStackTrace());
throw iae;
}
mxbeanProxies.put(mxbeanInterface,
new WeakReference<MXBeanProxy>(p));
mxbeanProxies.put(mxbeanInterface, new WeakReference<>(p));
}
return p;
}
}
private static final WeakHashMap<Class<?>, WeakReference<MXBeanProxy>>
mxbeanProxies = new WeakHashMap<Class<?>, WeakReference<MXBeanProxy>>();
mxbeanProxies = new WeakHashMap<>();
private Object invokeBroadcasterMethod(Object proxy, Method method,
Object[] args) throws Exception {

@ -324,8 +324,7 @@ public class NotificationBroadcasterSupport implements NotificationEmitter {
}
}
private List<ListenerInfo> listenerList =
new CopyOnWriteArrayList<ListenerInfo>();
private List<ListenerInfo> listenerList = new CopyOnWriteArrayList<>();
// since 1.6
private final Executor executor;

@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2022, 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 class NotificationFilterSupport implements NotificationFilter {
* The default value is an empty vector.
*/
@SuppressWarnings("serial") // Not statically typed as Serializable
private List<String> enabledTypes = new Vector<String>();
private List<String> enabledTypes = new Vector<>();
/**

@ -494,7 +494,7 @@ public class ObjectName implements Comparable<ObjectName>, QueryExp {
// parses property list
Property prop;
Map<String,Property> keys_map = new HashMap<String,Property>();
Map<String,Property> keys_map = new HashMap<>();
String[] keys;
String key_name;
boolean quoted_value;
@ -708,7 +708,7 @@ public class ObjectName implements Comparable<ObjectName>, QueryExp {
_kp_array = new Property[nb_props];
String[] keys = new String[nb_props];
final Map<String,Property> keys_map = new HashMap<String,Property>();
final Map<String,Property> keys_map = new HashMap<>();
Property prop;
int key_index;
int i = 0;
@ -1656,7 +1656,7 @@ public class ObjectName implements Comparable<ObjectName>, QueryExp {
if (_propertyList == null) {
// build (lazy eval) the property list from the canonical
// properties array
_propertyList = new HashMap<String,String>();
_propertyList = new HashMap<>();
int len = _ca_array.length;
Property prop;
for (int i = len - 1; i >= 0; i--) {
@ -1682,7 +1682,7 @@ public class ObjectName implements Comparable<ObjectName>, QueryExp {
*/
// CR 6441274 depends on the modification property defined above
public Hashtable<String,String> getKeyPropertyList() {
return new Hashtable<String,String>(_getKeyPropertyList());
return new Hashtable<>(_getKeyPropertyList());
}
/**

@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2022, 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
@ -25,7 +25,6 @@
package javax.management;
// java import
import java.io.Serializable;
/**
@ -39,7 +38,7 @@ public abstract class QueryEval implements Serializable {
private static final long serialVersionUID = 2675899265640874796L;
private static ThreadLocal<MBeanServer> server =
new InheritableThreadLocal<MBeanServer>();
new InheritableThreadLocal<>();
/**
* Constructor for subclasses to call.

@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 2022, 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
@ -759,7 +759,7 @@ public class StandardMBean implements DynamicMBean, MBeanRegistration {
desc = descriptors.get(desc);
} else {
Descriptor d = info.getDescriptor();
Map<String,Object> fields = new HashMap<String,Object>();
Map<String,Object> fields = new HashMap<>();
for (String fieldName : d.getFieldNames()) {
if (fieldName.equals("immutableInfo")) {
// Replace immutableInfo as the underlying MBean/MXBean
@ -1145,7 +1145,7 @@ public class StandardMBean implements DynamicMBean, MBeanRegistration {
* is immutable.
*/
private static final Map<Class<?>, Boolean> mbeanInfoSafeMap =
new WeakHashMap<Class<?>, Boolean>();
new WeakHashMap<>();
/**
* Return true if {@code subclass} is known to preserve the immutability

@ -189,7 +189,7 @@ public class MLet extends java.net.URLClassLoader
* @serial
*/
@SuppressWarnings("serial") // Type of field is not Serializable
private List<MLetContent> mletList = new ArrayList<MLetContent>();
private List<MLetContent> mletList = new ArrayList<>();
/**
@ -226,8 +226,7 @@ public class MLet extends java.net.URLClassLoader
* objects maps from primitive classes to primitive object classes.
*/
@SuppressWarnings("serial") // Type of field is not Serializable
private Map<String,Class<?>> primitiveClasses =
new HashMap<String,Class<?>>(8) ;
private Map<String,Class<?>> primitiveClasses = new HashMap<>(8) ;
{
primitiveClasses.put(Boolean.TYPE.toString(), Boolean.class);
primitiveClasses.put(Character.TYPE.toString(), Character.class);
@ -515,7 +514,7 @@ public class MLet extends java.net.URLClassLoader
}
// Walk through the list of MLets
Set<Object> mbeans = new HashSet<Object>();
Set<Object> mbeans = new HashSet<>();
for (MLetContent elmt : mletList) {
// Initialize local variables
String code = elmt.getCode();
@ -609,7 +608,7 @@ public class MLet extends java.net.URLClassLoader
List<String> signat = elmt.getParameterTypes();
List<String> stringPars = elmt.getParameterValues();
List<Object> objectPars = new ArrayList<Object>();
List<Object> objectPars = new ArrayList<>();
for (int i = 0; i < signat.size(); i++) {
objectPars.add(constructParameter(stringPars.get(i),
@ -1275,7 +1274,7 @@ public class MLet extends java.net.URLClassLoader
private synchronized void setMBeanServer(final MBeanServer server) {
this.server = server;
PrivilegedAction<ClassLoaderRepository> act =
new PrivilegedAction<ClassLoaderRepository>() {
new PrivilegedAction<>() {
public ClassLoaderRepository run() {
return server.getClassLoaderRepository();
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2022, 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
@ -114,7 +114,7 @@ class MLetParser {
* Scan tag
*/
public Map<String,String> scanTag(Reader in) throws IOException {
Map<String,String> atts = new HashMap<String,String>();
Map<String,String> atts = new HashMap<>();
skipSpace(in);
while (c >= 0 && c != '>') {
if (c == '<')
@ -172,11 +172,11 @@ class MLetParser {
//
url = conn.getURL();
List<MLetContent> mlets = new ArrayList<MLetContent>();
List<MLetContent> mlets = new ArrayList<>();
Map<String,String> atts = null;
List<String> types = new ArrayList<String>();
List<String> values = new ArrayList<String>();
List<String> types = new ArrayList<>();
List<String> values = new ArrayList<>();
// debug("parse","*** Parsing " + url );
while(true) {
@ -195,8 +195,8 @@ class MLetParser {
mlets.add(new MLetContent(url, atts, types, values));
}
atts = null;
types = new ArrayList<String>();
values = new ArrayList<String>();
types = new ArrayList<>();
values = new ArrayList<>();
}
} else {
String nm = scanIdentifier(in);

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2022, 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
@ -493,8 +493,7 @@ public class DescriptorSupport
}
private void init(Map<String, ?> initMap) {
descriptorMap =
new TreeMap<String, Object>(String.CASE_INSENSITIVE_ORDER);
descriptorMap = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
if (initMap != null)
descriptorMap.putAll(initMap);
}
@ -1062,7 +1061,7 @@ public class DescriptorSupport
"\f&#12;",
};
private static final Map<String,Character> entityToCharMap =
new HashMap<String,Character>();
new HashMap<>();
private static final String[] charToEntityMap;
static {
@ -1319,18 +1318,18 @@ public class DescriptorSupport
*/
SortedMap<String, Object> startMap = descriptorMap;
if (startMap.containsKey("targetObject")) {
startMap = new TreeMap<String, Object>(descriptorMap);
startMap = new TreeMap<>(descriptorMap);
startMap.remove("targetObject");
}
final HashMap<String, Object> descriptor;
if (compat || "1.2.0".equals(serialForm) ||
"1.2.1".equals(serialForm)) {
descriptor = new HashMap<String, Object>();
descriptor = new HashMap<>();
for (Map.Entry<String, Object> entry : startMap.entrySet())
descriptor.put(entry.getKey().toLowerCase(), entry.getValue());
} else
descriptor = new HashMap<String, Object>(startMap);
descriptor = new HashMap<>(startMap);
fields.put("descriptor", descriptor);
out.writeFields();

@ -31,8 +31,6 @@
package javax.management.modelmbean;
/* java imports */
import static com.sun.jmx.defaults.JmxProperties.MODELMBEAN_LOGGER;
import java.io.FileOutputStream;
import java.io.PrintStream;
@ -976,7 +974,7 @@ public class RequiredModelMBean
final String className = opClassName;
final ClassNotFoundException[] caughtException = new ClassNotFoundException[1];
targetClass = javaSecurityAccess.doIntersectionPrivilege(new PrivilegedAction<Class<?>>() {
targetClass = javaSecurityAccess.doIntersectionPrivilege(new PrivilegedAction<>() {
@Override
public Class<?> run() {
@ -1098,7 +1096,7 @@ public class RequiredModelMBean
float.class, short.class, byte.class, char.class,
};
private static final Map<String,Class<?>> primitiveClassMap =
new HashMap<String,Class<?>>();
new HashMap<>();
static {
for (int i = 0; i < primitiveClasses.length; i++) {
final Class<?> c = primitiveClasses[i];
@ -1132,7 +1130,7 @@ public class RequiredModelMBean
@SuppressWarnings("removal")
AccessControlContext stack = AccessController.getContext();
final String className = opClassName;
targetClass = javaSecurityAccess.doIntersectionPrivilege(new PrivilegedAction<Class<?>>() {
targetClass = javaSecurityAccess.doIntersectionPrivilege(new PrivilegedAction<>() {
@Override
public Class<?> run() {
@ -1169,7 +1167,7 @@ public class RequiredModelMBean
final Throwable[] caughtException = new Throwable[1];
@SuppressWarnings("removal")
AccessControlContext stack = AccessController.getContext();
Object rslt = javaSecurityAccess.doIntersectionPrivilege(new PrivilegedAction<Object>() {
Object rslt = javaSecurityAccess.doIntersectionPrivilege(new PrivilegedAction<>() {
@Override
public Object run() {
@ -1290,7 +1288,7 @@ public class RequiredModelMBean
private static synchronized boolean isRMMBMethodName(String name) {
if (rmmbMethodNames == null) {
try {
Set<String> names = new HashSet<String>();
Set<String> names = new HashSet<>();
Method[] methods = RequiredModelMBean.class.getMethods();
for (int i = 0; i < methods.length; i++)
names.add(methods[i].getName());
@ -1582,7 +1580,7 @@ public class RequiredModelMBean
@SuppressWarnings("removal")
AccessControlContext stack = AccessController.getContext();
Class<?> c = javaSecurityAccess.doIntersectionPrivilege(new PrivilegedAction<Class<?>>() {
Class<?> c = javaSecurityAccess.doIntersectionPrivilege(new PrivilegedAction<>() {
@Override
public Class<?> run() {
@ -2666,7 +2664,7 @@ public class RequiredModelMBean
AccessControlContext stack = AccessController.getContext();
final ClassNotFoundException[] caughtException = new ClassNotFoundException[1];
Class<?> c = javaSecurityAccess.doIntersectionPrivilege(new PrivilegedAction<Class<?>>() {
Class<?> c = javaSecurityAccess.doIntersectionPrivilege(new PrivilegedAction<>() {
@Override
public Class<?> run() {

@ -166,7 +166,7 @@ public abstract class Monitor
* Remaining attribute names extracted from complex type attribute name.
*/
private final List<String> remainingAttributes =
new CopyOnWriteArrayList<String>();
new CopyOnWriteArrayList<>();
/**
* AccessControlContext of the Monitor.start() caller.
@ -189,7 +189,7 @@ public abstract class Monitor
* Map containing the thread pool executor per thread group.
*/
private static final Map<ThreadPoolExecutor, Void> executors =
new WeakHashMap<ThreadPoolExecutor, Void>();
new WeakHashMap<>();
/**
* Lock for executors map.
@ -353,7 +353,7 @@ public abstract class Monitor
* List of ObservedObjects to which the attribute to observe belongs.
*/
final List<ObservedObject> observedObjects =
new CopyOnWriteArrayList<ObservedObject>();
new CopyOnWriteArrayList<>();
/**
* Flag denoting that a notification has occurred after changing
@ -1490,7 +1490,7 @@ public abstract class Monitor
maximumPoolSize,
60L,
TimeUnit.SECONDS,
new LinkedBlockingQueue<Runnable>(),
new LinkedBlockingQueue<>(),
new DaemonThreadFactory("ThreadGroup<" +
group.getName() + "> Executor", group));
executor.allowCoreThreadTimeOut(true);
@ -1517,7 +1517,7 @@ public abstract class Monitor
sf = Monitor.this.schedulerFuture;
ac = Monitor.this.acc;
}
PrivilegedAction<Void> action = new PrivilegedAction<Void>() {
PrivilegedAction<Void> action = new PrivilegedAction<>() {
public Void run() {
if (Monitor.this.isActive()) {
final int an[] = alreadyNotifieds;

@ -830,7 +830,7 @@ public class ArrayType<T> extends OpenType<T> {
*/
public static <E> ArrayType<E[]> getArrayType(OpenType<E> elementType)
throws OpenDataException {
return new ArrayType<E[]>(1, elementType);
return new ArrayType<>(1, elementType);
}
/**
@ -976,7 +976,7 @@ public class ArrayType<T> extends OpenType<T> {
break;
}
}
return new ArrayType<T>(cn, tn, d,
return new ArrayType<>(cn, tn, d,
dimension, elementType, primitiveArray);
}
@ -1044,7 +1044,7 @@ public class ArrayType<T> extends OpenType<T> {
break;
}
}
return new ArrayType<T>(cn, tn, d,
return new ArrayType<>(cn, tn, d,
dimension, elementType, primitiveArray);
}
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2022, 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
@ -26,22 +26,15 @@
package javax.management.openmbean;
// java import
//
import java.io.Serializable;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
import java.util.SortedMap;
import java.util.TreeMap;
// jmx import
import java.util.TreeSet;
//
/**
@ -133,7 +126,7 @@ public class CompositeDataSupport
"], itemValues[" + itemValues.length + "]");
}
SortedMap<String, Object> map = new TreeMap<String, Object>();
SortedMap<String, Object> map = new TreeMap<>();
for (int i = 0; i < itemNames.length; i++) {
String name = itemNames[i];
if (name == null || name.equals(""))
@ -182,7 +175,7 @@ public class CompositeDataSupport
if (items == null || items.isEmpty())
throw new IllegalArgumentException("Null or empty items map");
SortedMap<String, Object> map = new TreeMap<String, Object>();
SortedMap<String, Object> map = new TreeMap<>();
for (Object key : items.keySet()) {
if (key == null || key.equals(""))
throw new IllegalArgumentException("Null or empty item name");
@ -214,9 +207,9 @@ public class CompositeDataSupport
// This is just a comparison, but we do it this way for a better
// exception message.
if (!namesFromType.equals(namesFromItems)) {
Set<String> extraFromType = new TreeSet<String>(namesFromType);
Set<String> extraFromType = new TreeSet<>(namesFromType);
extraFromType.removeAll(namesFromItems);
Set<String> extraFromItems = new TreeSet<String>(namesFromItems);
Set<String> extraFromItems = new TreeSet<>(namesFromItems);
extraFromItems.removeAll(namesFromType);
if (!extraFromType.isEmpty() || !extraFromItems.isEmpty()) {
throw new OpenDataException(

@ -26,17 +26,11 @@
package javax.management.openmbean;
// java import
//
import java.util.Set;
import java.util.TreeMap;
import java.util.Collections;
import java.util.Iterator;
// jmx import
//
/**
* The <code>CompositeType</code> class is the <i>open type</i> class
@ -144,8 +138,8 @@ public class CompositeType extends OpenType<CompositeData> {
// Initialize internal "names to descriptions" and "names to types" sorted maps,
// and, by doing so, check there are no duplicate item names
//
nameToDescription = new TreeMap<String,String>();
nameToType = new TreeMap<String,OpenType<?>>();
nameToDescription = new TreeMap<>();
nameToType = new TreeMap<>();
String key;
for (int i=0; i<itemNames.length; i++) {
key = itemNames[i].trim();

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2022, 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
@ -575,11 +575,11 @@ public class OpenMBeanAttributeInfoSupport
T[] legalValues,
Comparable<T> minValue,
Comparable<T> maxValue) {
Map<String, Object> map = new HashMap<String, Object>();
Map<String, Object> map = new HashMap<>();
if (defaultValue != null)
map.put("defaultValue", defaultValue);
if (legalValues != null) {
Set<T> set = new HashSet<T>();
Set<T> set = new HashSet<>();
for (T v : legalValues)
set.add(v);
set = Collections.unmodifiableSet(set);
@ -654,7 +654,7 @@ public class OpenMBeanAttributeInfoSupport
throw new IllegalArgumentException(msg);
}
Set<T> result = new HashSet<T>();
Set<T> result = new HashSet<>();
for (Object element : coll)
result.add(convertFrom(element, openType));
return result;

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2022, 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
@ -26,9 +26,6 @@
package javax.management.openmbean;
// java import
//
import java.util.Arrays;
import java.util.HashSet;
import java.util.Objects;
@ -301,8 +298,8 @@ public class OpenMBeanInfoSupport
}
private static <T> boolean sameArrayContents(T[] a1, T[] a2) {
return (new HashSet<T>(Arrays.asList(a1))
.equals(new HashSet<T>(Arrays.asList(a2))));
return (new HashSet<>(Arrays.asList(a1))
.equals(new HashSet<>(Arrays.asList(a2))));
}
/**
@ -360,7 +357,7 @@ public class OpenMBeanInfoSupport
}
private static <T> int arraySetHash(T[] a) {
return new HashSet<T>(Arrays.asList(a)).hashCode();
return new HashSet<>(Arrays.asList(a)).hashCode();
}

@ -209,7 +209,7 @@ public abstract class OpenType<T> implements Serializable {
@SuppressWarnings("removal")
private static boolean overridesGetClassName(final Class<?> c) {
return AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
return AccessController.doPrivileged(new PrivilegedAction<>() {
public Boolean run() {
try {
return (c.getMethod("getClassName").getDeclaringClass() !=

@ -73,98 +73,98 @@ public final class SimpleType<T> extends OpenType<T> {
* Java class name is <code>java.lang.Void</code>.
*/
public static final SimpleType<Void> VOID =
new SimpleType<Void>(Void.class);
new SimpleType<>(Void.class);
/**
* The <code>SimpleType</code> instance describing values whose
* Java class name is <code>java.lang.Boolean</code>.
*/
public static final SimpleType<Boolean> BOOLEAN =
new SimpleType<Boolean>(Boolean.class);
new SimpleType<>(Boolean.class);
/**
* The <code>SimpleType</code> instance describing values whose
* Java class name is <code>java.lang.Character</code>.
*/
public static final SimpleType<Character> CHARACTER =
new SimpleType<Character>(Character.class);
new SimpleType<>(Character.class);
/**
* The <code>SimpleType</code> instance describing values whose
* Java class name is <code>java.lang.Byte</code>.
*/
public static final SimpleType<Byte> BYTE =
new SimpleType<Byte>(Byte.class);
new SimpleType<>(Byte.class);
/**
* The <code>SimpleType</code> instance describing values whose
* Java class name is <code>java.lang.Short</code>.
*/
public static final SimpleType<Short> SHORT =
new SimpleType<Short>(Short.class);
new SimpleType<>(Short.class);
/**
* The <code>SimpleType</code> instance describing values whose
* Java class name is <code>java.lang.Integer</code>.
*/
public static final SimpleType<Integer> INTEGER =
new SimpleType<Integer>(Integer.class);
new SimpleType<>(Integer.class);
/**
* The <code>SimpleType</code> instance describing values whose
* Java class name is <code>java.lang.Long</code>.
*/
public static final SimpleType<Long> LONG =
new SimpleType<Long>(Long.class);
new SimpleType<>(Long.class);
/**
* The <code>SimpleType</code> instance describing values whose
* Java class name is <code>java.lang.Float</code>.
*/
public static final SimpleType<Float> FLOAT =
new SimpleType<Float>(Float.class);
new SimpleType<>(Float.class);
/**
* The <code>SimpleType</code> instance describing values whose
* Java class name is <code>java.lang.Double</code>.
*/
public static final SimpleType<Double> DOUBLE =
new SimpleType<Double>(Double.class);
new SimpleType<>(Double.class);
/**
* The <code>SimpleType</code> instance describing values whose
* Java class name is <code>java.lang.String</code>.
*/
public static final SimpleType<String> STRING =
new SimpleType<String>(String.class);
new SimpleType<>(String.class);
/**
* The <code>SimpleType</code> instance describing values whose
* Java class name is <code>java.math.BigDecimal</code>.
*/
public static final SimpleType<BigDecimal> BIGDECIMAL =
new SimpleType<BigDecimal>(BigDecimal.class);
new SimpleType<>(BigDecimal.class);
/**
* The <code>SimpleType</code> instance describing values whose
* Java class name is <code>java.math.BigInteger</code>.
*/
public static final SimpleType<BigInteger> BIGINTEGER =
new SimpleType<BigInteger>(BigInteger.class);
new SimpleType<>(BigInteger.class);
/**
* The <code>SimpleType</code> instance describing values whose
* Java class name is <code>java.util.Date</code>.
*/
public static final SimpleType<Date> DATE =
new SimpleType<Date>(Date.class);
new SimpleType<>(Date.class);
/**
* The <code>SimpleType</code> instance describing values whose
* Java class name is <code>javax.management.ObjectName</code>.
*/
public static final SimpleType<ObjectName> OBJECTNAME =
new SimpleType<ObjectName>(ObjectName.class);
new SimpleType<>(ObjectName.class);
private static final SimpleType<?>[] typeArray = {
VOID, BOOLEAN, CHARACTER, BYTE, SHORT, INTEGER, LONG, FLOAT,
@ -294,7 +294,7 @@ public final class SimpleType<T> extends OpenType<T> {
}
private static final Map<SimpleType<?>,SimpleType<?>> canonicalTypes =
new HashMap<SimpleType<?>,SimpleType<?>>();
new HashMap<>();
static {
for (int i = 0; i < typeArray.length; i++) {
final SimpleType<?> type = typeArray[i];

@ -26,9 +26,6 @@
package javax.management.openmbean;
// java import
//
import com.sun.jmx.mbeanserver.GetPropertyAction;
import com.sun.jmx.mbeanserver.Util;
import java.io.IOException;
@ -47,9 +44,6 @@ import java.util.Map;
import java.util.Set;
import jdk.internal.access.SharedSecrets;
// jmx import
//
/**
* The {@code TabularDataSupport} class is the <i>open data</i>
@ -162,8 +156,8 @@ public class TabularDataSupport
// Construct the empty contents HashMap
//
this.dataMap = useHashMap ?
new HashMap<Object,CompositeData>(initialCapacity, loadFactor) :
new LinkedHashMap<Object, CompositeData>(initialCapacity, loadFactor);
new HashMap<>(initialCapacity, loadFactor) :
new LinkedHashMap<>(initialCapacity, loadFactor);
}
@ -512,7 +506,7 @@ public class TabularDataSupport
// create the list of indexes corresponding to each value
List<List<?>> indexes =
new ArrayList<List<?>>(values.length + 1);
new ArrayList<>(values.length + 1);
// Check all elements in values and build index list
//
@ -677,7 +671,7 @@ public class TabularDataSupport
public Object clone() {
try {
TabularDataSupport c = (TabularDataSupport) super.clone();
c.dataMap = new HashMap<Object,CompositeData>(c.dataMap);
c.dataMap = new HashMap<>(c.dataMap);
return c;
}
catch (CloneNotSupportedException e) {

@ -26,17 +26,10 @@
package javax.management.openmbean;
// java import
//
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
// jmx import
//
/**
* The <code>TabularType</code> class is the <i> open type</i> class
@ -139,7 +132,7 @@ public class TabularType extends OpenType<TabularData> {
// modifs to the array referenced by the indexNames parameter
// have no impact)
//
List<String> tmpList = new ArrayList<String>(indexNames.length + 1);
List<String> tmpList = new ArrayList<>(indexNames.length + 1);
for (int i=0; i<indexNames.length; i++) {
tmpList.add(indexNames[i]);
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2022, 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
@ -44,9 +44,7 @@ import javax.management.Notification;
import javax.management.NotificationFilterSupport;
import javax.management.ObjectName;
import java.util.List;
import java.lang.System.Logger.Level;
import java.util.Vector;
/**
* Filter for {@link MBeanServerNotification}.
@ -138,7 +136,7 @@ public class MBeanServerNotificationFilter extends NotificationFilterSupport {
* <li>Empty vector means that no {@link ObjectName} is explicitly selected</li>
* </ul>
*/
private List<ObjectName> selectedNames = new Vector<ObjectName>();
private List<ObjectName> selectedNames = new Vector<>();
/**
* @serial List of {@link ObjectName}s with no interest
@ -182,7 +180,7 @@ public class MBeanServerNotificationFilter extends NotificationFilterSupport {
RELATION_LOGGER.log(Level.TRACE, "ENTRY");
selectedNames = new Vector<ObjectName>();
selectedNames = new Vector<>();
deselectedNames = null;
RELATION_LOGGER.log(Level.TRACE, "RETURN");
@ -234,7 +232,7 @@ public class MBeanServerNotificationFilter extends NotificationFilterSupport {
RELATION_LOGGER.log(Level.TRACE, "ENTRY");
selectedNames = null;
deselectedNames = new Vector<ObjectName>();
deselectedNames = new Vector<>();
RELATION_LOGGER.log(Level.TRACE, "RETURN");
return;
@ -288,7 +286,7 @@ public class MBeanServerNotificationFilter extends NotificationFilterSupport {
*/
public synchronized Vector<ObjectName> getEnabledObjectNames() {
if (selectedNames != null) {
return new Vector<ObjectName>(selectedNames);
return new Vector<>(selectedNames);
} else {
return null;
}
@ -305,7 +303,7 @@ public class MBeanServerNotificationFilter extends NotificationFilterSupport {
*/
public synchronized Vector<ObjectName> getDisabledObjectNames() {
if (deselectedNames != null) {
return new Vector<ObjectName>(deselectedNames);
return new Vector<>(deselectedNames);
} else {
return null;
}

@ -35,7 +35,6 @@ import java.io.ObjectOutputStream;
import java.io.ObjectStreamField;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.ArrayList;
import java.util.Arrays;
@ -365,7 +364,7 @@ public class RelationNotification extends Notification {
public List<ObjectName> getMBeansToUnregister() {
List<ObjectName> result;
if (unregisterMBeanList != null) {
result = new ArrayList<ObjectName>(unregisterMBeanList);
result = new ArrayList<>(unregisterMBeanList);
} else {
result = Collections.emptyList();
}
@ -393,7 +392,7 @@ public class RelationNotification extends Notification {
public List<ObjectName> getOldRoleValue() {
List<ObjectName> result;
if (oldRoleValue != null) {
result = new ArrayList<ObjectName>(oldRoleValue);
result = new ArrayList<>(oldRoleValue);
} else {
result = Collections.emptyList();
}
@ -408,7 +407,7 @@ public class RelationNotification extends Notification {
public List<ObjectName> getNewRoleValue() {
List<ObjectName> result;
if (newRoleValue != null) {
result = new ArrayList<ObjectName>(newRoleValue);
result = new ArrayList<>(newRoleValue);
} else {
result = Collections.emptyList();
}
@ -490,7 +489,7 @@ public class RelationNotification extends Notification {
RelationNotification.RELATION_BASIC_REMOVAL,
RelationNotification.RELATION_MBEAN_REMOVAL};
Set<String> ctSet = new HashSet<String>(Arrays.asList(validTypes));
Set<String> ctSet = new HashSet<>(Arrays.asList(validTypes));
return ctSet.contains(notifType);
}
@ -512,7 +511,7 @@ public class RelationNotification extends Notification {
private ArrayList<ObjectName> safeGetObjectNameList(List<ObjectName> src){
ArrayList<ObjectName> dest = null;
if (src != null) {
dest = new ArrayList<ObjectName>();
dest = new ArrayList<>();
for (ObjectName item : src) {
// NPE thrown if we attempt to add null object
dest.add(ObjectName.getInstance(item));

@ -80,27 +80,27 @@ public class RelationService extends NotificationBroadcasterSupport
// depending if the relation has been created using createRelation()
// method (so internally handled) or is an MBean added as a relation by the
// user
private Map<String,Object> myRelId2ObjMap = new HashMap<String,Object>();
private Map<String,Object> myRelId2ObjMap = new HashMap<>();
// Map associating:
// <relation id> -> <relation type name>
private Map<String,String> myRelId2RelTypeMap = new HashMap<String,String>();
private Map<String,String> myRelId2RelTypeMap = new HashMap<>();
// Map associating:
// <relation MBean Object Name> -> <relation id>
private Map<ObjectName,String> myRelMBeanObjName2RelIdMap =
new HashMap<ObjectName,String>();
new HashMap<>();
// Map associating:
// <relation type name> -> <RelationType object>
private Map<String,RelationType> myRelType2ObjMap =
new HashMap<String,RelationType>();
new HashMap<>();
// Map associating:
// <relation type name> -> ArrayList of <relation id>
// to list all the relations of a given type
private Map<String,List<String>> myRelType2RelIdsMap =
new HashMap<String,List<String>>();
new HashMap<>();
// Map associating:
// <ObjectName> -> HashMap
@ -109,7 +109,7 @@ public class RelationService extends NotificationBroadcasterSupport
// to track where a given MBean is referenced.
private final Map<ObjectName,Map<String,List<String>>>
myRefedMBeanObjName2RelIdsMap =
new HashMap<ObjectName,Map<String,List<String>>>();
new HashMap<>();
// Flag to indicate if, when a notification is received for the
// unregistration of an MBean referenced in a relation, if an immediate
@ -138,7 +138,7 @@ public class RelationService extends NotificationBroadcasterSupport
// of relations when unregistering a referenced MBean is not immediate but
// on user request)
private List<MBeanServerNotification> myUnregNtfList =
new ArrayList<MBeanServerNotification>();
new ArrayList<>();
//
// Constructor
@ -352,7 +352,7 @@ public class RelationService extends NotificationBroadcasterSupport
public List<String> getAllRelationTypeNames() {
ArrayList<String> result;
synchronized(myRelType2ObjMap) {
result = new ArrayList<String>(myRelType2ObjMap.keySet());
result = new ArrayList<>(myRelType2ObjMap.keySet());
}
return result;
}
@ -465,7 +465,7 @@ public class RelationService extends NotificationBroadcasterSupport
List<String> relIdList1 =
myRelType2RelIdsMap.get(relationTypeName);
if (relIdList1 != null) {
relIdList = new ArrayList<String>(relIdList1);
relIdList = new ArrayList<>(relIdList1);
}
}
@ -766,7 +766,7 @@ public class RelationService extends NotificationBroadcasterSupport
// Updates listener information to received notification for
// unregistration of this MBean
List<ObjectName> newRefList = new ArrayList<ObjectName>();
List<ObjectName> newRefList = new ArrayList<>();
newRefList.add(relationObjectName);
updateUnregistrationListener(newRefList, null);
@ -877,7 +877,7 @@ public class RelationService extends NotificationBroadcasterSupport
public List<String> getAllRelationIds() {
List<String> result;
synchronized(myRelId2ObjMap) {
result = new ArrayList<String>(myRelId2ObjMap.keySet());
result = new ArrayList<>(myRelId2ObjMap.keySet());
}
return result;
}
@ -1081,7 +1081,7 @@ public class RelationService extends NotificationBroadcasterSupport
}
if (!(oldValue instanceof ArrayList<?>))
oldValue = new ArrayList<ObjectName>(oldValue);
oldValue = new ArrayList<>(oldValue);
RELATION_LOGGER.log(Level.TRACE, "ENTRY {0} {1} {2}",
relationId, newRole, oldValue);
@ -1205,11 +1205,10 @@ public class RelationService extends NotificationBroadcasterSupport
List<ObjectName> newRoleValue = newRole.getRoleValue();
// Note: no need to test if oldValue not null before cloning,
// tested above.
List<ObjectName> oldRoleValue =
new ArrayList<ObjectName>(oldValue);
List<ObjectName> oldRoleValue = new ArrayList<>(oldValue);
// List of ObjectNames of new referenced MBeans
List<ObjectName> newRefList = new ArrayList<ObjectName>();
List<ObjectName> newRefList = new ArrayList<>();
for (ObjectName currObjName : newRoleValue) {
@ -1244,7 +1243,7 @@ public class RelationService extends NotificationBroadcasterSupport
}
// List of ObjectNames of MBeans no longer referenced
List<ObjectName> obsRefList = new ArrayList<ObjectName>();
List<ObjectName> obsRefList = new ArrayList<>();
// Each ObjectName remaining in oldRoleValue is an ObjectName no longer
// referenced in new value
@ -1310,7 +1309,7 @@ public class RelationService extends NotificationBroadcasterSupport
// Removes it from listener filter
if (result instanceof ObjectName) {
List<ObjectName> obsRefList = new ArrayList<ObjectName>();
List<ObjectName> obsRefList = new ArrayList<>();
obsRefList.add((ObjectName)result);
// Can throw a RelationServiceNotRegisteredException
updateUnregistrationListener(null, obsRefList);
@ -1339,10 +1338,10 @@ public class RelationService extends NotificationBroadcasterSupport
// on the relation itself. Ok if it is an internal one, but if
// it is an MBean, it is possible it is already unregistered, so
// not available through the MBean Server.
List<ObjectName> refMBeanList = new ArrayList<ObjectName>();
List<ObjectName> refMBeanList = new ArrayList<>();
// List of MBeans no longer referenced in any relation, to be
// removed fom the map
List<ObjectName> nonRefObjNameList = new ArrayList<ObjectName>();
List<ObjectName> nonRefObjNameList = new ArrayList<>();
synchronized(myRefedMBeanObjName2RelIdsMap) {
@ -1454,10 +1453,9 @@ public class RelationService extends NotificationBroadcasterSupport
// notifications while proceeding those ones
List<MBeanServerNotification> localUnregNtfList;
synchronized(myRefedMBeanObjName2RelIdsMap) {
localUnregNtfList =
new ArrayList<MBeanServerNotification>(myUnregNtfList);
localUnregNtfList = new ArrayList<>(myUnregNtfList);
// Resets list
myUnregNtfList = new ArrayList<MBeanServerNotification>();
myUnregNtfList = new ArrayList<>();
}
@ -1467,11 +1465,11 @@ public class RelationService extends NotificationBroadcasterSupport
// ObjectName -> relId -> roles, to remove the MBean from the global
// map
// List of references to be removed from the listener filter
List<ObjectName> obsRefList = new ArrayList<ObjectName>();
List<ObjectName> obsRefList = new ArrayList<>();
// Map including ObjectNames for unregistered MBeans, with
// referencing relation ids and roles
Map<ObjectName,Map<String,List<String>>> localMBean2RelIdMap =
new HashMap<ObjectName,Map<String,List<String>>>();
new HashMap<>();
synchronized(myRefedMBeanObjName2RelIdsMap) {
for (MBeanServerNotification currNtf : localUnregNtfList) {
@ -1571,7 +1569,7 @@ public class RelationService extends NotificationBroadcasterSupport
RELATION_LOGGER.log(Level.TRACE, "ENTRY {0} {1} {2}",
mbeanName, relationTypeName, roleName);
Map<String,List<String>> result = new HashMap<String,List<String>>();
Map<String,List<String>> result = new HashMap<>();
synchronized(myRefedMBeanObjName2RelIdsMap) {
@ -1589,11 +1587,11 @@ public class RelationService extends NotificationBroadcasterSupport
List<String> relIdList;
if (relationTypeName == null) {
// Considers all relations
relIdList = new ArrayList<String>(allRelIdSet);
relIdList = new ArrayList<>(allRelIdSet);
} else {
relIdList = new ArrayList<String>();
relIdList = new ArrayList<>();
// Considers only the relation ids for relations of given
// type
@ -1628,12 +1626,12 @@ public class RelationService extends NotificationBroadcasterSupport
// Note: no need to test if list not null before
// cloning, MUST be not null else bug :(
result.put(currRelId,
new ArrayList<String>(currRoleNameList));
new ArrayList<>(currRoleNameList));
} else if (currRoleNameList.contains(roleName)) {
// Filters only the relations where the MBean is
// referenced in // given role
List<String> dummyList = new ArrayList<String>();
List<String> dummyList = new ArrayList<>();
dummyList.add(roleName);
result.put(currRelId, dummyList);
}
@ -1686,8 +1684,7 @@ public class RelationService extends NotificationBroadcasterSupport
relationTypeName,
roleName);
Map<ObjectName,List<String>> result =
new HashMap<ObjectName,List<String>>();
Map<ObjectName,List<String>> result = new HashMap<>();
for (String currRelId : relId2RoleNamesMap.keySet()) {
@ -1713,7 +1710,7 @@ public class RelationService extends NotificationBroadcasterSupport
List<String> currRelIdList = result.get(currObjName);
if (currRelIdList == null) {
currRelIdList = new ArrayList<String>();
currRelIdList = new ArrayList<>();
currRelIdList.add(currRelId);
result.put(currObjName, currRelIdList);
@ -1757,9 +1754,9 @@ public class RelationService extends NotificationBroadcasterSupport
synchronized(myRelType2RelIdsMap) {
List<String> result1 = myRelType2RelIdsMap.get(relationTypeName);
if (result1 == null)
result = new ArrayList<String>();
result = new ArrayList<>();
else
result = new ArrayList<String>(result1);
result = new ArrayList<>(result1);
}
RELATION_LOGGER.log(Level.TRACE, "RETURN");
@ -1836,7 +1833,7 @@ public class RelationService extends NotificationBroadcasterSupport
if (invokeResult == null || invokeResult instanceof ArrayList<?>)
result = invokeResult;
else
result = new ArrayList<ObjectName>(invokeResult);
result = new ArrayList<>(invokeResult);
} catch (InstanceNotFoundException | ReflectionException exc1) {
throw new RuntimeException(exc1.getMessage());
} catch (MBeanException exc2) {
@ -2626,11 +2623,11 @@ public class RelationService extends NotificationBroadcasterSupport
// List of roles where the MBean is referenced in given
// relation
List<String> roleNames = new ArrayList<String>();
List<String> roleNames = new ArrayList<>();
roleNames.add(roleName);
// Map of relations where the MBean is referenced
mbeanRefMap = new HashMap<String,List<String>>();
mbeanRefMap = new HashMap<>();
mbeanRefMap.put(relationId, roleNames);
myRefedMBeanObjName2RelIdsMap.put(objectName, mbeanRefMap);
@ -2646,7 +2643,7 @@ public class RelationService extends NotificationBroadcasterSupport
// List of roles where the MBean is referenced in given
// relation
roleNames = new ArrayList<String>();
roleNames = new ArrayList<>();
roleNames.add(roleName);
// Adds new reference done in current relation
@ -2953,7 +2950,7 @@ public class RelationService extends NotificationBroadcasterSupport
// to see which roles have not been initialized
// Note: no need to test if list not null before cloning, not allowed
// to have an empty relation type.
List<RoleInfo> roleInfoList = new ArrayList<RoleInfo>(relType.getRoleInfos());
List<RoleInfo> roleInfoList = new ArrayList<>(relType.getRoleInfos());
if (roleList != null) {
@ -3026,7 +3023,7 @@ public class RelationService extends NotificationBroadcasterSupport
boolean firstRelFlag = false;
if (relIdList == null) {
firstRelFlag = true;
relIdList = new ArrayList<String>();
relIdList = new ArrayList<>();
}
relIdList.add(relationId);
if (firstRelFlag) {
@ -3041,7 +3038,7 @@ public class RelationService extends NotificationBroadcasterSupport
for (Role currRole : roleList.asList()) {
// Creates a dummy empty ArrayList of ObjectNames to be the old
// role value :)
List<ObjectName> dummyList = new ArrayList<ObjectName>();
List<ObjectName> dummyList = new ArrayList<>();
// Will not throw a RelationNotFoundException (as the RelId2Obj map
// has been updated above) so catch it :)
try {
@ -3250,7 +3247,7 @@ public class RelationService extends NotificationBroadcasterSupport
String roleName = currRoleInfo.getName();
// Creates an empty value
List<ObjectName> emptyValue = new ArrayList<ObjectName>();
List<ObjectName> emptyValue = new ArrayList<>();
// Creates a role
Role role = new Role(roleName, emptyValue);

@ -107,7 +107,7 @@ public class RelationSupport
// via Relation Service setRole() and setRoles() methods
// - if the relation is internal to the Relation Service, via
// setRoleInt() and setRolesInt() methods.
private final Map<String,Role> myRoleName2ValueMap = new HashMap<String,Role>();
private final Map<String,Role> myRoleName2ValueMap = new HashMap<>();
// Flag to indicate if the object has been added in the Relation Service
private final AtomicBoolean myInRelServFlg = new AtomicBoolean();
@ -365,7 +365,7 @@ public class RelationSupport
RoleList result;
synchronized(myRoleName2ValueMap) {
result =
new RoleList(new ArrayList<Role>(myRoleName2ValueMap.values()));
new RoleList(new ArrayList<>(myRoleName2ValueMap.values()));
}
RELATION_LOGGER.log(Level.TRACE, "RETURN");
@ -580,8 +580,7 @@ public class RelationSupport
RELATION_LOGGER.log(Level.TRACE, "ENTRY");
Map<ObjectName,List<String>> refMBeanMap =
new HashMap<ObjectName,List<String>>();
Map<ObjectName,List<String>> refMBeanMap = new HashMap<>();
synchronized(myRoleName2ValueMap) {
@ -601,7 +600,7 @@ public class RelationSupport
boolean newRefFlg = false;
if (mbeanRoleNameList == null) {
newRefFlg = true;
mbeanRoleNameList = new ArrayList<String>();
mbeanRoleNameList = new ArrayList<>();
}
mbeanRoleNameList.add(currRoleName);
if (newRefFlg) {
@ -836,7 +835,7 @@ public class RelationSupport
// Note: no need to test if role value (list) not null before
// cloning, null value not allowed, empty list if
// nothing.
result = new ArrayList<ObjectName>(role.getRoleValue());
result = new ArrayList<>(role.getRoleValue());
} else {
// Role retrieved during multi-role retrieval: returns the
@ -974,8 +973,7 @@ public class RelationSupport
List<String> roleNameList;
synchronized(myRoleName2ValueMap) {
roleNameList =
new ArrayList<String>(myRoleName2ValueMap.keySet());
roleNameList = new ArrayList<>(myRoleName2ValueMap.keySet());
}
String[] roleNames = new String[roleNameList.size()];
roleNameList.toArray(roleNames);
@ -1082,7 +1080,7 @@ public class RelationSupport
if (role == null) {
initFlg = true;
oldRoleValue = new ArrayList<ObjectName>();
oldRoleValue = new ArrayList<>();
} else {
initFlg = false;
@ -1683,7 +1681,7 @@ public class RelationSupport
// Note: no need to test if list not null before cloning, null value
// not allowed for role value.
List<ObjectName> newRoleValue = new ArrayList<ObjectName>(currRoleValue);
List<ObjectName> newRoleValue = new ArrayList<>(currRoleValue);
newRoleValue.remove(objectName);
Role newRole = new Role(roleName, newRoleValue);

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2022, 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
@ -138,8 +138,7 @@ public class RelationTypeSupport implements RelationType {
* @serial {@link Map} holding the mapping:
* &lt;role name ({@link String})&gt; -&gt; &lt;role info ({@link RoleInfo} object)&gt;
*/
private Map<String,RoleInfo> roleName2InfoMap =
new HashMap<String,RoleInfo>();
private Map<String,RoleInfo> roleName2InfoMap = new HashMap<>();
/**
* @serial Flag specifying whether the relation type has been declared in the
@ -223,7 +222,7 @@ public class RelationTypeSupport implements RelationType {
* Returns the list of role definitions (ArrayList of RoleInfo objects).
*/
public List<RoleInfo> getRoleInfos() {
return new ArrayList<RoleInfo>(roleName2InfoMap.values());
return new ArrayList<>(roleName2InfoMap.values());
}
/**
@ -390,7 +389,7 @@ public class RelationTypeSupport implements RelationType {
}
Set<String> roleNames = new HashSet<String>();
Set<String> roleNames = new HashSet<>();
for (int i = 0; i < roleInfoArray.length; i++) {
RoleInfo currRoleInfo = roleInfoArray[i];

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2022, 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
@ -120,7 +120,7 @@ public class Role implements Serializable {
/**
* @serial {@link List} of {@link ObjectName}s of referenced MBeans
*/
private List<ObjectName> objectNameList = new ArrayList<ObjectName>();
private List<ObjectName> objectNameList = new ArrayList<>();
//
// Constructors
@ -217,7 +217,7 @@ public class Role implements Serializable {
throw new IllegalArgumentException(excMsg);
}
objectNameList = new ArrayList<ObjectName>(roleValue);
objectNameList = new ArrayList<>(roleValue);
return;
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2022, 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
@ -235,7 +235,7 @@ public class RoleUnresolved implements Serializable {
public void setRoleValue(List<ObjectName> value) {
if (value != null) {
roleValue = new ArrayList<ObjectName>(value);
roleValue = new ArrayList<>(value);
} else {
roleValue = null;
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 2022, 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
@ -272,11 +272,11 @@ public class JMXConnectorFactory {
}
private static <K,V> Map<K,V> newHashMap() {
return new HashMap<K,V>();
return new HashMap<>();
}
private static <K> Map<K,Object> newHashMap(Map<K,?> map) {
return new HashMap<K,Object>(map);
return new HashMap<>(map);
}
/**
@ -449,7 +449,7 @@ public class JMXConnectorFactory {
@SuppressWarnings("removal")
private static ClassLoader wrap(final ClassLoader parent) {
return parent != null ? AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
return parent != null ? AccessController.doPrivileged(new PrivilegedAction<>() {
@Override
public ClassLoader run() {
return new ClassLoader(parent) {

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2022, 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
@ -407,7 +407,7 @@ public abstract class JMXConnectorServer
*/
private ObjectName myName;
private final List<String> connectionIds = new ArrayList<String>();
private final List<String> connectionIds = new ArrayList<>();
private static final int[] sequenceNumberLock = new int[0];
private static long sequenceNumber;

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2022, 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 com.sun.jmx.remote.util.ClassLogger;
import com.sun.jmx.remote.util.EnvHelp;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.net.MalformedURLException;
import java.util.Collections;
import java.util.HashMap;
@ -262,10 +261,10 @@ public class JMXConnectorServerFactory {
throws IOException {
Map<String, Object> envcopy;
if (environment == null)
envcopy = new HashMap<String, Object>();
envcopy = new HashMap<>();
else {
EnvHelp.checkAttributes(environment);
envcopy = new HashMap<String, Object>(environment);
envcopy = new HashMap<>(environment);
}
final Class<JMXConnectorServerProvider> targetInterface =

@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2022, 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
@ -246,7 +246,7 @@ public class Timer extends NotificationBroadcasterSupport
* that were given to addNotification.
*/
public synchronized MBeanNotificationInfo[] getNotificationInfo() {
Set<String> notifTypes = new TreeSet<String>();
Set<String> notifTypes = new TreeSet<>();
for (Object[] entry : timerTable.values()) {
TimerNotification notif = (TimerNotification)
entry[TIMER_NOTIF_INDEX];
@ -771,7 +771,7 @@ public class Timer extends NotificationBroadcasterSupport
* <BR>The vector is empty if there is no timer notification registered for this timer MBean.
*/
public synchronized Vector<Integer> getAllNotificationIDs() {
return new Vector<Integer>(timerTable.keySet());
return new Vector<>(timerTable.keySet());
}
/**
@ -788,7 +788,7 @@ public class Timer extends NotificationBroadcasterSupport
String s;
Vector<Integer> v = new Vector<Integer>();
Vector<Integer> v = new Vector<>();
for (Map.Entry<Integer,Object[]> entry : timerTable.entrySet()) {
Object[] obj = entry.getValue();
@ -988,8 +988,7 @@ public class Timer extends NotificationBroadcasterSupport
Integer notifID;
Date date;
ArrayList<Object[]> values =
new ArrayList<Object[]>(timerTable.values());
ArrayList<Object[]> values = new ArrayList<>(timerTable.values());
for (Object[] obj : values) {

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2022, 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
@ -25,10 +25,7 @@
package sun.management;
import java.util.regex.*;
import java.util.List;
import java.util.ListIterator;
import java.util.Iterator;
import java.util.ArrayList;
import java.util.Map;
import java.util.TreeMap;
@ -150,7 +147,7 @@ class HotspotCompilation
numActiveThreads = (int) compilerThreads.longValue();
// Allocate CompilerThreadInfo for compilerThread and adaptorThread
threads = new ArrayList<CompilerThreadInfo>();
threads = new ArrayList<>();
for (int i = 0; i < numActiveThreads; i++) {
if (counters.containsKey(SUN_CI + "compilerThread." + i + ".method")) {

@ -24,6 +24,7 @@
*/
package sun.management;
import java.lang.management.MemoryUsage;
import java.lang.management.MemoryNotificationInfo;
import java.lang.management.MonitorInfo;
@ -616,7 +617,7 @@ public abstract class MappedMXBeanType {
// check if a static from method exists
try {
fromMethod = AccessController.doPrivileged(new PrivilegedExceptionAction<Method>() {
fromMethod = AccessController.doPrivileged(new PrivilegedExceptionAction<>() {
public Method run() throws NoSuchMethodException {
return javaClass.getMethod("from", COMPOSITE_DATA_CLASS);
}
@ -637,7 +638,7 @@ public abstract class MappedMXBeanType {
// Make a CompositeData containing all the getters
final Method[] methods =
AccessController.doPrivileged(new PrivilegedAction<Method[]>() {
AccessController.doPrivileged(new PrivilegedAction<>() {
public Method[] run() {
return javaClass.getMethods();
}

@ -205,7 +205,7 @@ class VMManagementImpl implements VMManagement {
public String getCompilerName() {
@SuppressWarnings("removal")
String name = AccessController.doPrivileged(
new PrivilegedAction<String>() {
new PrivilegedAction<>() {
public String run() {
return System.getProperty("sun.management.compiler");
}