From 56523d5014e6d102382219549c3a0924b459c9dc Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Sun, 5 Mar 2023 19:37:11 +0100 Subject: [PATCH] Polishing --- .../aop/framework/ReflectiveMethodInvocation.java | 2 +- .../main/java/org/springframework/aot/agent/HintType.java | 3 +-- .../aot/agent/InstrumentedBridgeMethods.java | 3 +-- .../org/springframework/aot/agent/RecordedInvocation.java | 8 ++++---- .../org/springframework/core/test/tools/ClassFile.java | 2 ++ .../org/springframework/core/test/tools/ClassFiles.java | 1 + .../tools/CompileWithForkedClassLoaderClassLoader.java | 1 + .../core/test/tools/DynamicClassLoader.java | 1 - .../org/springframework/core/test/tools/DynamicFile.java | 1 - .../core/test/tools/DynamicFileAssert.java | 1 + .../org/springframework/core/test/tools/DynamicFiles.java | 1 - .../core/test/tools/DynamicJavaFileManager.java | 1 + .../org/springframework/core/test/tools/ResourceFile.java | 1 - .../core/test/tools/ResourceFileAssert.java | 5 +---- .../org/springframework/core/test/tools/SourceFile.java | 3 +-- .../springframework/core/test/tools/SourceFileAssert.java | 3 +-- .../core/annotation/AnnotationAwareOrderComparator.java | 2 +- .../main/java/org/springframework/core/codec/Decoder.java | 2 +- .../core/convert/support/ObjectToOptionalConverter.java | 2 +- 19 files changed, 19 insertions(+), 24 deletions(-) diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/ReflectiveMethodInvocation.java b/spring-aop/src/main/java/org/springframework/aop/framework/ReflectiveMethodInvocation.java index 3640d0c3dd..cc29883d59 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/ReflectiveMethodInvocation.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/ReflectiveMethodInvocation.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-2023 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. diff --git a/spring-core-test/src/main/java/org/springframework/aot/agent/HintType.java b/spring-core-test/src/main/java/org/springframework/aot/agent/HintType.java index a1310f6abe..46ee4f6ed0 100644 --- a/spring-core-test/src/main/java/org/springframework/aot/agent/HintType.java +++ b/spring-core-test/src/main/java/org/springframework/aot/agent/HintType.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2023 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. @@ -16,7 +16,6 @@ package org.springframework.aot.agent; - import org.springframework.aot.hint.JavaSerializationHint; import org.springframework.aot.hint.JdkProxyHint; import org.springframework.aot.hint.ReflectionHints; diff --git a/spring-core-test/src/main/java/org/springframework/aot/agent/InstrumentedBridgeMethods.java b/spring-core-test/src/main/java/org/springframework/aot/agent/InstrumentedBridgeMethods.java index df2d880c6e..bf3deedb36 100644 --- a/spring-core-test/src/main/java/org/springframework/aot/agent/InstrumentedBridgeMethods.java +++ b/spring-core-test/src/main/java/org/springframework/aot/agent/InstrumentedBridgeMethods.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2023 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. @@ -33,7 +33,6 @@ import java.util.stream.Stream; import org.springframework.lang.Nullable; - /** * Instrumented version of JDK methods to be used by bytecode rewritten by the {@link RuntimeHintsAgent}. *

Methods implemented here follow a specific naming pattern "lowercase type name + bridged method name", diff --git a/spring-core-test/src/main/java/org/springframework/aot/agent/RecordedInvocation.java b/spring-core-test/src/main/java/org/springframework/aot/agent/RecordedInvocation.java index c80a82eac1..9f105b62a0 100644 --- a/spring-core-test/src/main/java/org/springframework/aot/agent/RecordedInvocation.java +++ b/spring-core-test/src/main/java/org/springframework/aot/agent/RecordedInvocation.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2023 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. @@ -176,13 +176,13 @@ public final class RecordedInvocation { @Override public String toString() { - if(isStatic()) { - return String.format("<%s> invocation of <%s> with arguments %s", + if (isStatic()) { + return "<%s> invocation of <%s> with arguments %s".formatted( getHintType().hintClassName(), getMethodReference(), getArguments()); } else { Class instanceType = (getInstance() instanceof Class) ? getInstance() : getInstance().getClass(); - return String.format("<%s> invocation of <%s> on type <%s> with arguments %s", + return "<%s> invocation of <%s> on type <%s> with arguments %s".formatted( getHintType().hintClassName(), getMethodReference(), instanceType.getCanonicalName(), getArguments()); } } diff --git a/spring-core-test/src/main/java/org/springframework/core/test/tools/ClassFile.java b/spring-core-test/src/main/java/org/springframework/core/test/tools/ClassFile.java index 67fd32a6ca..029ab2b228 100644 --- a/spring-core-test/src/main/java/org/springframework/core/test/tools/ClassFile.java +++ b/spring-core-test/src/main/java/org/springframework/core/test/tools/ClassFile.java @@ -36,11 +36,13 @@ public final class ClassFile { private final byte[] content; + private ClassFile(String name, byte[] content) { this.name = name; this.content = content; } + /** * Return the fully qualified name of the class. * @return the class name diff --git a/spring-core-test/src/main/java/org/springframework/core/test/tools/ClassFiles.java b/spring-core-test/src/main/java/org/springframework/core/test/tools/ClassFiles.java index 28f1bd6538..e4fc0c82ad 100644 --- a/spring-core-test/src/main/java/org/springframework/core/test/tools/ClassFiles.java +++ b/spring-core-test/src/main/java/org/springframework/core/test/tools/ClassFiles.java @@ -35,6 +35,7 @@ public final class ClassFiles implements Iterable { private static final ClassFiles NONE = new ClassFiles(Collections.emptyMap()); + private final Map files; private ClassFiles(Map files) { diff --git a/spring-core-test/src/main/java/org/springframework/core/test/tools/CompileWithForkedClassLoaderClassLoader.java b/spring-core-test/src/main/java/org/springframework/core/test/tools/CompileWithForkedClassLoaderClassLoader.java index 3ff0513a8c..4551533d3e 100644 --- a/spring-core-test/src/main/java/org/springframework/core/test/tools/CompileWithForkedClassLoaderClassLoader.java +++ b/spring-core-test/src/main/java/org/springframework/core/test/tools/CompileWithForkedClassLoaderClassLoader.java @@ -45,6 +45,7 @@ final class CompileWithForkedClassLoaderClassLoader extends ClassLoader { this.testClassLoader = testClassLoader; } + // Invoked reflectively by DynamicClassLoader @SuppressWarnings("unused") void setClassResourceLookup(Function classResourceLookup) { diff --git a/spring-core-test/src/main/java/org/springframework/core/test/tools/DynamicClassLoader.java b/spring-core-test/src/main/java/org/springframework/core/test/tools/DynamicClassLoader.java index 6412cd0b06..a5fccba28a 100644 --- a/spring-core-test/src/main/java/org/springframework/core/test/tools/DynamicClassLoader.java +++ b/spring-core-test/src/main/java/org/springframework/core/test/tools/DynamicClassLoader.java @@ -93,7 +93,6 @@ public class DynamicClassLoader extends ClassLoader { } - private Class defineClass(String name, byte[] bytes) { if (this.defineClassMethod != null) { return (Class) ReflectionUtils.invokeMethod(this.defineClassMethod, diff --git a/spring-core-test/src/main/java/org/springframework/core/test/tools/DynamicFile.java b/spring-core-test/src/main/java/org/springframework/core/test/tools/DynamicFile.java index c64a1e1675..f35765a8dd 100644 --- a/spring-core-test/src/main/java/org/springframework/core/test/tools/DynamicFile.java +++ b/spring-core-test/src/main/java/org/springframework/core/test/tools/DynamicFile.java @@ -32,7 +32,6 @@ import org.springframework.util.Assert; */ public abstract sealed class DynamicFile permits SourceFile, ResourceFile { - private final String path; private final String content; diff --git a/spring-core-test/src/main/java/org/springframework/core/test/tools/DynamicFileAssert.java b/spring-core-test/src/main/java/org/springframework/core/test/tools/DynamicFileAssert.java index a9d26207cf..5c8cddc233 100644 --- a/spring-core-test/src/main/java/org/springframework/core/test/tools/DynamicFileAssert.java +++ b/spring-core-test/src/main/java/org/springframework/core/test/tools/DynamicFileAssert.java @@ -39,6 +39,7 @@ public class DynamicFileAssert, F extends Dyna super(actual, selfType); } + /** * Verify that the actual content is equal to the given one. * @param content the expected content of the file diff --git a/spring-core-test/src/main/java/org/springframework/core/test/tools/DynamicFiles.java b/spring-core-test/src/main/java/org/springframework/core/test/tools/DynamicFiles.java index 01359ec16c..93f19710a5 100644 --- a/spring-core-test/src/main/java/org/springframework/core/test/tools/DynamicFiles.java +++ b/spring-core-test/src/main/java/org/springframework/core/test/tools/DynamicFiles.java @@ -37,7 +37,6 @@ import org.springframework.lang.Nullable; */ final class DynamicFiles implements Iterable { - private static final DynamicFiles NONE = new DynamicFiles<>(Collections.emptyMap()); diff --git a/spring-core-test/src/main/java/org/springframework/core/test/tools/DynamicJavaFileManager.java b/spring-core-test/src/main/java/org/springframework/core/test/tools/DynamicJavaFileManager.java index e5780b4c70..f385401529 100644 --- a/spring-core-test/src/main/java/org/springframework/core/test/tools/DynamicJavaFileManager.java +++ b/spring-core-test/src/main/java/org/springframework/core/test/tools/DynamicJavaFileManager.java @@ -63,6 +63,7 @@ class DynamicJavaFileManager extends ForwardingJavaFileManager this.classLoader = classLoader; } + @Override public ClassLoader getClassLoader(Location location) { return this.classLoader; diff --git a/spring-core-test/src/main/java/org/springframework/core/test/tools/ResourceFile.java b/spring-core-test/src/main/java/org/springframework/core/test/tools/ResourceFile.java index 954587a257..27935e620b 100644 --- a/spring-core-test/src/main/java/org/springframework/core/test/tools/ResourceFile.java +++ b/spring-core-test/src/main/java/org/springframework/core/test/tools/ResourceFile.java @@ -33,7 +33,6 @@ import org.springframework.util.FileCopyUtils; */ public final class ResourceFile extends DynamicFile implements AssertProvider { - private ResourceFile(String path, String content) { super(path, content); } diff --git a/spring-core-test/src/main/java/org/springframework/core/test/tools/ResourceFileAssert.java b/spring-core-test/src/main/java/org/springframework/core/test/tools/ResourceFileAssert.java index 305a566c51..f786293ff8 100644 --- a/spring-core-test/src/main/java/org/springframework/core/test/tools/ResourceFileAssert.java +++ b/spring-core-test/src/main/java/org/springframework/core/test/tools/ResourceFileAssert.java @@ -22,13 +22,10 @@ package org.springframework.core.test.tools; * @author Phillip Webb * @since 6.0 */ -public class ResourceFileAssert - extends DynamicFileAssert { - +public class ResourceFileAssert extends DynamicFileAssert { ResourceFileAssert(ResourceFile actual) { super(actual, ResourceFileAssert.class); } - } diff --git a/spring-core-test/src/main/java/org/springframework/core/test/tools/SourceFile.java b/spring-core-test/src/main/java/org/springframework/core/test/tools/SourceFile.java index bf0ae02076..72f875f5bb 100644 --- a/spring-core-test/src/main/java/org/springframework/core/test/tools/SourceFile.java +++ b/spring-core-test/src/main/java/org/springframework/core/test/tools/SourceFile.java @@ -61,6 +61,7 @@ public final class SourceFile extends DynamicFile implements AssertProvider { - SourceFileAssert(SourceFile actual) { super(actual, SourceFileAssert.class); } diff --git a/spring-core/src/main/java/org/springframework/core/annotation/AnnotationAwareOrderComparator.java b/spring-core/src/main/java/org/springframework/core/annotation/AnnotationAwareOrderComparator.java index 75c9c1b5ec..1cddc59306 100644 --- a/spring-core/src/main/java/org/springframework/core/annotation/AnnotationAwareOrderComparator.java +++ b/spring-core/src/main/java/org/springframework/core/annotation/AnnotationAwareOrderComparator.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2023 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. diff --git a/spring-core/src/main/java/org/springframework/core/codec/Decoder.java b/spring-core/src/main/java/org/springframework/core/codec/Decoder.java index 2599ce940a..d37244b764 100644 --- a/spring-core/src/main/java/org/springframework/core/codec/Decoder.java +++ b/spring-core/src/main/java/org/springframework/core/codec/Decoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-2023 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. diff --git a/spring-core/src/main/java/org/springframework/core/convert/support/ObjectToOptionalConverter.java b/spring-core/src/main/java/org/springframework/core/convert/support/ObjectToOptionalConverter.java index 4d12b15e56..589c6a59c9 100644 --- a/spring-core/src/main/java/org/springframework/core/convert/support/ObjectToOptionalConverter.java +++ b/spring-core/src/main/java/org/springframework/core/convert/support/ObjectToOptionalConverter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2023 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.