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 2025/04/13 18:54:08 UTC

(commons-jxpath) branch master updated (9e04732 -> 39bead9)

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/commons-jxpath.git


    from 9e04732  Simplify new interface ExceptionHandler
     new da8fb28  Reuse Objects.equals()
     new 39bead9  Reduce public API footprint for new class

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/changes/changes.xml                            |  1 -
 .../apache/commons/jxpath/JXPathIntrospector.java  |  2 +-
 .../jxpath/ri/model/dynabeans/DynaBeanPointer.java | 14 ++------
 .../commons/jxpath/util/ClassLoaderUtil.java       | 38 +++-------------------
 4 files changed, 7 insertions(+), 48 deletions(-)


(commons-jxpath) 02/02: Reduce public API footprint for new class

Posted by gg...@apache.org.
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 <ga...@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
     }
 }


(commons-jxpath) 01/02: Reuse Objects.equals()

Posted by gg...@apache.org.
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 da8fb28f5a1b9f82310d785bab350e1d4437f402
Author: Gary D. Gregory <ga...@gmail.com>
AuthorDate: Sun Apr 13 14:48:03 2025 -0400

    Reuse Objects.equals()
---
 .../commons/jxpath/ri/model/dynabeans/DynaBeanPointer.java | 14 ++------------
 1 file changed, 2 insertions(+), 12 deletions(-)

diff --git a/src/main/java/org/apache/commons/jxpath/ri/model/dynabeans/DynaBeanPointer.java b/src/main/java/org/apache/commons/jxpath/ri/model/dynabeans/DynaBeanPointer.java
index d4afaac..a9b9a2e 100644
--- a/src/main/java/org/apache/commons/jxpath/ri/model/dynabeans/DynaBeanPointer.java
+++ b/src/main/java/org/apache/commons/jxpath/ri/model/dynabeans/DynaBeanPointer.java
@@ -18,6 +18,7 @@
 package org.apache.commons.jxpath.ri.model.dynabeans;
 
 import java.util.Locale;
+import java.util.Objects;
 
 import org.apache.commons.beanutils.DynaBean;
 import org.apache.commons.jxpath.ri.QName;
@@ -32,17 +33,6 @@ public class DynaBeanPointer extends PropertyOwnerPointer {
 
     private static final long serialVersionUID = -9135052498044877965L;
 
-    /**
-     * Tests whether two objects are == || .equals().
-     *
-     * @param o1 first object
-     * @param o2 second object
-     * @return boolean
-     */
-    private static boolean equalObjects(final Object o1, final Object o2) {
-        return o1 == o2 || o1 != null && o1.equals(o2);
-    }
-
     /**
      * Qualified name.
      */
@@ -93,7 +83,7 @@ public class DynaBeanPointer extends PropertyOwnerPointer {
             return false;
         }
         final DynaBeanPointer other = (DynaBeanPointer) object;
-        if (!(equalObjects(parent, other.parent) && equalObjects(qName, other.qName))) {
+        if (!(Objects.equals(parent, other.parent) && Objects.equals(qName, other.qName))) {
             return false;
         }
         final int iThis = index == WHOLE_COLLECTION ? 0 : index;