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

jamesbognar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/juneau.git


The following commit(s) were added to refs/heads/master by this push:
     new eaa96f9229 Marshall module improvements
eaa96f9229 is described below

commit eaa96f9229954d480cb8c5fc48373b7bcae2e328
Author: James Bognar <[email protected]>
AuthorDate: Fri Dec 5 19:27:18 2025 -0500

    Marshall module improvements
---
 .../juneau/commons/annotation/AppliedAnnotationObject.java |  3 ++-
 .../java/org/apache/juneau/commons/utils/ClassUtils.java   | 14 ++++++++++++--
 .../main/java/org/apache/juneau/jena/RdfParserSession.java |  4 ++--
 .../src/main/java/org/apache/juneau/BeanPropertyMeta.java  |  6 +++---
 .../src/main/java/org/apache/juneau/BeanPropertyValue.java |  4 +++-
 .../main/java/org/apache/juneau/collections/JsonMap.java   |  4 ++--
 .../java/org/apache/juneau/json/JsonParserSession.java     |  2 +-
 .../org/apache/juneau/msgpack/MsgPackParserSession.java    |  2 +-
 .../main/java/org/apache/juneau/uon/UonParserSession.java  |  4 ++--
 .../main/java/org/apache/juneau/xml/XmlParserSession.java  |  2 +-
 10 files changed, 29 insertions(+), 16 deletions(-)

diff --git 
a/juneau-core/juneau-commons/src/main/java/org/apache/juneau/commons/annotation/AppliedAnnotationObject.java
 
b/juneau-core/juneau-commons/src/main/java/org/apache/juneau/commons/annotation/AppliedAnnotationObject.java
index de8a6644c1..6e43ea6f3e 100644
--- 
a/juneau-core/juneau-commons/src/main/java/org/apache/juneau/commons/annotation/AppliedAnnotationObject.java
+++ 
b/juneau-core/juneau-commons/src/main/java/org/apache/juneau/commons/annotation/AppliedAnnotationObject.java
@@ -19,6 +19,7 @@ package org.apache.juneau.commons.annotation;
 import static org.apache.juneau.commons.reflect.ReflectionUtils.*;
 import static org.apache.juneau.commons.utils.AssertionUtils.*;
 import static org.apache.juneau.commons.utils.CollectionUtils.*;
+import static org.apache.juneau.commons.utils.Utils.*;
 
 import java.lang.annotation.*;
 import java.lang.reflect.*;
