Skip to content

Commit f94ded8

Browse files
committed
Consistent use of ClassUtils.forName instead of class.getClassLoader().loadClass
Issue: SPR-11780 (cherry picked from commit 551950c)
1 parent ad8f17b commit f94ded8

File tree

4 files changed

+10
-9
lines changed

4 files changed

+10
-9
lines changed

spring-beans/src/main/java/org/springframework/beans/PropertyEditorRegistrySupport.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2013 the original author or authors.
2+
* Copyright 2002-2014 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.
@@ -89,7 +89,7 @@ public class PropertyEditorRegistrySupport implements PropertyEditorRegistry {
8989

9090
static {
9191
try {
92-
zoneIdClass = PropertyEditorRegistrySupport.class.getClassLoader().loadClass("java.time.ZoneId");
92+
zoneIdClass = ClassUtils.forName("java.time.ZoneId", PropertyEditorRegistrySupport.class.getClassLoader());
9393
}
9494
catch (ClassNotFoundException ex) {
9595
// Java 8 ZoneId class not available

spring-orm-hibernate4/src/main/java/org/springframework/orm/hibernate4/ConfigurableJtaPlatform.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2013 the original author or authors.
2+
* Copyright 2002-2014 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.
@@ -33,6 +33,7 @@
3333

3434
import org.springframework.transaction.jta.UserTransactionAdapter;
3535
import org.springframework.util.Assert;
36+
import org.springframework.util.ClassUtils;
3637

3738
/**
3839
* Implementation of Hibernate 4's JtaPlatform SPI (which has a different package
@@ -51,14 +52,14 @@ class ConfigurableJtaPlatform implements InvocationHandler {
5152
Class<?> jpClass;
5253
try {
5354
// Try Hibernate 4.0-4.2 JtaPlatform variant
54-
jpClass = SpringSessionContext.class.getClassLoader().loadClass(
55-
"org.hibernate.service.jta.platform.spi.JtaPlatform");
55+
jpClass = ClassUtils.forName("org.hibernate.service.jta.platform.spi.JtaPlatform",
56+
ConfigurableJtaPlatform.class.getClassLoader());
5657
}
5758
catch (ClassNotFoundException ex) {
5859
try {
5960
// Try Hibernate 4.3 JtaPlatform variant
60-
jpClass = SpringSessionContext.class.getClassLoader().loadClass(
61-
"org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform");
61+
jpClass = ClassUtils.forName("org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform",
62+
ConfigurableJtaPlatform.class.getClassLoader());
6263
}
6364
catch (ClassNotFoundException ex2) {
6465
throw new IllegalStateException("Neither Hibernate 4.0-4.2 nor 4.3 variant of JtaPlatform found");

spring-orm-hibernate4/src/main/java/org/springframework/orm/hibernate4/LocalSessionFactoryBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public class LocalSessionFactoryBuilder extends Configuration {
9494
try {
9595
@SuppressWarnings("unchecked")
9696
Class<? extends Annotation> converterAnnotation = (Class<? extends Annotation>)
97-
LocalSessionFactoryBuilder.class.getClassLoader().loadClass("javax.persistence.Converter");
97+
ClassUtils.forName("javax.persistence.Converter", LocalSessionFactoryBuilder.class.getClassLoader());
9898
entityTypeFilters.add(new AnnotationTypeFilter(converterAnnotation, false));
9999
}
100100
catch (ClassNotFoundException ex) {

spring-orm/src/main/java/org/springframework/orm/jpa/persistenceunit/DefaultPersistenceUnitManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public class DefaultPersistenceUnitManager
117117
try {
118118
@SuppressWarnings("unchecked")
119119
Class<? extends Annotation> converterAnnotation = (Class<? extends Annotation>)
120-
DefaultPersistenceUnitManager.class.getClassLoader().loadClass("javax.persistence.Converter");
120+
ClassUtils.forName("javax.persistence.Converter", DefaultPersistenceUnitManager.class.getClassLoader());
121121
entityTypeFilters.add(new AnnotationTypeFilter(converterAnnotation, false));
122122
}
123123
catch (ClassNotFoundException ex) {

0 commit comments

Comments
 (0)