You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2024/03/17 14:09:22 UTC
(commons-logging) branch master updated: cure generics warnings (#213)
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-logging.git
The following commit(s) were added to refs/heads/master by this push:
new 3b2daae cure generics warnings (#213)
3b2daae is described below
commit 3b2daae4836c8f8bd25b466000cead3fa34404d7
Author: Elliotte Rusty Harold <el...@users.noreply.github.com>
AuthorDate: Sun Mar 17 10:09:17 2024 -0400
cure generics warnings (#213)
---
.../commons/logging/impl/LogFactoryImpl.java | 23 +++++++++++-----------
.../org/apache/commons/logging/LoadTestCase.java | 10 +++++-----
2 files changed, 17 insertions(+), 16 deletions(-)
diff --git a/src/main/java/org/apache/commons/logging/impl/LogFactoryImpl.java b/src/main/java/org/apache/commons/logging/impl/LogFactoryImpl.java
index 445d072..349b5fc 100644
--- a/src/main/java/org/apache/commons/logging/impl/LogFactoryImpl.java
+++ b/src/main/java/org/apache/commons/logging/impl/LogFactoryImpl.java
@@ -263,12 +263,12 @@ public class LogFactoryImpl extends LogFactory {
* This value is initialized by {@code getLogConstructor()},
* and then returned repeatedly.
*/
- protected Constructor logConstructor;
+ protected Constructor<?> logConstructor;
/**
* The signature of the Constructor to be used.
*/
- protected Class[] logConstructorSignature = { String.class };
+ protected Class<?>[] logConstructorSignature = { String.class };
/**
* The one-argument {@code setLogFactory} method of the selected
@@ -279,7 +279,7 @@ public class LogFactoryImpl extends LogFactory {
/**
* The signature of the {@code setLogFactory} method to be used.
*/
- protected Class[] logMethodSignature = { LogFactory.class };
+ protected Class<?>[] logMethodSignature = { LogFactory.class };
/**
* See getBaseClassLoader and initConfiguration.
@@ -331,9 +331,9 @@ public class LogFactoryImpl extends LogFactory {
final Object[] params = { logCategory };
Log logAdapter = null;
- Constructor constructor = null;
+ Constructor<?> constructor = null;
- Class logAdapterClass = null;
+ Class<?> logAdapterClass = null;
ClassLoader currentCL = getBaseClassLoader();
for(;;) {
@@ -361,7 +361,7 @@ public class LogFactoryImpl extends LogFactory {
}
}
- Class clazz;
+ Class<?> clazz;
try {
clazz = Class.forName(logAdapterClassName, true, currentCL);
} catch (final ClassNotFoundException originalClassNotFoundException) {
@@ -872,7 +872,7 @@ public class LogFactoryImpl extends LogFactory {
* @deprecated Never invoked by this class; subclasses should not assume it will be.
*/
@Deprecated
- protected Constructor getLogConstructor()
+ protected Constructor<?> getLogConstructor()
throws LogConfigurationException {
// Return the previously identified Constructor (if any)
@@ -1023,13 +1023,13 @@ public class LogFactoryImpl extends LogFactory {
* @throws LogConfigurationException when the situation
* should not be recovered from.
*/
- private void handleFlawedHierarchy(final ClassLoader badClassLoader, final Class badClass)
+ private void handleFlawedHierarchy(final ClassLoader badClassLoader, final Class<?> badClass)
throws LogConfigurationException {
boolean implementsLog = false;
final String logInterfaceName = Log.class.getName();
- final Class[] interfaces = badClass.getInterfaces();
- for (final Class element : interfaces) {
+ final Class<?>[] interfaces = badClass.getInterfaces();
+ for (final Class<?> element : interfaces) {
if (logInterfaceName.equals(element.getName())) {
implementsLog = true;
break;
@@ -1157,7 +1157,8 @@ public class LogFactoryImpl extends LogFactory {
// the context it is intended to manage.
// Note that this prefix should be kept consistent with that
// in LogFactory.
- final Class clazz = this.getClass();
+ @SuppressWarnings("unchecked")
+ final Class<LogFactoryImpl> clazz = (Class<LogFactoryImpl>) this.getClass();
final ClassLoader classLoader = getClassLoader(clazz);
String classLoaderName;
try {
diff --git a/src/test/java/org/apache/commons/logging/LoadTestCase.java b/src/test/java/org/apache/commons/logging/LoadTestCase.java
index 17f14fb..0005202 100644
--- a/src/test/java/org/apache/commons/logging/LoadTestCase.java
+++ b/src/test/java/org/apache/commons/logging/LoadTestCase.java
@@ -42,9 +42,9 @@ public class LoadTestCase extends TestCase {
super(parent);
}
- private Class def(final String name) throws ClassNotFoundException {
+ private Class<?> def(final String name) throws ClassNotFoundException {
- Class result = (Class) classes.get(name);
+ Class<?> result = (Class<?>) classes.get(name);
if (result != null) {
return result;
}
@@ -130,8 +130,8 @@ public class LoadTestCase extends TestCase {
* (expected to be a UserClass loaded via a custom class loader), passing
* it the specified state parameter.
*/
- private void setAllowFlawedContext(final Class c, final String state) throws Exception {
- final Class[] params = {String.class};
+ private void setAllowFlawedContext(final Class<?> c, final String state) throws Exception {
+ final Class<?>[] params = {String.class};
final java.lang.reflect.Method m = c.getDeclaredMethod("setAllowFlawedContext", params);
m.invoke(null, state);
}
@@ -165,7 +165,7 @@ public class LoadTestCase extends TestCase {
// 2. Thread.currentThread().setContextClassLoader(null);
// Context class loader is same as class calling into log
- Class cls = reload();
+ Class<?> cls = reload();
Thread.currentThread().setContextClassLoader(cls.getClassLoader());
execute(cls);