Skip to content

Commit 16eff68

Browse files
committed
Fix package tangle between o.s.core and o.s.aot
Closes gh-28496
1 parent 875ee54 commit 16eff68

File tree

6 files changed

+30
-11
lines changed

6 files changed

+30
-11
lines changed
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,14 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.core.annotation;
17+
package org.springframework.aot.hint.support;
1818

1919
import java.util.stream.Stream;
2020

2121
import org.springframework.aot.hint.RuntimeHints;
2222
import org.springframework.aot.hint.RuntimeHintsRegistrar;
23-
import org.springframework.aot.hint.support.RuntimeHintsUtils;
23+
import org.springframework.core.annotation.AliasFor;
24+
import org.springframework.core.annotation.Order;
2425
import org.springframework.lang.Nullable;
2526

2627
/**
Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.core.io.support;
17+
package org.springframework.aot.hint.support;
1818

1919
import java.util.List;
2020
import java.util.Map;
@@ -27,6 +27,7 @@
2727
import org.springframework.aot.hint.RuntimeHints;
2828
import org.springframework.aot.hint.RuntimeHintsRegistrar;
2929
import org.springframework.aot.hint.TypeHint;
30+
import org.springframework.core.io.support.SpringFactoriesLoader;
3031
import org.springframework.core.log.LogMessage;
3132
import org.springframework.lang.Nullable;
3233
import org.springframework.util.ClassUtils;
@@ -41,13 +42,13 @@
4142
*/
4243
class SpringFactoriesLoaderRuntimeHintsRegistrar implements RuntimeHintsRegistrar {
4344

44-
private static List<String> RESOURCE_LOCATIONS =
45+
private static final List<String> RESOURCE_LOCATIONS =
4546
List.of(SpringFactoriesLoader.FACTORIES_RESOURCE_LOCATION);
4647

4748
private static final Consumer<TypeHint.Builder> HINT = builder ->
4849
builder.withMembers(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS);
4950

50-
private final Log logger = LogFactory.getLog(SpringFactoriesLoaderRuntimeHintsRegistrar.class);
51+
private static final Log logger = LogFactory.getLog(SpringFactoriesLoaderRuntimeHintsRegistrar.class);
5152

5253

5354
@Override
@@ -60,7 +61,7 @@ public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
6061
private void registerHints(RuntimeHints hints, ClassLoader classLoader, String resourceLocation) {
6162
hints.resources().registerPattern(resourceLocation);
6263
Map<String, List<String>> factories =
63-
SpringFactoriesLoader.loadFactoriesResource(classLoader, resourceLocation);
64+
ExtendedSpringFactoriesLoader.accessLoadFactoriesResource(classLoader, resourceLocation);
6465
factories.forEach((factoryClassName, implementationClassNames) ->
6566
registerHints(hints, classLoader, factoryClassName, implementationClassNames));
6667
}
@@ -104,4 +105,16 @@ private Class<?> resolveClassName(ClassLoader classLoader, String factoryClassNa
104105
}
105106
}
106107

108+
private static class ExtendedSpringFactoriesLoader extends SpringFactoriesLoader {
109+
110+
public ExtendedSpringFactoriesLoader(@Nullable ClassLoader classLoader, Map<String, List<String>> factories) {
111+
super(classLoader, factories);
112+
}
113+
114+
static Map<String, List<String>> accessLoadFactoriesResource(ClassLoader classLoader, String resourceLocation) {
115+
return SpringFactoriesLoader.loadFactoriesResource(classLoader, resourceLocation);
116+
}
117+
118+
}
119+
107120
}

spring-core/src/main/java/org/springframework/core/io/support/SpringFactoriesLoader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ public static SpringFactoriesLoader forResourceLocation(@Nullable ClassLoader cl
327327
new SpringFactoriesLoader(classLoader, loadFactoriesResource(resourceClassLoader, resourceLocation)));
328328
}
329329

330-
static Map<String, List<String>> loadFactoriesResource(ClassLoader classLoader, String resourceLocation) {
330+
protected static Map<String, List<String>> loadFactoriesResource(ClassLoader classLoader, String resourceLocation) {
331331
Map<String, List<String>> result = new LinkedHashMap<>();
332332
try {
333333
Enumeration<URL> urls = classLoader.getResources(resourceLocation);
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
org.springframework.aot.hint.RuntimeHintsRegistrar=\
2-
org.springframework.core.annotation.CoreAnnotationsRuntimeHintsRegistrar,\
3-
org.springframework.core.io.support.SpringFactoriesLoaderRuntimeHintsRegistrar
2+
org.springframework.aot.hint.support.CoreAnnotationsRuntimeHintsRegistrar,\
3+
org.springframework.aot.hint.support.SpringFactoriesLoaderRuntimeHintsRegistrar
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.core.annotation;
17+
package org.springframework.aot.hint.support;
1818

1919
import org.junit.jupiter.api.BeforeEach;
2020
import org.junit.jupiter.api.Test;
@@ -23,6 +23,8 @@
2323
import org.springframework.aot.hint.RuntimeHints;
2424
import org.springframework.aot.hint.RuntimeHintsRegistrar;
2525
import org.springframework.aot.hint.TypeReference;
26+
import org.springframework.core.annotation.AliasFor;
27+
import org.springframework.core.annotation.Order;
2628
import org.springframework.core.io.support.SpringFactoriesLoader;
2729
import org.springframework.util.ClassUtils;
2830

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.core.io.support;
17+
package org.springframework.aot.hint.support;
1818

1919
import org.junit.jupiter.api.BeforeEach;
2020
import org.junit.jupiter.api.Test;
@@ -25,6 +25,9 @@
2525
import org.springframework.aot.hint.RuntimeHintsRegistrar;
2626
import org.springframework.aot.hint.TypeHint;
2727
import org.springframework.aot.hint.TypeReference;
28+
import org.springframework.core.io.support.DummyFactory;
29+
import org.springframework.core.io.support.MyDummyFactory1;
30+
import org.springframework.core.io.support.SpringFactoriesLoader;
2831
import org.springframework.util.ClassUtils;
2932

3033
import static org.assertj.core.api.Assertions.assertThat;

0 commit comments

Comments
 (0)