Skip to content

Commit 855e90c

Browse files
committed
ClassUtils: deprecate hasClass methods
An implication of these methods is that they might somehow test for the existence of classes without loading them, which is not actually true. Better to recommend using Types.load directly and comparing vs null.
1 parent 92d9ee9 commit 855e90c

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

src/main/java/org/scijava/util/ClassUtils.java

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -89,18 +89,6 @@ private ClassUtils() {
8989

9090
// -- Class loading, querying and reflection --
9191

92-
/** Checks whether a class with the given name exists. */
93-
public static boolean hasClass(final String className) {
94-
return hasClass(className, null);
95-
}
96-
97-
/** Checks whether a class with the given name exists. */
98-
public static boolean hasClass(final String className,
99-
final ClassLoader classLoader)
100-
{
101-
return Types.load(className, classLoader) != null;
102-
}
103-
10492
/**
10593
* Gets the base location of the given class.
10694
* <p>
@@ -627,6 +615,20 @@ public static Class<?> loadClass(final String name,
627615
return Types.load(name, classLoader, quietly);
628616
}
629617

618+
/** @deprecated Use {@link Types#load(String)} instead. */
619+
@Deprecated
620+
public static boolean hasClass(final String className) {
621+
return Types.load(className) != null;
622+
}
623+
624+
/** @deprecated Use {@link Types#load(String, ClassLoader)} instead. */
625+
@Deprecated
626+
public static boolean hasClass(final String className,
627+
final ClassLoader classLoader)
628+
{
629+
return Types.load(className, classLoader) != null;
630+
}
631+
630632
/** @deprecated use {@link ConversionUtils#convert(Object, Class)} */
631633
@Deprecated
632634
public static <T> T convert(final Object value, final Class<T> type) {

0 commit comments

Comments
 (0)