@@ -446,7 +447,7 @@ public class AppliedAnnotationObject extends 
AnnotationObject {
                public BuilderT on(ClassInfo...value) {
                        assertVarargsNotNull("value", value);
                        for (var v : value)
-                               on = addAll(on, v.inner().getName());
+                               on = addAll(on, cn(v));
                        return this;
                }
 
diff --git 
a/juneau-core/juneau-commons/src/main/java/org/apache/juneau/commons/utils/ClassUtils.java
 
b/juneau-core/juneau-commons/src/main/java/org/apache/juneau/commons/utils/ClassUtils.java
index b8b8b29708..b1f09277b4 100644
--- 
a/juneau-core/juneau-commons/src/main/java/org/apache/juneau/commons/utils/ClassUtils.java
+++ 
b/juneau-core/juneau-commons/src/main/java/org/apache/juneau/commons/utils/ClassUtils.java
@@ -149,7 +149,13 @@ public class ClassUtils {
         * @return The name of the class or <jk>null</jk> if the value was null.
         */
        public static String className(Object value) {
-               return value == null ? null : value instanceof Class<?> ? 
((Class<?>)value).getName() : value.getClass().getName();
+               if (value == null)
+                       return null;
+               if (value instanceof Class value2)
+                       return value2.getName();
+               if (value instanceof ClassInfo value2)
+                       return value2.getName();
+               return value.getClass().getName();
        }
 
        /**
@@ -185,9 +191,13 @@ public class ClassUtils {
         * @return The simple name of the class or <jk>null</jk> if the value 
was null.
         */
        public static String classNameSimple(Object value) {
+               if (value == null)
+                       return null;
+               if (value instanceof Class value2)
+                       return value2.getSimpleName();
                if (value instanceof ClassInfo value2)
                        return value2.getNameSimple();
-               return value == null ? null : value instanceof Class<?> c ? 
c.getSimpleName() : value.getClass().getSimpleName();
+               return value.getClass().getSimpleName();
        }
 
        /**
diff --git 
a/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/RdfParserSession.java
 
b/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/RdfParserSession.java
index f46e534506..77750e14cd 100644
--- 
a/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/RdfParserSession.java
+++ 
b/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/RdfParserSession.java
@@ -443,9 +443,9 @@ public class RdfParserSession extends ReaderParserSession {
                        else if (nn(sType.getProxyInvocationHandler()))
                                o = newBeanMap(outer, 
sType.inner()).load(m).getBean();
                        else
-                               throw new ParseException(this, "Class ''{0}'' 
could not be instantiated.  Reason: ''{1}''", sType.inner().getName(), 
sType.getNotABeanReason());
+                               throw new ParseException(this, "Class ''{0}'' 
could not be instantiated.  Reason: ''{1}''", cn(sType), 
sType.getNotABeanReason());
                } else {
-                       throw new ParseException(this, "Class ''{0}'' could not 
be instantiated.  Reason: ''{1}''", sType.inner().getName(), 
sType.getNotABeanReason());
+                       throw new ParseException(this, "Class ''{0}'' could not 
be instantiated.  Reason: ''{1}''", cn(sType), sType.getNotABeanReason());
                }
 
                if (nn(swap) && nn(o))
diff --git 
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanPropertyMeta.java
 
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanPropertyMeta.java
index 5cd1381b43..6985c90052 100644
--- 
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanPropertyMeta.java
+++ 
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanPropertyMeta.java
@@ -922,7 +922,7 @@ public class BeanPropertyMeta implements 
Comparable<BeanPropertyMeta> {
 
        @Override /* Overridden from Object */
        public String toString() {
-               return name + ": " + this.rawTypeMeta.inner().getName() + ", 
field=[" + field + "], getter=[" + getter + "], setter=[" + setter + "]";
+               return name + ": " + cn(this.rawTypeMeta) + ", field=[" + field 
+ "], getter=[" + getter + "], setter=[" + setter + "]";
        }
 
        private Object applyChildPropertiesFilter(BeanSession session, 
ClassMeta cm, Object o) {
@@ -1047,7 +1047,7 @@ public class BeanPropertyMeta implements 
Comparable<BeanPropertyMeta> {
                                m = (Map<String,Object>)getter.invoke(bean);
                        else
                                throw bex(beanMeta.c, "Cannot set property 
''{0}'' of type ''{1}'' to object of type ''{2}'' because no setter is defined 
on this property, and the existing property value is null",
-                                       name, 
this.getClassMeta().inner().getName(), findClassName(val));
+                                       name, cn(this.getClassMeta()), 
findClassName(val));
                        return (m == null ? null : m.put(pName, val));
                }
                if (nn(setter))
@@ -1057,7 +1057,7 @@ public class BeanPropertyMeta implements 
Comparable<BeanPropertyMeta> {
                        return null;
                }
                throw bex(beanMeta.c, "Cannot set property ''{0}'' of type 
''{1}'' to object of type ''{2}'' because no setter is defined on this 
property, and the existing property value is null", name,
-                       this.getClassMeta().inner().getName(), 
findClassName(val));
+                       cn(this.getClassMeta()), findClassName(val));
        }
 
        @SuppressWarnings("null")
diff --git 
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanPropertyValue.java
 
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanPropertyValue.java
index d9e8e1b1cc..aefbfc0ee3 100644
--- 
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanPropertyValue.java
+++ 
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanPropertyValue.java
@@ -16,6 +16,8 @@
  */
 package org.apache.juneau;
 
