Skip to content

Commit 949432c

Browse files
committed
General upgrade to Jakarta EE 11 APIs
Includes removal of ManagedBean and javax.annotation legacy support. Includes AbstractJson(Http)MessageConverter revision for Yasson 3.0. Includes initial Hibernate ORM 7.0 upgrade. Closes gh-34011 Closes gh-33750
1 parent 15c6d34 commit 949432c

File tree

65 files changed

+200
-2995
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+200
-2995
lines changed

framework-docs/modules/ROOT/pages/core/beans/classpath-scanning.adoc

+1-3
Original file line numberDiff line numberDiff line change
@@ -674,9 +674,7 @@ By default, the `AnnotationBeanNameGenerator` is used. For Spring
674674
xref:core/beans/classpath-scanning.adoc#beans-stereotype-annotations[stereotype annotations],
675675
if you supply a name via the annotation's `value` attribute that name will be used as
676676
the name in the corresponding bean definition. This convention also applies when the
677-
following JSR-250 and JSR-330 annotations are used instead of Spring stereotype
678-
annotations: `@jakarta.annotation.ManagedBean`, `@javax.annotation.ManagedBean`,
679-
`@jakarta.inject.Named`, and `@javax.inject.Named`.
677+
`@jakarta.inject.Named` annotation is used instead of Spring stereotype annotations.
680678

681679
As of Spring Framework 6.1, the name of the annotation attribute that is used to specify
682680
the bean name is no longer required to be `value`. Custom stereotype annotations can

framework-docs/modules/ROOT/pages/integration/email.adoc

+1-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ Spring Framework's email support:
1111
* The https://jakartaee.github.io/mail-api/[Jakarta Mail] library
1212
1313
This library is freely available on the web -- for example, in Maven Central as
14-
`com.sun.mail:jakarta.mail`. Please make sure to use the latest 2.x version (which uses
15-
the `jakarta.mail` package namespace) rather than Jakarta Mail 1.6.x (which uses the
16-
`javax.mail` package namespace).
14+
`org.eclipse.angus:angus-mail`.
1715
****
1816

1917
The Spring Framework provides a helpful utility library for sending email that shields

framework-docs/modules/ROOT/pages/testing/annotations/integration-junit-jupiter.adoc

+3-3
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,9 @@ the parameters of a test class constructor are autowired from components in the
171171

172172
If `@TestConstructor` is not present or meta-present on a test class, the default _test
173173
constructor autowire mode_ will be used. See the tip below for details on how to change
174-
the default mode. Note, however, that a local declaration of `@Autowired`,
175-
`@jakarta.inject.Inject`, or `@javax.inject.Inject` on a constructor takes precedence
176-
over both `@TestConstructor` and the default mode.
174+
the default mode. Note, however, that a local declaration of `@Autowired` or
175+
`@jakarta.inject.Inject` on a constructor takes precedence over both `@TestConstructor`
176+
and the default mode.
177177

178178
.Changing the default test constructor autowire mode
179179
[TIP]

framework-platform/framework-platform.gradle

