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 0dda87c097 Marshall module improvements
0dda87c097 is described below

commit 0dda87c097b2dac950270c54f99c78db9f9912fe
Author: James Bognar <[email protected]>
AuthorDate: Mon Dec 8 12:42:56 2025 -0500

    Marshall module improvements
---
 .../main/java/org/apache/juneau/BeanContext.java   | 10 +++++-----
 .../src/main/java/org/apache/juneau/ClassMeta.java | 22 +++++++---------------
 2 files changed, 12 insertions(+), 20 deletions(-)

diff --git 
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanContext.java 
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanContext.java
index a871e305f1..bbadfed184 100644
--- 
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanContext.java
+++ 
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanContext.java
@@ -3533,8 +3533,8 @@ public class BeanContext extends Context {
                swapArray = _swaps.toArray(new ObjectSwap[_swaps.size()]);
 
                cmCache = new ConcurrentHashMap<>();
-               cmCache.put(String.class, new ClassMeta(String.class, this, 
findObjectSwaps(String.class), findChildObjectSwaps(String.class)));
-               cmCache.put(Object.class, new ClassMeta(Object.class, this, 
findObjectSwaps(Object.class), findChildObjectSwaps(Object.class)));
+               cmCache.put(String.class, new ClassMeta(String.class, this));
+               cmCache.put(Object.class, new ClassMeta(Object.class, this));
                cmString = cmCache.get(String.class);
                cmObject = cmCache.get(Object.class);
                cmClass = cmCache.get(Class.class);
@@ -4045,7 +4045,7 @@ public class BeanContext extends Context {
         * @param c The class to check.
         * @return <jk>true</jk> if the specified class or one of its 
subclasses has a {@link ObjectSwap} associated with it.
         */
-       private final ObjectSwap[] findChildObjectSwaps(Class<?> c) {
+       final ObjectSwap[] findChildObjectSwaps(Class<?> c) {
                if (c == null || swapArray.length == 0)
                        return null;
                var l = (List<ObjectSwap>)null;
@@ -4067,7 +4067,7 @@ public class BeanContext extends Context {
         * @param c The class associated with the swap.
         * @return The swap associated with the class, or null if there is no 
association.
         */
-       private final <T> ObjectSwap[] findObjectSwaps(Class<T> c) {
+       final <T> ObjectSwap[] findObjectSwaps(Class<T> c) {
                // Note:  On first
                if (nn(c)) {
                        List<ObjectSwap> l = list();
@@ -4367,7 +4367,7 @@ public class BeanContext extends Context {
                                // Make sure someone didn't already set it 
while this thread was blocked.
                                cm = cmCache.get(type);
                                if (cm == null)
-                                       cm = new ClassMeta<>(type, this, 
findObjectSwaps(type), findChildObjectSwaps(type));
+                                       cm = new ClassMeta<>(type, this);
                        }
                }
                if (waitForInit)
diff --git 
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/ClassMeta.java 
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/ClassMeta.java
index 3c3cb9b435..6b20542e3f 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/ClassMeta.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/ClassMeta.java
@@ -173,22 +173,12 @@ public class ClassMeta<T> extends ClassInfoTyped<T> {
         *
         * @param innerClass The class being wrapped.
         * @param beanContext The bean context that created this object.
-        * @param implClass
-        *      For interfaces and abstract classes, this represents the "real" 
class to instantiate.
-        *      Can be <jk>null</jk>.
-        * @param swaps
-        *      The {@link ObjectSwap} programmatically associated with this 
class.
-        *      Can be <jk>null</jk>.
-        * @param childSwaps
-        *      The child {@link ObjectSwap ObjectSwaps} programmatically 
associated with this class.
-        *      These are the <c>ObjectSwaps</c> that have normal classes that 
are subclasses of this class.
-        *      Can be <jk>null</jk>.
         * @param delayedInit
         *      Don't call init() in constructor.
         *      Used for delayed initialization when the possibility of class 
reference loops exist.
         */
        @SuppressWarnings("unchecked")
-       ClassMeta(Class<T> innerClass, BeanContext beanContext, 
ObjectSwap<T,?>[] swaps, ObjectSwap<?,?>[] childSwaps) {
+       ClassMeta(Class<T> innerClass, BeanContext beanContext) {
                super(innerClass);
                this.beanContext = beanContext;
                this.cat = new Categories();
@@ -266,9 +256,10 @@ public class ClassMeta<T> extends ClassInfoTyped<T> {
                        this.dictionaryName = 
memoize(()->findBeanDictionaryName());
 
                        var _swaps = new ArrayList<ObjectSwap<T,?>>();
-                       if (swaps != null)
-                               for (var s : swaps)
-                                       _swaps.add(s);
+                       var programmaticSwaps = 
beanContext.findObjectSwaps(innerClass);
+                       if (programmaticSwaps != null)
+                               for (var s : programmaticSwaps)
+                                       _swaps.add((ObjectSwap<T,?>)s);
 
                        ap.find(Swap.class, 
this).stream().map(AnnotationInfo::inner).forEach(x -> 
_swaps.add(createSwap(x)));
                        var ds = DefaultSwaps.find(this);
@@ -288,7 +279,8 @@ public class ClassMeta<T> extends ClassInfoTyped<T> {
 
                        this.proxyInvocationHandler = 
()->(nn(beanMeta.get().getA()) && beanContext.isUseInterfaceProxies() && 
isInterface()) ? new BeanProxyInvocationHandler<>(beanMeta.get().getA()) : null;
 
-                       this.childSwaps = childSwaps == null ? null : 
Arrays.asList(childSwaps);
+                       var childSwapsArray = 
beanContext.findChildObjectSwaps(innerClass);
+                       this.childSwaps = childSwapsArray == null ? null : 
Arrays.asList(childSwapsArray);
                        this.childUnswapMap = 
Cache.<Class<?>,ObjectSwap<?,?>>create().supplier(x -> findUnswap(x)).build();
                        this.childSwapMap = 
Cache.<Class<?>,ObjectSwap<?,?>>create().supplier(x -> findSwap(x)).build();
 

Reply via email to