src/share/classes/java/lang/Class.java
Print this page
rev 3186 : 6880112: Project Coin: Port JDK core library code to use diamond operator
@@ -1304,11 +1304,11 @@
// has already been ok'd by the SecurityManager.
return java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction<Class<?>[]>() {
public Class[] run() {
- List<Class<?>> list = new ArrayList<Class<?>>();
+ List<Class<?>> list = new ArrayList<>();
Class<?> currentClass = Class.this;
while (currentClass != null) {
Class<?>[] members = currentClass.getDeclaredClasses();
for (int i = 0; i < members.length; i++) {
if (Modifier.isPublic(members[i].getModifiers())) {
@@ -2304,13 +2304,13 @@
}
// No cached value available; request value from VM
res = Reflection.filterFields(this, getDeclaredFields0(publicOnly));
if (useCaches) {
if (publicOnly) {
- declaredPublicFields = new SoftReference<Field[]>(res);
+ declaredPublicFields = new SoftReference<>(res);
} else {
- declaredFields = new SoftReference<Field[]>(res);
+ declaredFields = new SoftReference<>(res);
}
}
return res;
}
@@ -2328,13 +2328,13 @@
if (res != null) return res;
}
// No cached value available; compute value recursively.
// Traverse in correct order for getField().
- List<Field> fields = new ArrayList<Field>();
+ List<Field> fields = new ArrayList<>();
if (traversedInterfaces == null) {
- traversedInterfaces = new HashSet<Class<?>>();
+ traversedInterfaces = new HashSet<>();
}
// Local fields
Field[] tmp = privateGetDeclaredFields(true);
addAll(fields, tmp);
@@ -2356,11 +2356,11 @@
}
res = new Field[fields.size()];
fields.toArray(res);
if (useCaches) {
- publicFields = new SoftReference<Field[]>(res);
+ publicFields = new SoftReference<>(res);
}
return res;
}
private static void addAll(Collection<Field> c, Field[] o) {
@@ -2401,13 +2401,13 @@
} else {
res = getDeclaredConstructors0(publicOnly);
}
if (useCaches) {
if (publicOnly) {
- publicConstructors = new SoftReference<Constructor<T>[]>(res);
+ publicConstructors = new SoftReference<>(res);
} else {
- declaredConstructors = new SoftReference<Constructor<T>[]>(res);
+ declaredConstructors = new SoftReference<>(res);
}
}
return res;
}
@@ -2438,13 +2438,13 @@
}
// No cached value available; request value from VM
res = Reflection.filterMethods(this, getDeclaredMethods0(publicOnly));
if (useCaches) {
if (publicOnly) {
- declaredPublicMethods = new SoftReference<Method[]>(res);
+ declaredPublicMethods = new SoftReference<>(res);
} else {
- declaredMethods = new SoftReference<Method[]>(res);
+ declaredMethods = new SoftReference<>(res);
}
}
return res;
}
@@ -2596,11 +2596,11 @@
}
methods.addAllIfNotPresent(inheritedMethods);
methods.compactAndTrim();
res = methods.getArray();
if (useCaches) {
- publicMethods = new SoftReference<Method[]>(res);
+ publicMethods = new SoftReference<>(res);
}
return res;
}
@@ -2975,11 +2975,11 @@
if (enumConstantDirectory == null) {
T[] universe = getEnumConstantsShared();
if (universe == null)
throw new IllegalArgumentException(
getName() + " is not an enum type");
- Map<String, T> m = new HashMap<String, T>(2 * universe.length);
+ Map<String, T> m = new HashMap<>(2 * universe.length);
for (T constant : universe)
m.put(((Enum<?>)constant).name(), constant);
enumConstantDirectory = m;
}
return enumConstantDirectory;
@@ -3088,11 +3088,11 @@
getRawAnnotations(), getConstantPool(), this);
Class<?> superClass = getSuperclass();
if (superClass == null) {
annotations = declaredAnnotations;
} else {
- annotations = new HashMap<Class<? extends Annotation>, Annotation>();
+ annotations = new HashMap<>();
superClass.initAnnotationsIfNecessary();
for (Map.Entry<Class<? extends Annotation>, Annotation> e : superClass.annotations.entrySet()) {
Class<? extends Annotation> annotationClass = e.getKey();
if (AnnotationType.getInstance(annotationClass).isInherited())
annotations.put(annotationClass, e.getValue());