+18-20
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ dependencies {
4040
api("com.squareup.okhttp3:mockwebserver:3.14.9")
4141
api("com.squareup.okhttp3:okhttp:3.14.9")
4242
api("com.sun.activation:jakarta.activation:2.0.1")
43-
api("com.sun.mail:jakarta.mail:2.0.1")
4443
api("com.sun.xml.bind:jaxb-core:3.0.2")
4544
api("com.sun.xml.bind:jaxb-impl:3.0.2")
4645
api("com.sun.xml.bind:jaxb-xjc:3.0.2")
@@ -61,32 +60,30 @@ dependencies {
6160
api("io.undertow:undertow-servlet:2.3.18.Final")
6261
api("io.undertow:undertow-websockets-jsr:2.3.18.Final")
6362
api("io.vavr:vavr:0.10.4")
64-
api("jakarta.activation:jakarta.activation-api:2.0.1")
65-
api("jakarta.annotation:jakarta.annotation-api:2.0.0")
63+
api("jakarta.activation:jakarta.activation-api:2.1.3")
64+
api("jakarta.annotation:jakarta.annotation-api:3.0.0")
6665
api("jakarta.ejb:jakarta.ejb-api:4.0.1")
67-
api("jakarta.el:jakarta.el-api:4.0.0")
68-
api("jakarta.enterprise.concurrent:jakarta.enterprise.concurrent-api:2.0.0")
69-
api("jakarta.faces:jakarta.faces-api:3.0.0")
66+
api("jakarta.el:jakarta.el-api:6.0.1")
67+
api("jakarta.enterprise.concurrent:jakarta.enterprise.concurrent-api:3.1.1")
68+
api("jakarta.faces:jakarta.faces-api:4.1.2")
7069
api("jakarta.inject:jakarta.inject-api:2.0.1")
7170
api("jakarta.inject:jakarta.inject-tck:2.0.1")
72-
api("jakarta.interceptor:jakarta.interceptor-api:2.0.0")
73-
api("jakarta.jms:jakarta.jms-api:3.0.0")
74-
api("jakarta.json.bind:jakarta.json.bind-api:2.0.0")
75-
api("jakarta.json:jakarta.json-api:2.0.1")
76-
api("jakarta.mail:jakarta.mail-api:2.0.1")
77-
api("jakarta.persistence:jakarta.persistence-api:3.0.0")
78-
api("jakarta.resource:jakarta.resource-api:2.0.0")
71+
api("jakarta.interceptor:jakarta.interceptor-api:2.2.0")
72+
api("jakarta.jms:jakarta.jms-api:3.1.0")
73+
api("jakarta.json.bind:jakarta.json.bind-api:3.0.1")
74+
api("jakarta.json:jakarta.json-api:2.1.3")
75+
api("jakarta.mail:jakarta.mail-api:2.1.3")
76+
api("jakarta.persistence:jakarta.persistence-api:3.2.0")
77+
api("jakarta.resource:jakarta.resource-api:2.1.0")
7978
api("jakarta.servlet.jsp.jstl:jakarta.servlet.jsp.jstl-api:3.0.2")
8079
api("jakarta.servlet.jsp:jakarta.servlet.jsp-api:4.0.0")
8180
api("jakarta.servlet:jakarta.servlet-api:6.1.0")
8281
api("jakarta.transaction:jakarta.transaction-api:2.0.1")
83-
api("jakarta.validation:jakarta.validation-api:3.0.2")
82+
api("jakarta.validation:jakarta.validation-api:3.1.0")
8483
api("jakarta.websocket:jakarta.websocket-api:2.2.0")
8584
api("jakarta.websocket:jakarta.websocket-client-api:2.2.0")
8685
api("jakarta.xml.bind:jakarta.xml.bind-api:3.0.1")
87-
api("javax.annotation:javax.annotation-api:1.3.2")
8886
api("javax.cache:cache-api:1.1.1")
89-
api("javax.inject:javax.inject:1")
9087
api("javax.money:money-api:1.1")
9188
api("jaxen:jaxen:1.2.0")
9289
api("junit:junit:4.13.2")
@@ -117,9 +114,10 @@ dependencies {
117114
api("org.crac:crac:1.4.0")
118115
api("org.dom4j:dom4j:2.1.4")
119116
api("org.easymock:easymock:5.4.0")
117+
api("org.eclipse.angus:angus-mail:2.0.3")
120118
api("org.eclipse.jetty:jetty-reactive-httpclient:4.0.8")
121-
api("org.eclipse.persistence:org.eclipse.persistence.jpa:3.0.4")
122-
api("org.eclipse:yasson:2.0.4")
119+
api("org.eclipse.persistence:org.eclipse.persistence.jpa:5.0.0-B04")
120+
api("org.eclipse:yasson:3.0.4")
123121
api("org.ehcache:ehcache:3.10.8")
124122
api("org.ehcache:jcache:1.0.1")
125123
api("org.freemarker:freemarker:2.3.33")
@@ -128,8 +126,8 @@ dependencies {
128126
api("org.glassfish.tyrus:tyrus-container-servlet:2.1.3")
129127
api("org.graalvm.sdk:graal-sdk:22.3.1")
130128
api("org.hamcrest:hamcrest:2.2")
131-
api("org.hibernate:hibernate-core-jakarta:5.6.15.Final")
132-
api("org.hibernate:hibernate-validator:7.0.5.Final")
129+
api("org.hibernate:hibernate-core:7.0.0.Beta2")
130+
api("org.hibernate:hibernate-validator:9.0.0.Beta3")
133131
api("org.hsqldb:hsqldb:2.7.4")
134132
api("org.htmlunit:htmlunit:4.6.0")
135133
api("org.javamoney:moneta:1.4.4")

integration-tests/integration-tests.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ dependencies {
2626
testImplementation("jakarta.servlet:jakarta.servlet-api")
2727
testImplementation("org.aspectj:aspectjweaver")
2828
testImplementation("org.hsqldb:hsqldb")
29-
testImplementation("org.hibernate:hibernate-core-jakarta")
29+
testImplementation("org.hibernate:hibernate-core")
3030
testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-reactor")
3131
}
3232

spring-beans/spring-beans.gradle

-1
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,4 @@ dependencies {
1616
testImplementation(project(":spring-core-test"))
1717
testImplementation(testFixtures(project(":spring-core")))
1818
testImplementation("jakarta.annotation:jakarta.annotation-api")
19-
testImplementation("javax.inject:javax.inject")
2019
}

spring-beans/src/main/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.java

+2-13
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,6 @@
103103
*
104104
* <p>Also supports the common {@link jakarta.inject.Inject @Inject} annotation,
105105
* if available, as a direct alternative to Spring's own {@code @Autowired}.
106-
* Additionally, it retains support for the {@code javax.inject.Inject} variant
107-
* dating back to the original JSR-330 specification (as known from Java EE 6-8).
108106
*
109107
* <h3>Autowired Constructors</h3>
110108
* <p>Only one constructor of any given bean class may declare this annotation with
@@ -189,8 +187,8 @@ public class AutowiredAnnotationBeanPostProcessor implements SmartInstantiationA
189187
/**
190188
* Create a new {@code AutowiredAnnotationBeanPostProcessor} for Spring's
191189
* standard {@link Autowired @Autowired} and {@link Value @Value} annotations.
192-
* <p>Also supports the common {@link jakarta.inject.Inject @Inject} annotation,
193-
* if available, as well as the original {@code javax.inject.Inject} variant.
190+
* <p>Also supports the common {@link jakarta.inject.Inject @Inject} annotation
191+
* if available.
194192
*/
195193
@SuppressWarnings("unchecked")
196194
public AutowiredAnnotationBeanPostProcessor() {
@@ -206,15 +204,6 @@ public AutowiredAnnotationBeanPostProcessor() {
206204
catch (ClassNotFoundException ex) {
207205
// jakarta.inject API not available - simply skip.
208206
}
209-
210-
try {
211-
this.autowiredAnnotationTypes.add((Class<? extends Annotation>)
212-
ClassUtils.forName("javax.inject.Inject", classLoader));
213-
logger.trace("'javax.inject.Inject' annotation found and supported for autowiring");
214-
}
215-
catch (ClassNotFoundException ex) {
216-
// javax.inject API not available - simply skip.
217-
}
218207
}
219208

220209

spring-beans/src/main/java/org/springframework/beans/factory/annotation/JakartaAnnotationsRuntimeHints.java

+1-5
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,10 @@ class JakartaAnnotationsRuntimeHints implements RuntimeHintsRegistrar {
3333

3434
@Override
3535
public void registerHints(RuntimeHints hints, @Nullable ClassLoader classLoader) {
36-
// javax.inject.Provider is omitted from the list, since we do not currently load
37-
// it via reflection.
3836
Stream.of(
3937
"jakarta.inject.Inject",
4038
"jakarta.inject.Provider",
41-
"jakarta.inject.Qualifier",
42-
"javax.inject.Inject",
43-
"javax.inject.Qualifier"
39+
"jakarta.inject.Qualifier"
4440
).forEach(typeName -> hints.reflection().registerType(TypeReference.of(typeName)));
4541
}
4642

spring-beans/src/main/java/org/springframework/beans/factory/annotation/QualifierAnnotationAutowireCandidateResolver.java

+2-11
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@
4747
* against {@link Qualifier qualifier annotations} on the field or parameter to be autowired.
4848
* Also supports suggested expression values through a {@link Value value} annotation.
4949
*
50-
* <p>Also supports JSR-330's {@link jakarta.inject.Qualifier} annotation (as well as its
51-
* pre-Jakarta {@code javax.inject.Qualifier} equivalent), if available.
50+
* <p>Also supports JSR-330's {@link jakarta.inject.Qualifier} annotation if available.
5251
*
5352
* @author Mark Fisher
5453
* @author Juergen Hoeller
@@ -69,8 +68,7 @@ public class QualifierAnnotationAutowireCandidateResolver extends GenericTypeAwa
6968
/**
7069
* Create a new {@code QualifierAnnotationAutowireCandidateResolver} for Spring's
7170
* standard {@link Qualifier} annotation.
72-
* <p>Also supports JSR-330's {@link jakarta.inject.Qualifier} annotation (as well as
73-
* its pre-Jakarta {@code javax.inject.Qualifier} equivalent), if available.
71+
* <p>Also supports JSR-330's {@link jakarta.inject.Qualifier} annotation if available.
7472
*/
7573
@SuppressWarnings("unchecked")
7674
public QualifierAnnotationAutowireCandidateResolver() {
@@ -82,13 +80,6 @@ public QualifierAnnotationAutowireCandidateResolver() {
8280
catch (ClassNotFoundException ex) {
8381
// JSR-330 API (as included in Jakarta EE) not available - simply skip.
8482
}
85-
try {
86-
this.qualifierTypes.add((Class<? extends Annotation>) ClassUtils.forName("javax.inject.Qualifier",
87-
QualifierAnnotationAutowireCandidateResolver.class.getClassLoader()));
88-
}
89-
catch (ClassNotFoundException ex) {
90-
// JSR-330 API not available - simply skip.
91-
}
9283
}
9384

9485
/**

spring-beans/src/main/java/org/springframework/beans/factory/support/RootBeanDefinition.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -508,8 +508,8 @@ public Set<Member> getExternallyManagedConfigMembers() {
508508

509509
/**
510510
* Register an externally managed configuration initialization method &mdash;
511-
* for example, a method annotated with JSR-250's {@code javax.annotation.PostConstruct}
512-
* or Jakarta's {@link jakarta.annotation.PostConstruct} annotation.
511+
* for example, a method annotated with Jakarta's
512+
* {@link jakarta.annotation.PostConstruct} annotation.
513513
* <p>The supplied {@code initMethod} may be a
514514
* {@linkplain Method#getName() simple method name} or a
515515
* {@linkplain org.springframework.util.ClassUtils#getQualifiedMethodName(Method)

spring-beans/src/test/java/org/springframework/beans/factory/annotation/JakartaAnnotationsRuntimeHintsTests.java

-10
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,4 @@ void jakartaQualifierAnnotationHasHints() {
6363
assertThat(RuntimeHintsPredicates.reflection().onType(Qualifier.class)).accepts(this.hints);
6464
}
6565

66-
@Test // gh-33345
67-
void javaxInjectAnnotationHasHints() {
68-
assertThat(RuntimeHintsPredicates.reflection().onType(javax.inject.Inject.class)).accepts(this.hints);
69-
}
70-
71-
@Test // gh-33345
72-
void javaxQualifierAnnotationHasHints() {
73-
assertThat(RuntimeHintsPredicates.reflection().onType(javax.inject.Qualifier.class)).accepts(this.hints);
74-
}
75-
7666
}

spring-context-indexer/src/test/java/org/springframework/context/index/processor/CandidateComponentsIndexerTests.java

-7
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import java.io.IOException;
2222
import java.nio.file.Path;
2323

24-
import jakarta.annotation.ManagedBean;
2524
import jakarta.inject.Named;
2625
import jakarta.persistence.Converter;
2726
import jakarta.persistence.Embeddable;
@@ -43,7 +42,6 @@
4342
import org.springframework.context.index.sample.SampleNone;
4443
import org.springframework.context.index.sample.SampleRepository;
4544
import org.springframework.context.index.sample.SampleService;
46-
import org.springframework.context.index.sample.cdi.SampleManagedBean;
4745
import org.springframework.context.index.sample.cdi.SampleNamed;
4846
import org.springframework.context.index.sample.cdi.SampleTransactional;
4947
import org.springframework.context.index.sample.jpa.SampleConverter;
@@ -126,11 +124,6 @@ void stereotypeOnAbstractClass() {
126124
testComponent(AbstractController.class);
127125
}
128126

129-
@Test
130-
void cdiManagedBean() {
131-
testSingleComponent(SampleManagedBean.class, ManagedBean.class);
132-
}
133-
134127
@Test
135128
void cdiNamed() {
136129
testSingleComponent(SampleNamed.class, Named.class);

spring-context-indexer/src/test/java/org/springframework/context/index/sample/cdi/SampleManagedBean.java

-28
This file was deleted.

spring-context-support/spring-context-support.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ dependencies {
2323
testImplementation("io.projectreactor:reactor-core")
2424
testImplementation("jakarta.annotation:jakarta.annotation-api")
2525
testImplementation("org.hsqldb:hsqldb")
26-
testRuntimeOnly("com.sun.mail:jakarta.mail")
26+
testRuntimeOnly("org.eclipse.angus:angus-mail")
2727
testRuntimeOnly("org.ehcache:ehcache")
2828
testRuntimeOnly("org.ehcache:jcache")
2929
testRuntimeOnly("org.glassfish:jakarta.el")

spring-context/spring-context.gradle

-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ dependencies {
2121
optional("jakarta.inject:jakarta.inject-api")
2222
optional("jakarta.interceptor:jakarta.interceptor-api")
2323
optional("jakarta.validation:jakarta.validation-api")
24-
optional("javax.annotation:javax.annotation-api")
25-
optional("javax.inject:javax.inject")
2624
optional("javax.money:money-api")
2725
optional("org.apache.groovy:groovy")
2826
optional("org.apache-extras.beanshell:bsh")

spring-context/src/main/java/org/springframework/context/annotation/AnnotationBeanNameGenerator.java

+4-10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2023 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -51,11 +51,8 @@
5151
* {@link org.springframework.stereotype.Repository @Repository}) are
5252
* themselves annotated with {@code @Component}.
5353
*
54-
* <p>Also supports Jakarta EE's {@link jakarta.annotation.ManagedBean} and
55-
* JSR-330's {@link jakarta.inject.Named} annotations (as well as their pre-Jakarta
56-
* {@code javax.annotation.ManagedBean} and {@code javax.inject.Named} equivalents),
57-
* if available. Note that Spring component annotations always override such
58-
* standard annotations.
54+
* <p>Also supports JSR-330's {@link jakarta.inject.Named} annotation if available.
55+
* Note that Spring component annotations always override such standard annotations.
5956
*
6057
* <p>If the annotation's value doesn't indicate a bean name, an appropriate
6158
* name will be built based on the short name of the class (with the first
@@ -219,10 +216,7 @@ protected boolean isStereotypeWithNameValue(String annotationType,
219216
Set<String> metaAnnotationTypes, Map<String, Object> attributes) {
220217

221218
boolean isStereotype = metaAnnotationTypes.contains(COMPONENT_ANNOTATION_CLASSNAME) ||
222-
annotationType.equals("jakarta.annotation.ManagedBean") ||
223-
annotationType.equals("javax.annotation.ManagedBean") ||
224-
annotationType.equals("jakarta.inject.Named") ||
225-
annotationType.equals("javax.inject.Named");
219+
annotationType.equals("jakarta.inject.Named");
226220

227221
return (isStereotype && attributes.containsKey("value"));
228222
}

spring-context/src/main/java/org/springframework/context/annotation/AnnotationConfigUtils.java

+1-5
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,6 @@ public abstract class AnnotationConfigUtils {
117117
private static final boolean jakartaAnnotationsPresent =
118118
ClassUtils.isPresent("jakarta.annotation.PostConstruct", classLoader);
119119

120-
private static final boolean jsr250Present =
121-
ClassUtils.isPresent("javax.annotation.PostConstruct", classLoader);
122-
123120
private static final boolean jpaPresent =
124121
ClassUtils.isPresent("jakarta.persistence.EntityManagerFactory", classLoader) &&
125122
ClassUtils.isPresent(PERSISTENCE_ANNOTATION_PROCESSOR_CLASS_NAME, classLoader);
@@ -169,8 +166,7 @@ public static Set<BeanDefinitionHolder> registerAnnotationConfigProcessors(
169166
}
170167

171168
// Check for Jakarta Annotations support, and if present add the CommonAnnotationBeanPostProcessor.
172-
if ((jakartaAnnotationsPresent || jsr250Present) &&
173-
!registry.containsBeanDefinition(COMMON_ANNOTATION_PROCESSOR_BEAN_NAME)) {
169+
if (jakartaAnnotationsPresent && !registry.containsBeanDefinition(COMMON_ANNOTATION_PROCESSOR_BEAN_NAME)) {
174170
RootBeanDefinition def = new RootBeanDefinition(CommonAnnotationBeanPostProcessor.class);
175171
def.setSource(source);
176172
beanDefs.add(registerPostProcessor(registry, def, COMMON_ANNOTATION_PROCESSOR_BEAN_NAME));

spring-context/src/main/java/org/springframework/context/annotation/ClassPathBeanDefinitionScanner.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2023 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -48,8 +48,7 @@
4848
* {@link org.springframework.stereotype.Service @Service}, or
4949
* {@link org.springframework.stereotype.Controller @Controller} stereotype.
5050
*
51-
* <p>Also supports Jakarta EE's {@link jakarta.annotation.ManagedBean} and
52-
* JSR-330's {@link jakarta.inject.Named} annotations, if available.
51+
* <p>Also supports JSR-330's {@link jakarta.inject.Named} annotations, if available.
5352
*
5453
* @author Mark Fisher
5554
* @author Juergen Hoeller

0 commit comments

Comments
 (0)