1
0

cure generics warnings (#213)

This commit is contained in:
Elliotte Rusty Harold
2024-03-17 10:09:17 -04:00
committed by GitHub
parent 9ee83d3932
commit 3b2daae483
2 changed files with 17 additions and 16 deletions

View File

@@ -263,12 +263,12 @@ public class LogFactoryImpl extends LogFactory {
* This value is initialized by {@code getLogConstructor()}, * This value is initialized by {@code getLogConstructor()},
* and then returned repeatedly. * and then returned repeatedly.
*/ */
protected Constructor logConstructor; protected Constructor<?> logConstructor;
/** /**
* The signature of the Constructor to be used. * 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 * 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. * The signature of the {@code setLogFactory} method to be used.
*/ */
protected Class[] logMethodSignature = { LogFactory.class }; protected Class<?>[] logMethodSignature = { LogFactory.class };
/** /**
* See getBaseClassLoader and initConfiguration. * See getBaseClassLoader and initConfiguration.
@@ -331,9 +331,9 @@ public class LogFactoryImpl extends LogFactory {
final Object[] params = { logCategory }; final Object[] params = { logCategory };
Log logAdapter = null; Log logAdapter = null;
Constructor constructor = null; Constructor<?> constructor = null;
Class logAdapterClass = null; Class<?> logAdapterClass = null;
ClassLoader currentCL = getBaseClassLoader(); ClassLoader currentCL = getBaseClassLoader();
for(;;) { for(;;) {
@@ -361,7 +361,7 @@ public class LogFactoryImpl extends LogFactory {
} }
} }
Class clazz; Class<?> clazz;
try { try {
clazz = Class.forName(logAdapterClassName, true, currentCL); clazz = Class.forName(logAdapterClassName, true, currentCL);
} catch (final ClassNotFoundException originalClassNotFoundException) { } 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 Never invoked by this class; subclasses should not assume it will be.
*/ */
@Deprecated @Deprecated
protected Constructor getLogConstructor() protected Constructor<?> getLogConstructor()
throws LogConfigurationException { throws LogConfigurationException {
// Return the previously identified Constructor (if any) // Return the previously identified Constructor (if any)
@@ -1023,13 +1023,13 @@ public class LogFactoryImpl extends LogFactory {
* @throws LogConfigurationException when the situation * @throws LogConfigurationException when the situation
* should not be recovered from. * 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 { throws LogConfigurationException {
boolean implementsLog = false; boolean implementsLog = false;
final String logInterfaceName = Log.class.getName(); final String logInterfaceName = Log.class.getName();
final Class[] interfaces = badClass.getInterfaces(); final Class<?>[] interfaces = badClass.getInterfaces();
for (final Class element : interfaces) { for (final Class<?> element : interfaces) {
if (logInterfaceName.equals(element.getName())) { if (logInterfaceName.equals(element.getName())) {
implementsLog = true; implementsLog = true;
break; break;
@@ -1157,7 +1157,8 @@ public class LogFactoryImpl extends LogFactory {
// the context it is intended to manage. // the context it is intended to manage.
// Note that this prefix should be kept consistent with that // Note that this prefix should be kept consistent with that
// in LogFactory. // in LogFactory.
final Class clazz = this.getClass(); @SuppressWarnings("unchecked")
final Class<LogFactoryImpl> clazz = (Class<LogFactoryImpl>) this.getClass();
final ClassLoader classLoader = getClassLoader(clazz); final ClassLoader classLoader = getClassLoader(clazz);
String classLoaderName; String classLoaderName;
try { try {

View File

@@ -42,9 +42,9 @@ public class LoadTestCase extends TestCase {
super(parent); 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) { if (result != null) {
return result; return result;
} }
@@ -130,8 +130,8 @@ public class LoadTestCase extends TestCase {
* (expected to be a UserClass loaded via a custom class loader), passing * (expected to be a UserClass loaded via a custom class loader), passing
* it the specified state parameter. * it the specified state parameter.
*/ */
private void setAllowFlawedContext(final Class c, final String state) throws Exception { private void setAllowFlawedContext(final Class<?> c, final String state) throws Exception {
final Class[] params = {String.class}; final Class<?>[] params = {String.class};
final java.lang.reflect.Method m = c.getDeclaredMethod("setAllowFlawedContext", params); final java.lang.reflect.Method m = c.getDeclaredMethod("setAllowFlawedContext", params);
m.invoke(null, state); m.invoke(null, state);
} }
@@ -165,7 +165,7 @@ public class LoadTestCase extends TestCase {
// 2. Thread.currentThread().setContextClassLoader(null); // 2. Thread.currentThread().setContextClassLoader(null);
// Context class loader is same as class calling into log // Context class loader is same as class calling into log
Class cls = reload(); Class<?> cls = reload();
Thread.currentThread().setContextClassLoader(cls.getClassLoader()); Thread.currentThread().setContextClassLoader(cls.getClassLoader());
execute(cls); execute(cls);