+import static org.apache.juneau.commons.utils.Utils.*;
+
 import org.apache.juneau.collections.*;
 
 /**
@@ -91,7 +93,7 @@ public class BeanPropertyValue implements 
Comparable<BeanPropertyValue> {
                        .create()
                        .append("name", name)
                        .append("value", value)
-                       .append("type", 
pMeta.getClassMeta().inner().getSimpleName())
+                       .append("type", cns(pMeta.getClassMeta()))
                        .toString();
                // @formatter:on
        }
diff --git 
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/collections/JsonMap.java
 
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/collections/JsonMap.java
index 645fbd4f2f..0747325bb3 100644
--- 
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/collections/JsonMap.java
+++ 
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/collections/JsonMap.java
@@ -1820,10 +1820,10 @@ public class JsonMap extends 
LinkedHashMap<String,Object> {
                        }
 
                } catch (Exception e) {
-                       throw bex(e, cm.inner(), "Error occurred attempting to 
cast to an object of type ''{0}''", cm.inner().getName());
+                       throw bex(e, cm.inner(), "Error occurred attempting to 
cast to an object of type ''{0}''", cn(cm));
                }
 
-               throw bex(cm.inner(), "Cannot convert to class type ''{0}''.  
Only beans and maps can be converted using this method.", cm.inner().getName());
+               throw bex(cm.inner(), "Cannot convert to class type ''{0}''.  
Only beans and maps can be converted using this method.", cn(cm));
        }
 
        private ObjectRest getObjectRest() {
diff --git 
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/JsonParserSession.java
 
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/JsonParserSession.java
index 09546a0711..f33ab27aed 100644
--- 
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/JsonParserSession.java
+++ 
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/JsonParserSession.java
@@ -301,7 +301,7 @@ public class JsonParserSession extends ReaderParserSession {
                        else if (nn(sType.getProxyInvocationHandler()))
                                o = newBeanMap(outer, 
sType.inner()).load(m).getBean();
                        else
-                               throw new ParseException(this, "Class ''{0}'' 
could not be instantiated.  Reason: ''{1}''", sType.inner().getName(), 
sType.getNotABeanReason());
+                               throw new ParseException(this, "Class ''{0}'' 
could not be instantiated.  Reason: ''{1}''", cn(sType), 
sType.getNotABeanReason());
                } else if (sType.canCreateNewInstanceFromString(outer) && ! 
isStrict()) {
                        o = sType.newInstanceFromString(outer, parseString(r));
                } else {
diff --git 
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/msgpack/MsgPackParserSession.java
 
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/msgpack/MsgPackParserSession.java
index 7897ee0f38..4b4a458521 100644
--- 
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/msgpack/MsgPackParserSession.java
+++ 
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/msgpack/MsgPackParserSession.java
@@ -314,7 +314,7 @@ public class MsgPackParserSession extends 
InputStreamParserSession {
                                else if (nn(sType.getProxyInvocationHandler()))
                                        o = newBeanMap(outer, 
sType.inner()).load(m).getBean();
                                else
-                                       throw new ParseException(this, "Class 
''{0}'' could not be instantiated.  Reason: ''{1}''", sType.inner().getName(), 
sType.getNotABeanReason());
+                                       throw new ParseException(this, "Class 
''{0}'' could not be instantiated.  Reason: ''{1}''", cn(sType), 
sType.getNotABeanReason());
                        } else {
                                throw new ParseException(this, "Invalid data 
type {0} encountered for parse type {1}", dt, sType);
                        }
diff --git 
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/uon/UonParserSession.java
 
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/uon/UonParserSession.java
index c93649832d..cf81ca006f 100644
--- 
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/uon/UonParserSession.java
+++ 
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/uon/UonParserSession.java
@@ -424,12 +424,12 @@ public class UonParserSession extends ReaderParserSession 
implements HttpPartPar
                        else if (nn(sType.getProxyInvocationHandler()))
                                o = newBeanMap(outer, 
sType.inner()).load(m).getBean();
                        else
-                               throw new ParseException(this, "Class ''{0}'' 
could not be instantiated.  Reason: ''{1}''", sType.inner().getName(), 
sType.getNotABeanReason());
+                               throw new ParseException(this, "Class ''{0}'' 
could not be instantiated.  Reason: ''{1}''", cn(sType), 
sType.getNotABeanReason());
                } else if (c == 'n') {
                        r.read(); // NOSONAR - Intentional.
                        parseNull(r);
                } else {
-                       throw new ParseException(this, "Class ''{0}'' could not 
be instantiated.  Reason: ''{1}''", sType.inner().getName(), 
sType.getNotABeanReason());
+                       throw new ParseException(this, "Class ''{0}'' could not 
be instantiated.  Reason: ''{1}''", cn(sType), sType.getNotABeanReason());
                }
 
                if (o == null && sType.isPrimitive())
diff --git 
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlParserSession.java
 
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlParserSession.java
index 13ededf3bc..0f9ba9d36f 100644
--- 
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlParserSession.java
+++ 
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlParserSession.java
@@ -876,7 +876,7 @@ public class XmlParserSession extends ReaderParserSession {
                                m = new JsonMap(this).append(wrapperAttr, m);
                        o = newBeanMap(outer, sType.inner()).load(m).getBean();
                } else {
-                       throw new ParseException(this, "Class ''{0}'' could not 
be instantiated.  Reason: ''{1}'', property: ''{2}''", sType.inner().getName(), 
sType.getNotABeanReason(),
+                       throw new ParseException(this, "Class ''{0}'' could not 
be instantiated.  Reason: ''{1}'', property: ''{2}''", cn(sType), 
sType.getNotABeanReason(),
                                pMeta == null ? null : pMeta.getName());
                }
 

Reply via email to