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-jxpath.git
commit 39bead97c9bce0c7a45d59fcea79637a4d02f724 Author: Gary D. Gregory <garydgreg...@gmail.com> AuthorDate: Sun Apr 13 14:54:03 2025 -0400 Reduce public API footprint for new class --- src/changes/changes.xml | 1 - .../apache/commons/jxpath/JXPathIntrospector.java | 2 +- .../commons/jxpath/util/ClassLoaderUtil.java | 38 +++------------------- 3 files changed, 5 insertions(+), 36 deletions(-) diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 53cbb4f..6f2a714 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -110,7 +110,6 @@ The <action> type attribute can be add,update,fix,remove. <action dev="ggregory" type="fix" due-to="Gary Gregory">Use generics internally.</action> <action dev="ggregory" type="fix" due-to="Gary Gregory">NodeSet.getPointers() is now typed with generics.</action> <action dev="ggregory" type="fix" due-to="Gary Gregory">ServletContextHandler.collectPropertyNames(HashSet, Object) is now typed with generics.</action> - <action dev="ggregory" type="fix" due-to="Gary Gregory">Deprecate ClassLoaderUtil.ClassLoaderUtil().</action> <action dev="ggregory" type="fix" due-to="Gary Gregory">Deprecate MethodLookupUtils.MethodLookupUtils().</action> <action dev="ggregory" type="fix" due-to="Gary Gregory">Deprecate KeyManagerUtils.KeyManagerUtils().</action> <action dev="ggregory" type="fix" due-to="Gary Gregory">Deprecate TypeUtils.TypeUtils().</action> diff --git a/src/main/java/org/apache/commons/jxpath/JXPathIntrospector.java b/src/main/java/org/apache/commons/jxpath/JXPathIntrospector.java index e5ada65..4f096d1 100644 --- a/src/main/java/org/apache/commons/jxpath/JXPathIntrospector.java +++ b/src/main/java/org/apache/commons/jxpath/JXPathIntrospector.java @@ -166,7 +166,7 @@ public class JXPathIntrospector { } } // Now try the ClassLoaderUtil. - return ClassLoaderUtil.getClass(className).newInstance(); + return ClassLoaderUtil.getClass(className, true).newInstance(); } /** diff --git a/src/main/java/org/apache/commons/jxpath/util/ClassLoaderUtil.java b/src/main/java/org/apache/commons/jxpath/util/ClassLoaderUtil.java index 7311436..ec239bf 100644 --- a/src/main/java/org/apache/commons/jxpath/util/ClassLoaderUtil.java +++ b/src/main/java/org/apache/commons/jxpath/util/ClassLoaderUtil.java @@ -27,8 +27,9 @@ import java.util.Objects; * context class loader results in a {@code java.lang.ClassNotFoundException}. * * See org.apache.commons.lang3.ClassUtils + * @since 1.4.0 */ -public class ClassLoaderUtil { +public final class ClassLoaderUtil { /** * Maps a primitive class name to its corresponding abbreviation used in array class names. @@ -58,21 +59,6 @@ public class ClassLoaderUtil { abbreviationMap.put(primitive, abbreviation); } - /** - * Returns the (initialized) class represented by {@code className} using the {@code classLoader}. This implementation supports names like - * "{@code java.lang.String[]}" as well as "{@code [Ljava.lang.String;}". - * - * @param <T> The expected class type. - * @param classLoader the class loader to use to load the class - * @param className the class name - * @return the class represented by {@code className} using the {@code classLoader} - * @throws ClassNotFoundException if the class is not found - */ - public static <T> Class<T> getClass(final ClassLoader classLoader, final String className) throws ClassNotFoundException { - return getClass(classLoader, className, true); - } - - // Class loading /** * Returns the class represented by {@code className} using the {@code classLoader}. This implementation supports names like "{@code java.lang.String[]}" as * well as "{@code [Ljava.lang.String;}". @@ -85,7 +71,7 @@ public class ClassLoaderUtil { * @throws ClassNotFoundException if the class is not found */ @SuppressWarnings("unchecked") // assume the call site knows what it's doing. - public static <T> Class<T> getClass(final ClassLoader classLoader, final String className, final boolean initialize) throws ClassNotFoundException { + private static <T> Class<T> getClass(final ClassLoader classLoader, final String className, final boolean initialize) throws ClassNotFoundException { Class<T> clazz; if (abbreviationMap.containsKey(className)) { final String clsName = "[" + abbreviationMap.get(className); @@ -96,19 +82,6 @@ public class ClassLoaderUtil { return clazz; } - /** - * Returns the (initialized) class represented by {@code className} using the current thread's context class loader. This implementation supports names like - * "{@code java.lang.String[]}" as well as "{@code [Ljava.lang.String;}". - * - * @param <T> The expected class type. - * @param className the class name - * @return the class represented by {@code className} using the current thread's context class loader - * @throws ClassNotFoundException if the class is not found - */ - public static <T> Class<T> getClass(final String className) throws ClassNotFoundException { - return getClass(className, true); - } - /** * Returns the class represented by {@code className} using the current thread's context class loader. This implementation supports names like * "{@code java.lang.String[]}" as well as "{@code [Ljava.lang.String;}". @@ -159,11 +132,8 @@ public class ClassLoaderUtil { /** * Constructs a new instance. - * - * @deprecated Constructor will be private in the next major version. */ - @Deprecated - public ClassLoaderUtil() { + private ClassLoaderUtil() { // empty } }