From 4208ec0ba8c8f182b2262c35b1681150eebd5114 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Wed, 25 Oct 2017 19:23:48 +0200 Subject: [PATCH] Polishing (cherry picked from commit 7e8c8f0) --- .../core/type/ClassMetadata.java | 19 +++++++++---------- .../core/type/StandardClassMetadata.java | 7 ++++--- .../ClassMetadataReadingVisitor.java | 7 ++++--- 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/spring-core/src/main/java/org/springframework/core/type/ClassMetadata.java b/spring-core/src/main/java/org/springframework/core/type/ClassMetadata.java index d664198e7df..9756e65fd02 100644 --- a/spring-core/src/main/java/org/springframework/core/type/ClassMetadata.java +++ b/spring-core/src/main/java/org/springframework/core/type/ClassMetadata.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -61,19 +61,18 @@ public interface ClassMetadata { boolean isFinal(); /** - * Determine whether the underlying class is independent, - * i.e. whether it is a top-level class or a nested class - * (static inner class) that can be constructed independent - * from an enclosing class. + * Determine whether the underlying class is independent, i.e. whether + * it is a top-level class or a nested class (static inner class) that + * can be constructed independently from an enclosing class. */ boolean isIndependent(); /** - * Return whether the underlying class has an enclosing class - * (i.e. the underlying class is an inner/nested class or - * a local class within a method). - *

If this method returns {@code false}, then the - * underlying class is a top-level class. + * Return whether the underlying class is declared within an enclosing + * class (i.e. the underlying class is an inner/nested class or a + * local class within a method). + *

If this method returns {@code false}, then the underlying + * class is a top-level class. */ boolean hasEnclosingClass(); diff --git a/spring-core/src/main/java/org/springframework/core/type/StandardClassMetadata.java b/spring-core/src/main/java/org/springframework/core/type/StandardClassMetadata.java index 935184b0c52..bbf573b672f 100644 --- a/spring-core/src/main/java/org/springframework/core/type/StandardClassMetadata.java +++ b/spring-core/src/main/java/org/springframework/core/type/StandardClassMetadata.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +20,7 @@ import java.lang.reflect.Modifier; import java.util.LinkedHashSet; import org.springframework.util.Assert; +import org.springframework.util.StringUtils; /** * {@link ClassMetadata} implementation that uses standard reflection @@ -121,11 +122,11 @@ public class StandardClassMetadata implements ClassMetadata { @Override public String[] getMemberClassNames() { - LinkedHashSet memberClassNames = new LinkedHashSet(); + LinkedHashSet memberClassNames = new LinkedHashSet(4); for (Class nestedClass : this.introspectedClass.getDeclaredClasses()) { memberClassNames.add(nestedClass.getName()); } - return memberClassNames.toArray(new String[memberClassNames.size()]); + return StringUtils.toStringArray(memberClassNames); } } diff --git a/spring-core/src/main/java/org/springframework/core/type/classreading/ClassMetadataReadingVisitor.java b/spring-core/src/main/java/org/springframework/core/type/classreading/ClassMetadataReadingVisitor.java index 83a62aeebed..74f2b09050f 100644 --- a/spring-core/src/main/java/org/springframework/core/type/classreading/ClassMetadataReadingVisitor.java +++ b/spring-core/src/main/java/org/springframework/core/type/classreading/ClassMetadataReadingVisitor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,6 +28,7 @@ import org.springframework.asm.Opcodes; import org.springframework.asm.SpringAsmInfo; import org.springframework.core.type.ClassMetadata; import org.springframework.util.ClassUtils; +import org.springframework.util.StringUtils; /** * ASM class visitor which looks only for the class name and implemented types, @@ -61,7 +62,7 @@ class ClassMetadataReadingVisitor extends ClassVisitor implements ClassMetadata private String[] interfaces; - private Set memberClassNames = new LinkedHashSet(); + private Set memberClassNames = new LinkedHashSet(4); public ClassMetadataReadingVisitor() { @@ -201,7 +202,7 @@ class ClassMetadataReadingVisitor extends ClassVisitor implements ClassMetadata @Override public String[] getMemberClassNames() { - return this.memberClassNames.toArray(new String[this.memberClassNames.size()]); + return StringUtils.toStringArray(this.memberClassNames); }