Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f6a3346

Browse files
committed
Polishing
1 parent 247d2e3 commit f6a3346

File tree

7 files changed

+36
-12
lines changed

7 files changed

+36
-12
lines changed

spring-core/src/main/java/org/springframework/core/type/classreading/MetadataReaderFactoryDelegate.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,5 @@ static MetadataReaderFactory create(@Nullable ResourceLoader resourceLoader) {
3737
static MetadataReaderFactory create(@Nullable ClassLoader classLoader) {
3838
return new SimpleMetadataReaderFactory(classLoader);
3939
}
40+
4041
}

spring-core/src/main/java24/org/springframework/core/type/classreading/ClassFileAnnotationMetadata.java

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
package org.springframework.core.type.classreading;
1818

19-
2019
import java.lang.classfile.Annotation;
2120
import java.lang.classfile.AnnotationElement;
2221
import java.lang.classfile.AnnotationValue;
@@ -42,11 +41,15 @@
4241
/**
4342
* Parse {@link RuntimeVisibleAnnotationsAttribute} into {@link MergedAnnotations}
4443
* instances.
44+
*
4545
* @author Brian Clozel
46+
* @since 7.0
4647
*/
4748
abstract class ClassFileAnnotationMetadata {
4849

49-
static MergedAnnotations createMergedAnnotations(String className, RuntimeVisibleAnnotationsAttribute annotationAttribute, @Nullable ClassLoader classLoader) {
50+
static MergedAnnotations createMergedAnnotations(
51+
String className, RuntimeVisibleAnnotationsAttribute annotationAttribute, @Nullable ClassLoader classLoader) {
52+
5053
Set<MergedAnnotation<?>> annotations = annotationAttribute.annotations()
5154
.stream()
5255
.map(ann -> createMergedAnnotation(className, ann, classLoader))
@@ -56,7 +59,9 @@ static MergedAnnotations createMergedAnnotations(String className, RuntimeVisibl
5659
}
5760

5861
@SuppressWarnings("unchecked")
59-
private static <A extends java.lang.annotation.Annotation> @Nullable MergedAnnotation<A> createMergedAnnotation(String className, Annotation annotation, @Nullable ClassLoader classLoader) {
62+
private static <A extends java.lang.annotation.Annotation> @Nullable MergedAnnotation<A> createMergedAnnotation(
63+
String className, Annotation annotation, @Nullable ClassLoader classLoader) {
64+
6065
String typeName = fromTypeDescriptor(annotation.className().stringValue());
6166
if (AnnotationFilter.PLAIN.matches(typeName)) {
6267
return null;
@@ -78,7 +83,9 @@ static MergedAnnotations createMergedAnnotations(String className, RuntimeVisibl
7883
}
7984
}
8085

81-
private static @Nullable Object readAnnotationValue(String className, AnnotationValue elementValue, @Nullable ClassLoader classLoader) {
86+
private static @Nullable Object readAnnotationValue(
87+
String className, AnnotationValue elementValue, @Nullable ClassLoader classLoader) {
88+
8289
switch (elementValue) {
8390
case AnnotationValue.OfConstant constantValue -> {
8491
return constantValue.resolvedValue();
@@ -168,7 +175,6 @@ private static Class<?> resolveArrayElementType(List<AnnotationValue> values, @N
168175

169176

170177
record Source(Annotation entryName) {
171-
172178
}
173179

174180
}

spring-core/src/main/java24/org/springframework/core/type/classreading/ClassFileClassMetadata.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@
4242
/**
4343
* {@link AnnotationMetadata} implementation that leverages
4444
* the {@link java.lang.classfile.ClassFile} API.
45+
*
4546
* @author Brian Clozel
47+
* @since 7.0
4648
*/
4749
class ClassFileClassMetadata implements AnnotationMetadata {
4850

@@ -66,9 +68,11 @@ class ClassFileClassMetadata implements AnnotationMetadata {
6668

6769
private @Nullable Set<String> annotationTypes;
6870

71+
6972
ClassFileClassMetadata(String className, AccessFlags accessFlags, @Nullable String enclosingClassName,
7073
@Nullable String superClassName, boolean independentInnerClass, Set<String> interfaceNames,
7174
Set<String> memberClassNames, Set<MethodMetadata> declaredMethods, MergedAnnotations mergedAnnotations) {
75+
7276
this.className = className;
7377
this.accessFlags = accessFlags;
7478
this.enclosingClassName = enclosingClassName;
@@ -80,6 +84,7 @@ class ClassFileClassMetadata implements AnnotationMetadata {
8084
this.mergedAnnotations = mergedAnnotations;
8185
}
8286

87+
8388
@Override
8489
public String getClassName() {
8590
return this.className;
@@ -215,6 +220,7 @@ static ClassFileClassMetadata of(ClassModel classModel, @Nullable ClassLoader cl
215220
return builder.build();
216221
}
217222

223+
218224
static class Builder {
219225

220226
private final ClassLoader clasLoader;
@@ -297,7 +303,6 @@ ClassFileClassMetadata build() {
297303
return new ClassFileClassMetadata(this.className, this.accessFlags, this.enclosingClassName, this.superClassName,
298304
independentInnerClass, this.interfaceNames, this.memberClassNames, this.declaredMethods, this.mergedAnnotations);
299305
}
300-
301306
}
302307

303308
}

spring-core/src/main/java24/org/springframework/core/type/classreading/ClassFileMetadataReader.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
* {@link MetadataReader} implementation based on the {@link ClassFile} API.
3232
*
3333
* @author Brian Clozel
34+
* @since 7.0
3435
*/
3536
final class ClassFileMetadataReader implements MetadataReader {
3637

@@ -51,6 +52,7 @@ private static ClassModel parseClassModel(Resource resource) throws IOException
5152
}
5253
}
5354

55+
5456
@Override
5557
public Resource getResource() {
5658
return this.resource;

spring-core/src/main/java24/org/springframework/core/type/classreading/ClassFileMetadataReaderFactory.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
*/
3333
public class ClassFileMetadataReaderFactory extends AbstractMetadataReaderFactory {
3434

35-
3635
/**
3736
* Create a new ClassFileMetadataReaderFactory for the default class loader.
3837
*/
@@ -57,8 +56,10 @@ public ClassFileMetadataReaderFactory(@Nullable ClassLoader classLoader) {
5756
super(classLoader);
5857
}
5958

59+
6060
@Override
6161
public MetadataReader getMetadataReader(Resource resource) throws IOException {
6262
return new ClassFileMetadataReader(resource, getResourceLoader().getClassLoader());
6363
}
64+
6465
}

spring-core/src/main/java24/org/springframework/core/type/classreading/ClassFileMethodMetadata.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@
3737
/**
3838
* {@link MethodMetadata} extracted from class bytecode using the
3939
* {@link java.lang.classfile.ClassFile} API.
40+
*
4041
* @author Brian Clozel
42+
* @since 7.0
4143
*/
4244
class ClassFileMethodMetadata implements MethodMetadata {
4345

@@ -54,7 +56,10 @@ class ClassFileMethodMetadata implements MethodMetadata {
5456

5557
private final MergedAnnotations annotations;
5658

57-
ClassFileMethodMetadata(String methodName, AccessFlags accessFlags, @Nullable String declaringClassName, String returnTypeName, Object source, MergedAnnotations annotations) {
59+
60+
ClassFileMethodMetadata(String methodName, AccessFlags accessFlags, @Nullable String declaringClassName,
61+
String returnTypeName, Object source, MergedAnnotations annotations) {
62+
5863
this.methodName = methodName;
5964
this.accessFlags = accessFlags;
6065
this.declaringClassName = declaringClassName;
@@ -63,6 +68,7 @@ class ClassFileMethodMetadata implements MethodMetadata {
6368
this.annotations = annotations;
6469
}
6570

71+
6672
@Override
6773
public String getMethodName() {
6874
return this.methodName;
@@ -131,6 +137,7 @@ public String toString() {
131137
return this.source.toString();
132138
}
133139

140+
134141
static ClassFileMethodMetadata of(MethodModel methodModel, ClassLoader classLoader) {
135142
String methodName = methodModel.methodName().stringValue();
136143
AccessFlags flags = methodModel.flags();
@@ -146,13 +153,13 @@ static ClassFileMethodMetadata of(MethodModel methodModel, ClassLoader classLoad
146153
return new ClassFileMethodMetadata(methodName, flags, declaringClassName, returnTypeName, source, annotations);
147154
}
148155

156+
149157
/**
150158
* {@link MergedAnnotation} source.
151-
*
152159
* @param declaringClassName the name of the declaring class
153-
* @param flags the access flags
154-
* @param methodName the name of the method
155-
* @param descriptor the bytecode descriptor for this method
160+
* @param flags the access flags
161+
* @param methodName the name of the method
162+
* @param descriptor the bytecode descriptor for this method
156163
*/
157164
record Source(@Nullable String declaringClassName, AccessFlags flags, String methodName, MethodTypeDesc descriptor) {
158165

spring-core/src/main/java24/org/springframework/core/type/classreading/MetadataReaderFactoryDelegate.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
* For JDK >= 24, the {@link ClassFileMetadataReaderFactory} is being used.
2626
*
2727
* @author Brian Clozel
28+
* @since 7.0
2829
* @see MetadataReaderFactory
2930
*/
3031
abstract class MetadataReaderFactoryDelegate {
@@ -36,4 +37,5 @@ static MetadataReaderFactory create(@Nullable ResourceLoader resourceLoader) {
3637
static MetadataReaderFactory create(@Nullable ClassLoader classLoader) {
3738
return new ClassFileMetadataReaderFactory(classLoader);
3839
}
40+
3941
}

0 commit comments

Comments
 (0)