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

commit c4319e8592ea09dc817bf6e4515b4a05544614b5
Author: James Bognar <[email protected]>
AuthorDate: Fri Dec 12 12:41:09 2025 -0500

    Marshall module improvements
---
 .../apache/juneau/commons/reflect/ClassInfo.java   |  2 +-
 .../apache/juneau/commons/reflect/FieldInfo.java   |  2 +-
 .../main/java/org/apache/juneau/BeanContext.java   | 24 ++++++++++++++--------
 .../java/org/apache/juneau/BeanPropertyMeta.java   |  6 +++---
 4 files changed, 20 insertions(+), 14 deletions(-)

diff --git 
a/juneau-core/juneau-commons/src/main/java/org/apache/juneau/commons/reflect/ClassInfo.java
 
b/juneau-core/juneau-commons/src/main/java/org/apache/juneau/commons/reflect/ClassInfo.java
index 3ddef8aab4..062c8ed55e 100644
--- 
a/juneau-core/juneau-commons/src/main/java/org/apache/juneau/commons/reflect/ClassInfo.java
+++ 
b/juneau-core/juneau-commons/src/main/java/org/apache/juneau/commons/reflect/ClassInfo.java
@@ -232,7 +232,7 @@ public class ClassInfo extends ElementInfo implements 
Annotatable, Type {
                this.fullName = memoize(() -> getNameFormatted(FULL, true, '$', 
BRACKETS));
                this.shortName = memoize(() -> getNameFormatted(SHORT, true, 
'$', BRACKETS));
                this.readableName = memoize(() -> getNameFormatted(SIMPLE, 
false, '$', WORD));
-               this.declaredInterfaces = memoize(() -> opt(inner).map(x -> 
stream(x.getInterfaces()).map(ClassInfo::of).map(ClassInfo.class::cast).toList()).orElse(liste()));
+               this.declaredInterfaces = memoize(() -> opt(inner).map(x -> 
stream(x.getGenericInterfaces()).map(ClassInfo::of).map(ClassInfo.class::cast).toList()).orElse(liste()));
                this.interfaces = memoize(() -> getParents().stream().flatMap(x 
-> x.getDeclaredInterfaces().stream()).flatMap(ci2 -> concat(Stream.of(ci2), 
ci2.getInterfaces().stream())).distinct().toList());
                this.allParents = memoize(() -> concat(getParents().stream(), 
getInterfaces().stream()).toList());
                this.parentsAndInterfaces = 
memoize(this::findParentsAndInterfaces);
diff --git 
a/juneau-core/juneau-commons/src/main/java/org/apache/juneau/commons/reflect/FieldInfo.java
 
b/juneau-core/juneau-commons/src/main/java/org/apache/juneau/commons/reflect/FieldInfo.java
index 6b6b990846..d049d4f535 100644
--- 
a/juneau-core/juneau-commons/src/main/java/org/apache/juneau/commons/reflect/FieldInfo.java
+++ 
b/juneau-core/juneau-commons/src/main/java/org/apache/juneau/commons/reflect/FieldInfo.java
@@ -147,7 +147,7 @@ public class FieldInfo extends AccessibleInfo implements 
Comparable<FieldInfo>,
                assertArgNotNull("inner", inner);
                this.declaringClass = declaringClass;
                this.inner = inner;
-               this.type = memoize(() -> ClassInfo.of(inner.getType()));
+               this.type = memoize(() -> ClassInfo.of(inner.getType(), 
inner.getGenericType()));
                this.annotations = memoize(() -> 
stream(inner.getAnnotations()).flatMap(a -> 
AnnotationUtils.streamRepeated(a)).map(a -> ai(this, a)).toList());
                this.fullName = memoize(this::findFullName);
        }
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 39490a2d9a..7ce81e7015 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
@@ -4208,25 +4208,26 @@ public class BeanContext extends Context {
         * Used for determining the class type on a method or field where a 
{@code @Beanp} annotation may be present.
         *
         * @param <T> The class type we're wrapping.
-        * @param p The property annotation on the type if there is one.
-        * @param t The type.
+        * @param p The property annotation info on the type if there is one.
+        * @param ci The class info for the type.
         * @param typeVarImpls
         *      Contains known resolved type parameters on the specified class 
so that we can result
         *      {@code ParameterizedTypes} and {@code TypeVariables}.
         *      Can be <jk>null</jk> if the information is not known.
-        * @return The new {@code ClassMeta} object wrapped around the {@code 
Type} object.
+        * @return The new {@code ClassMeta} object wrapped around the type.
         */
-       protected final <T> ClassMeta<T> resolveClassMeta(Beanp p, Type t, 
Map<Class<?>,Class<?>[]> typeVarImpls) {
-               ClassMeta<T> cm = resolveClassMeta(t, typeVarImpls);
+       protected final <T> ClassMeta<T> resolveClassMeta(AnnotationInfo<Beanp> 
p, ClassInfo ci, Map<Class<?>,Class<?>[]> typeVarImpls) {
+               ClassMeta<T> cm = resolveClassMeta(ci, typeVarImpls);
                ClassMeta<T> cm2 = cm;
 
                if (nn(p)) {
+                       var beanp = p.inner();
 
-                       if (isNotVoid(p.type()))
-                               cm2 = resolveClassMeta(p.type(), typeVarImpls);
+                       if (isNotVoid(beanp.type()))
+                               cm2 = resolveClassMeta(beanp.type(), 
typeVarImpls);
 
                        if (cm2.isMap()) {
-                               Class<?>[] pParams = (p.params().length == 0 ? 
a(Object.class, Object.class) : p.params());
+                               Class<?>[] pParams = (beanp.params().length == 
0 ? a(Object.class, Object.class) : beanp.params());
                                if (pParams.length != 2)
                                        throw rex("Invalid number of parameters 
specified for Map (must be 2): {0}", pParams.length);
                                ClassMeta<?> keyType = resolveType(pParams[0], 
cm2.getKeyType(), cm.getKeyType());
@@ -4237,7 +4238,7 @@ public class BeanContext extends Context {
                        }
 
                        if (cm2.isCollection() || cm2.isOptional()) {
-                               Class<?>[] pParams = (p.params().length == 0 ? 
a(Object.class) : p.params());
+                               Class<?>[] pParams = (beanp.params().length == 
0 ? a(Object.class) : beanp.params());
                                if (pParams.length != 1)
                                        throw rex("Invalid number of parameters 
specified for {1} (must be 1): {0}", pParams.length, (cm2.isCollection() ? 
"Collection" : cm2.isOptional() ? "Optional" : "Array"));
                                ClassMeta<?> elementType = 
resolveType(pParams[0], cm2.getElementType(), cm.getElementType());
@@ -4408,6 +4409,11 @@ public class BeanContext extends Context {
                        return getClassMeta(cm.inner());
                }
 
+               // Handle ClassInfo by extracting the underlying Type
+               if (o instanceof ClassInfo ci) {
+                       return resolveClassMeta(ci.innerType(), typeVarImpls);
+               }
+
                Class c = resolve(o, typeVarImpls);
 
                // This can happen when trying to resolve the "E getFirst()" 
method on LinkedList, whose type is a TypeVariable
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 adf73a0401..bb0fc00d3c 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
@@ -303,7 +303,7 @@ public class BeanPropertyMeta implements 
Comparable<BeanPropertyMeta> {
                                if (nn(field) || isNotEmpty(lp)) {
                                        // Only use field type if it's a bean 
property or has @Beanp annotation.
                                        // Otherwise, we want to infer the type 
from the getter or setter.
-                                       rawTypeMeta = 
bc.resolveClassMeta(opt(last(lp)).map(AnnotationInfo::inner).orElse(null), 
innerField.inner().getGenericType(), typeVarImpls);
+                                       rawTypeMeta = 
bc.resolveClassMeta(opt(last(lp)).orElse(null), innerField.getFieldType(), 
typeVarImpls);
                                        isUri |= (rawTypeMeta.isUri());
                                }
                                lp.forEach(x -> {
@@ -325,7 +325,7 @@ public class BeanPropertyMeta implements 
Comparable<BeanPropertyMeta> {
                        if (nn(getter)) {
                                var lp = ap.find(Beanp.class, gi);
                                if (rawTypeMeta == null)
-                                       rawTypeMeta = 
bc.resolveClassMeta(opt(last(lp)).map(AnnotationInfo::inner).orElse(null), 
getter.inner().getGenericReturnType(), typeVarImpls);
+                                       rawTypeMeta = 
bc.resolveClassMeta(opt(last(lp)).orElse(null), getter.getReturnType(), 
typeVarImpls);
                                isUri |= (rawTypeMeta.isUri() || 
ap.has(Uri.class, gi));
                                lp.forEach(x -> {
                                        var beanp = x.inner();
@@ -345,7 +345,7 @@ public class BeanPropertyMeta implements 
Comparable<BeanPropertyMeta> {
                        if (nn(setter)) {
                                var lp = ap.find(Beanp.class, si);
                                if (rawTypeMeta == null)
-                                       rawTypeMeta = 
bc.resolveClassMeta(opt(last(lp)).map(AnnotationInfo::inner).orElse(null), 
setter.inner().getGenericParameterTypes()[0], typeVarImpls);
+                                       rawTypeMeta = 
bc.resolveClassMeta(opt(last(lp)).orElse(null), 
setter.getParameterTypes().get(0), typeVarImpls);
                                isUri |= (rawTypeMeta.isUri() || 
ap.has(Uri.class, si));
                                lp.forEach(x -> {
                                        var beanp = x.inner();

Reply via email to