diff --git a/c-xml-client/src/main/java/com/webcohesion/enunciate/modules/c_client/ClientClassnameForMethod.java b/c-xml-client/src/main/java/com/webcohesion/enunciate/modules/c_client/ClientClassnameForMethod.java index 2361af1dc..1fd2ea318 100644 --- a/c-xml-client/src/main/java/com/webcohesion/enunciate/modules/c_client/ClientClassnameForMethod.java +++ b/c-xml-client/src/main/java/com/webcohesion/enunciate/modules/c_client/ClientClassnameForMethod.java @@ -16,6 +16,7 @@ package com.webcohesion.enunciate.modules.c_client; import com.webcohesion.enunciate.javac.decorations.TypeMirrorDecorator; +import com.webcohesion.enunciate.javac.decorations.element.ElementUtils; import com.webcohesion.enunciate.javac.decorations.type.DecoratedTypeMirror; import com.webcohesion.enunciate.metadata.ClientName; import com.webcohesion.enunciate.modules.jaxb.EnunciateJaxbContext; @@ -27,7 +28,7 @@ import freemarker.template.TemplateModelException; import jakarta.activation.DataHandler; -import javax.lang.model.element.ElementKind; + import javax.lang.model.element.TypeElement; import javax.lang.model.type.*; import jakarta.xml.bind.JAXBElement; @@ -78,6 +79,7 @@ public ClientClassnameForMethod(Map conversions, EnunciateJaxbCo classConversions.put(javax.xml.datatype.Duration.class.getName(), "xmlChar"); classConversions.put(jakarta.xml.bind.JAXBElement.class.getName(), "struct xmlBasicNode"); classConversions.put(Object.class.getName(), "struct xmlBasicNode"); + classConversions.put(Record.class.getName(), "struct xmlBasicNode"); classConversions.putAll(conversions); } @@ -95,7 +97,7 @@ else if (isCollection(declaration)) { if (adapterType != null) { return convert(adapterType.getAdaptingType()); } - if (declaration.getKind() == ElementKind.CLASS) { + if (ElementUtils.isClassOrRecord(declaration)) { DecoratedTypeMirror superType = (DecoratedTypeMirror) TypeMirrorDecorator.decorate(declaration.getSuperclass(), this.context.getProcessingEnvironment()); if (superType != null && superType.isInstanceOf(JAXBElement.class.getName())) { //for client conversions, we're going to generalize subclasses of JAXBElement to JAXBElement @@ -194,4 +196,4 @@ public String convert(TypeVariable typeVariable) throws TemplateModelException { return conversion; } -} \ No newline at end of file +} diff --git a/core/src/main/java/com/webcohesion/enunciate/util/AccessorBag.java b/core/src/main/java/com/webcohesion/enunciate/util/AccessorBag.java index 1e5510267..20da06078 100644 --- a/core/src/main/java/com/webcohesion/enunciate/util/AccessorBag.java +++ b/core/src/main/java/com/webcohesion/enunciate/util/AccessorBag.java @@ -40,7 +40,7 @@ public void removeByName(E memberDeclaration) { } } - public final ElementList fields = new ElementList<>(); + public final ElementList fields = new ElementList<>(); public final ElementList properties = new ElementList<>(); public String typeIdProperty; diff --git a/core/src/main/java/com/webcohesion/enunciate/util/freemarker/ClientClassnameForMethod.java b/core/src/main/java/com/webcohesion/enunciate/util/freemarker/ClientClassnameForMethod.java index 6cc14dd17..6ce3cb516 100644 --- a/core/src/main/java/com/webcohesion/enunciate/util/freemarker/ClientClassnameForMethod.java +++ b/core/src/main/java/com/webcohesion/enunciate/util/freemarker/ClientClassnameForMethod.java @@ -93,7 +93,7 @@ else if (typeMirror instanceof TypeVariable) { conversion = super.convert(typeMirror); boolean isArray = typeMirror.getKind() == TypeKind.ARRAY; - if (typeMirror instanceof DeclaredType && !"java.lang.Object".equals(conversion) && !"java.lang.Record".equals(conversion)) { + if (typeMirror instanceof DeclaredType && !Object.class.getName().equals(conversion) && !Record.class.getName().equals(conversion)) { conversion += convertDeclaredTypeArguments(((DeclaredType) typeMirror).getTypeArguments()); } @@ -162,4 +162,4 @@ protected String getPackageSeparator() { public String convert(PackageElement packageDeclaration) { throw new UnsupportedOperationException("packages don't have a classname."); } -} \ No newline at end of file +} diff --git a/csharp-xml-client/src/main/java/com/webcohesion/enunciate/modules/csharp_client/ClientClassnameForMethod.java b/csharp-xml-client/src/main/java/com/webcohesion/enunciate/modules/csharp_client/ClientClassnameForMethod.java index 173c5ff84..d60141b5a 100644 --- a/csharp-xml-client/src/main/java/com/webcohesion/enunciate/modules/csharp_client/ClientClassnameForMethod.java +++ b/csharp-xml-client/src/main/java/com/webcohesion/enunciate/modules/csharp_client/ClientClassnameForMethod.java @@ -19,6 +19,7 @@ import com.webcohesion.enunciate.api.resources.Entity; import com.webcohesion.enunciate.api.resources.MediaTypeDescriptor; import com.webcohesion.enunciate.javac.decorations.TypeMirrorDecorator; +import com.webcohesion.enunciate.javac.decorations.element.ElementUtils; import com.webcohesion.enunciate.javac.decorations.type.DecoratedTypeMirror; import com.webcohesion.enunciate.metadata.ClientName; import com.webcohesion.enunciate.modules.jaxb.EnunciateJaxbContext; @@ -34,9 +35,9 @@ import freemarker.template.TemplateModelException; import jakarta.activation.DataHandler; + import javax.lang.model.element.ElementKind; import javax.lang.model.element.TypeElement; -import javax.lang.model.element.TypeParameterElement; import javax.lang.model.type.*; import jakarta.xml.bind.JAXBElement; import javax.xml.datatype.XMLGregorianCalendar; @@ -86,6 +87,7 @@ public ClientClassnameForMethod(Map conversions, EnunciateJaxbCo classConversions.put(javax.xml.datatype.Duration.class.getName(), "TimeSpan?"); classConversions.put(jakarta.xml.bind.JAXBElement.class.getName(), "object"); classConversions.put(Object.class.getName(), "object"); + classConversions.put(Record.class.getName(), "object"); } @Override @@ -124,7 +126,7 @@ else if (isCollection(declaration)) { if (adapterType != null) { return convert(adapterType.getAdaptingType()); } - if (declaration.getKind() == ElementKind.CLASS) { + if (ElementUtils.isClassOrRecord(declaration)) { DecoratedTypeMirror superType = (DecoratedTypeMirror) TypeMirrorDecorator.decorate(declaration.getSuperclass(), this.context.getProcessingEnvironment()); if (superType != null && superType.isInstanceOf(JAXBElement.class.getName())) { //for client conversions, we're going to generalize subclasses of JAXBElement to JAXBElement diff --git a/gwt-json-overlay/src/main/java/com/webcohesion/enunciate/modules/gwt_json_overlay/ClientClassnameForMethod.java b/gwt-json-overlay/src/main/java/com/webcohesion/enunciate/modules/gwt_json_overlay/ClientClassnameForMethod.java index 56b18ea1f..b4b7972e9 100644 --- a/gwt-json-overlay/src/main/java/com/webcohesion/enunciate/modules/gwt_json_overlay/ClientClassnameForMethod.java +++ b/gwt-json-overlay/src/main/java/com/webcohesion/enunciate/modules/gwt_json_overlay/ClientClassnameForMethod.java @@ -19,11 +19,11 @@ import com.webcohesion.enunciate.api.resources.Entity; import com.webcohesion.enunciate.api.resources.MediaTypeDescriptor; import com.webcohesion.enunciate.javac.decorations.TypeMirrorDecorator; +import com.webcohesion.enunciate.javac.decorations.element.ElementUtils; import com.webcohesion.enunciate.javac.decorations.type.DecoratedDeclaredType; import com.webcohesion.enunciate.javac.decorations.type.DecoratedTypeMirror; import com.webcohesion.enunciate.metadata.ClientName; import com.webcohesion.enunciate.metadata.qname.XmlQNameEnumRef; -import com.webcohesion.enunciate.modules.jackson.EnunciateJacksonContext; import com.webcohesion.enunciate.modules.jackson.api.impl.SyntaxImpl; import com.webcohesion.enunciate.util.HasClientConvertibleType; import freemarker.template.TemplateModelException; @@ -117,7 +117,7 @@ else if (isCollection(declaration)) { if (adaptingType != null) { return convert(adaptingType); } - if (declaration.getKind() == ElementKind.CLASS) { + if (ElementUtils.isClassOrRecord(declaration)) { DecoratedTypeMirror superType = (DecoratedTypeMirror) TypeMirrorDecorator.decorate(declaration.getSuperclass(), this.context.getProcessingEnvironment()); if (superType != null && superType.isInstanceOf(JAXBElement.class.getName())) { //for client conversions, we're going to generalize subclasses of JAXBElement to JAXBElement @@ -202,4 +202,4 @@ else if (decorated.isPrimitive()) { return super.convert(typeMirror); } -} \ No newline at end of file +} diff --git a/jackson/src/main/java/com/webcohesion/enunciate/modules/jackson/EnunciateJacksonContext.java b/jackson/src/main/java/com/webcohesion/enunciate/modules/jackson/EnunciateJacksonContext.java index c4e338b16..af1bf5044 100644 --- a/jackson/src/main/java/com/webcohesion/enunciate/modules/jackson/EnunciateJacksonContext.java +++ b/jackson/src/main/java/com/webcohesion/enunciate/modules/jackson/EnunciateJacksonContext.java @@ -35,7 +35,6 @@ import com.webcohesion.enunciate.metadata.rs.TypeHint; import com.webcohesion.enunciate.module.EnunciateModuleContext; import com.webcohesion.enunciate.modules.jackson.javac.InterfaceJacksonDeclaredType; -import com.webcohesion.enunciate.modules.jackson.javac.InterfaceJacksonTypeElement; import com.webcohesion.enunciate.modules.jackson.javac.ParameterizedJacksonDeclaredType; import com.webcohesion.enunciate.modules.jackson.javac.SyntheticJacksonArrayType; import com.webcohesion.enunciate.modules.jackson.model.*; @@ -226,7 +225,7 @@ protected Map loadKnownTypes() { knownTypes.put(java.net.URI.class.getName(), KnownJsonType.STRING); knownTypes.put(java.net.URL.class.getName(), KnownJsonType.STRING); knownTypes.put(java.lang.Object.class.getName(), KnownJsonType.OBJECT); - knownTypes.put(java.lang.Record.class.getName(), KnownJsonType.OBJECT); + knownTypes.put(Record.class.getName(), KnownJsonType.OBJECT); knownTypes.put(java.io.Serializable.class.getName(), KnownJsonType.OBJECT); knownTypes.put(byte[].class.getName(), KnownJsonType.STRING); knownTypes.put(java.nio.ByteBuffer.class.getName(), KnownJsonType.STRING); diff --git a/jackson/src/main/java/com/webcohesion/enunciate/modules/jackson/JacksonModule.java b/jackson/src/main/java/com/webcohesion/enunciate/modules/jackson/JacksonModule.java index 0fff3ec53..5e154beab 100644 --- a/jackson/src/main/java/com/webcohesion/enunciate/modules/jackson/JacksonModule.java +++ b/jackson/src/main/java/com/webcohesion/enunciate/modules/jackson/JacksonModule.java @@ -216,7 +216,7 @@ protected void addPotentialJacksonElement(Element declaration, LinkedList fieldElements = new ArrayList(ElementFilter.fieldsIn(clazz.getEnclosedElements())); + List fieldElements = ElementUtils.fieldsOrRecordComponentsIn(clazz); if (mixin != null) { //replace all mixin fields. - for (VariableElement mixinField : ElementFilter.fieldsIn(mixin.getEnclosedElements())) { + for (Element mixinField : ElementUtils.fieldsOrRecordComponentsIn(mixin)) { int index = indexOf(fieldElements, mixinField.getSimpleName().toString()); if (index >= 0) { fieldElements.set(index, mixinField); @@ -234,7 +234,7 @@ protected void aggregatePotentialAccessors(AccessorBag bag, DecoratedTypeElement } Set propsIgnore = new HashSet(); - for (VariableElement fieldDeclaration : fieldElements) { + for (Element fieldDeclaration : fieldElements) { JsonUnwrapped unwrapped = fieldDeclaration.getAnnotation(JsonUnwrapped.class); if (unwrapped != null && unwrapped.enabled()) { DecoratedTypeElement element; @@ -274,7 +274,7 @@ else if (!filter.accept((DecoratedElement) fieldDeclaration)) { } JacksonPropertySpec propertySpec = new JacksonPropertySpec(this.env); - List propertyElements = new ArrayList(clazz.getProperties(propertySpec)); + List propertyElements = new ArrayList<>(clazz.getProperties(propertySpec)); if (mixin != null) { //replace all mixin properties. for (PropertyElement mixinProperty : ((DecoratedTypeElement)mixin).getProperties(propertySpec)) { @@ -600,7 +600,7 @@ public List getAllAccessors() { static DeclaredType refineType(DecoratedProcessingEnvironment env, DecoratedElement element, Class annotation, Function> refiner) { Element elt = element; - while (elt != null && elt.getKind() != ElementKind.CLASS && elt.getKind() != ElementKind.INTERFACE) { + while (elt != null && elt.getKind() != ElementKind.CLASS && elt.getKind() != ElementKind.INTERFACE && elt.getKind() != ElementKind.RECORD) { elt = elt.getEnclosingElement(); } if (elt == null) { diff --git a/jackson/src/main/java/com/webcohesion/enunciate/modules/jackson/model/types/JsonTypeVisitor.java b/jackson/src/main/java/com/webcohesion/enunciate/modules/jackson/model/types/JsonTypeVisitor.java index b5ff497ba..9b43d70ac 100644 --- a/jackson/src/main/java/com/webcohesion/enunciate/modules/jackson/model/types/JsonTypeVisitor.java +++ b/jackson/src/main/java/com/webcohesion/enunciate/modules/jackson/model/types/JsonTypeVisitor.java @@ -120,9 +120,7 @@ public JsonType visitDeclared(DeclaredType declaredType, Context context) { } else { switch (declaredElement.getKind()) { - case ENUM: - case CLASS: - case INTERFACE: + case ENUM, CLASS, INTERFACE, RECORD -> { JsonType knownType = context.getContext().getKnownType(declaredElement); if (knownType != null) { jsonType = knownType; @@ -134,7 +132,7 @@ public JsonType visitDeclared(DeclaredType declaredType, Context context) { jsonType = new JsonClassType(typeDefinition); } } - break; + } } } } diff --git a/java-json-client/src/main/java/com/webcohesion/enunciate/modules/java_json_client/ClientClassnameForMethod.java b/java-json-client/src/main/java/com/webcohesion/enunciate/modules/java_json_client/ClientClassnameForMethod.java index dfacd5a44..b210da7ff 100644 --- a/java-json-client/src/main/java/com/webcohesion/enunciate/modules/java_json_client/ClientClassnameForMethod.java +++ b/java-json-client/src/main/java/com/webcohesion/enunciate/modules/java_json_client/ClientClassnameForMethod.java @@ -19,6 +19,7 @@ import com.webcohesion.enunciate.api.resources.Entity; import com.webcohesion.enunciate.api.resources.MediaTypeDescriptor; import com.webcohesion.enunciate.javac.decorations.TypeMirrorDecorator; +import com.webcohesion.enunciate.javac.decorations.element.ElementUtils; import com.webcohesion.enunciate.javac.decorations.type.DecoratedTypeMirror; import com.webcohesion.enunciate.metadata.ClientName; import com.webcohesion.enunciate.metadata.qname.XmlQNameEnumRef; @@ -94,7 +95,7 @@ public String convert(TypeElement declaration) throws TemplateModelException { if (adaptingType != null) { return convert(adaptingType); } - if (declaration.getKind() == ElementKind.CLASS) { + if (ElementUtils.isClassOrRecord(declaration)) { DecoratedTypeMirror superType = (DecoratedTypeMirror) TypeMirrorDecorator.decorate(declaration.getSuperclass(), this.context.getProcessingEnvironment()); if (superType != null && superType.isInstanceOf(JAXBElement.class.getName())) { //for client conversions, we're going to generalize subclasses of JAXBElement to JAXBElement diff --git a/java-xml-client/src/main/java/com/webcohesion/enunciate/modules/java_xml_client/ClientClassnameForMethod.java b/java-xml-client/src/main/java/com/webcohesion/enunciate/modules/java_xml_client/ClientClassnameForMethod.java index 21c9256d2..08e853ced 100644 --- a/java-xml-client/src/main/java/com/webcohesion/enunciate/modules/java_xml_client/ClientClassnameForMethod.java +++ b/java-xml-client/src/main/java/com/webcohesion/enunciate/modules/java_xml_client/ClientClassnameForMethod.java @@ -19,6 +19,7 @@ import com.webcohesion.enunciate.api.resources.Entity; import com.webcohesion.enunciate.api.resources.MediaTypeDescriptor; import com.webcohesion.enunciate.javac.decorations.TypeMirrorDecorator; +import com.webcohesion.enunciate.javac.decorations.element.ElementUtils; import com.webcohesion.enunciate.javac.decorations.type.DecoratedTypeMirror; import com.webcohesion.enunciate.metadata.ClientName; import com.webcohesion.enunciate.modules.jaxb.EnunciateJaxbContext; @@ -110,7 +111,7 @@ public String convert(TypeElement declaration) throws TemplateModelException { if (adapterType != null) { return convert(adapterType.getAdaptingType()); } - if (declaration.getKind() == ElementKind.CLASS) { + if (ElementUtils.isClassOrRecord(declaration)) { DecoratedTypeMirror superType = (DecoratedTypeMirror) TypeMirrorDecorator.decorate(declaration.getSuperclass(), this.context.getProcessingEnvironment()); if (superType != null && superType.isInstanceOf(JAXBElement.class.getName())) { //for client conversions, we're going to generalize subclasses of JAXBElement to JAXBElement diff --git a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/DecoratedElements.java b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/DecoratedElements.java index e44982a13..351e69951 100644 --- a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/DecoratedElements.java +++ b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/DecoratedElements.java @@ -22,10 +22,13 @@ import com.webcohesion.enunciate.javac.decorations.element.DecoratedElement; import com.webcohesion.enunciate.javac.decorations.element.DecoratedExecutableElement; import com.webcohesion.enunciate.javac.decorations.element.DecoratedTypeElement; +import com.webcohesion.enunciate.javac.javadoc.JavaDoc; +import com.webcohesion.enunciate.javac.javadoc.ParamDocComment; import javax.lang.model.element.*; import javax.lang.model.util.Elements; import java.io.Writer; +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -70,6 +73,12 @@ public String getDocComment(Element e) { e = ((DecoratedElement) e).getDelegate(); } + String recordComponentName = null; + if (e.getKind() == ElementKind.RECORD_COMPONENT) { + recordComponentName = e.getSimpleName().toString(); + e = e.getEnclosingElement(); + } + String docComment; if (e instanceof ElementAdaptor) { docComment = ((ElementAdaptor) e).getDocComment(); @@ -78,6 +87,12 @@ public String getDocComment(Element e) { docComment = delegate.getDocComment(e); } + if (recordComponentName != null) { + JavaDoc recordDoc = new JavaDoc(docComment, null, null, this.env); + HashMap params = ParamDocComment.loadParamsComments("param", recordDoc); + docComment = params.get(recordComponentName); + } + return docComment; } diff --git a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/element/DecoratedTypeElement.java b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/element/DecoratedTypeElement.java index 0875b4f52..83e6b83f3 100644 --- a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/element/DecoratedTypeElement.java +++ b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/element/DecoratedTypeElement.java @@ -151,7 +151,7 @@ public List enumValues() { public A getAnnotation(Class annotationType) { A annotation = super.getAnnotation(annotationType); - if (isClass() && (annotation == null) && (annotationType.getAnnotation(Inherited.class) != null) && (getSuperclass() instanceof DeclaredType)) { + if (ElementUtils.isClassOrRecord(this) && annotation == null && (annotationType.getAnnotation(Inherited.class) != null) && (getSuperclass() instanceof DeclaredType)) { TypeElement superDecl = (TypeElement) ((DeclaredType) getSuperclass()).asElement(); if ((superDecl != null) && (!Object.class.getName().equals(superDecl.getQualifiedName().toString()))) { return superDecl.getAnnotation(annotationType); @@ -213,10 +213,6 @@ protected List loadEnumConstants() { return constants; } - public boolean isClass() { - return getKind() == ElementKind.CLASS; - } - public boolean isInterface() { return getKind() == ElementKind.INTERFACE; } diff --git a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/element/ElementUtils.java b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/element/ElementUtils.java index 37043edca..85c5b4062 100644 --- a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/element/ElementUtils.java +++ b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/element/ElementUtils.java @@ -19,10 +19,14 @@ import com.webcohesion.enunciate.javac.javadoc.JavaDoc; import com.webcohesion.enunciate.javac.javadoc.JavaDocTagHandler; +import javax.lang.model.element.Element; +import javax.lang.model.element.ElementKind; import javax.lang.model.element.TypeElement; import javax.lang.model.element.VariableElement; import javax.lang.model.type.DeclaredType; import javax.lang.model.type.TypeMirror; +import javax.lang.model.util.ElementFilter; +import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.Map; @@ -131,6 +135,37 @@ public static String capitalize(String string) { return Character.toUpperCase(string.charAt(0)) + string.substring(1); } + /** + * Check if the element is a class or record. + * + * @param element the element to test + * @return true if it's a class or record + */ + public static boolean isClassOrRecord(Element element) { + return element.getKind() == ElementKind.CLASS || element.getKind() == ElementKind.RECORD; + } + + /** + * Get all fields in the class. If it is a java.lang.Record then get all the record components. + * + * @param clazz the element to inspect + * @return a list of elements + */ + public static List fieldsOrRecordComponentsIn(TypeElement clazz) { + if (clazz.getKind() == ElementKind.RECORD) { + List elements = new ArrayList<>(); + for (Element element : clazz.getEnclosedElements()) { + if (element.getKind() == ElementKind.RECORD_COMPONENT) { + elements.add(element); + } + } + return elements; + } + else { + return new ArrayList<>(ElementFilter.fieldsIn(clazz.getEnclosedElements())); + } + } + public static class DefaultPropertySpec implements PropertySpec { protected final DecoratedProcessingEnvironment env; diff --git a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/type/DecoratedTypeMirror.java b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/type/DecoratedTypeMirror.java index 71c6c1bb1..ae35dd092 100644 --- a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/type/DecoratedTypeMirror.java +++ b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/type/DecoratedTypeMirror.java @@ -18,6 +18,7 @@ import com.webcohesion.enunciate.javac.decorations.DecoratedProcessingEnvironment; import com.webcohesion.enunciate.javac.decorations.ElementDecorator; import com.webcohesion.enunciate.javac.decorations.TypeMirrorDecoration; +import com.webcohesion.enunciate.javac.decorations.element.ElementUtils; import com.webcohesion.enunciate.javac.javadoc.DefaultJavaDocTagHandler; import com.webcohesion.enunciate.javac.javadoc.DocComment; import com.webcohesion.enunciate.javac.javadoc.JavaDocTagHandler; @@ -143,7 +144,12 @@ public boolean isReferenceType() { return false; } public boolean isClass() { - return isDeclared() && ((DeclaredType)this.delegate).asElement().getKind() == ElementKind.CLASS; + return isDeclared() && isClassOrRecord(); + } + + private boolean isClassOrRecord() { + Element element = ((DeclaredType) this.delegate).asElement(); + return ElementUtils.isClassOrRecord(element); } public boolean isDeclared() { diff --git a/javac-support/src/main/java/com/webcohesion/enunciate/javac/javadoc/ParamDocComment.java b/javac-support/src/main/java/com/webcohesion/enunciate/javac/javadoc/ParamDocComment.java index 16a873452..79981a366 100644 --- a/javac-support/src/main/java/com/webcohesion/enunciate/javac/javadoc/ParamDocComment.java +++ b/javac-support/src/main/java/com/webcohesion/enunciate/javac/javadoc/ParamDocComment.java @@ -42,7 +42,7 @@ protected HashMap loadParamsComments(JavaDoc javaDoc) { return loadParamsComments("param", javaDoc); } - protected HashMap loadParamsComments(String tagName, JavaDoc jd) { + public static HashMap loadParamsComments(String tagName, JavaDoc jd) { HashMap paramComments = new HashMap(); if (jd.get(tagName) != null) { for (String paramDoc : jd.get(tagName)) { diff --git a/javascript-client/src/main/java/com/webcohesion/enunciate/modules/javascript_client/ClientClassnameForMethod.java b/javascript-client/src/main/java/com/webcohesion/enunciate/modules/javascript_client/ClientClassnameForMethod.java index 5c77fc178..b46f1d145 100644 --- a/javascript-client/src/main/java/com/webcohesion/enunciate/modules/javascript_client/ClientClassnameForMethod.java +++ b/javascript-client/src/main/java/com/webcohesion/enunciate/modules/javascript_client/ClientClassnameForMethod.java @@ -84,6 +84,7 @@ public ClientClassnameForMethod(Map conversions, EnunciateJackso classConversions.put(javax.xml.datatype.Duration.class.getName(), "String"); classConversions.put(jakarta.xml.bind.JAXBElement.class.getName(), "Object"); classConversions.put(Object.class.getName(), "Object"); + classConversions.put(Record.class.getName(), "Object"); } @Override @@ -200,4 +201,4 @@ protected String getPackageSeparator() { return "."; } -} \ No newline at end of file +} diff --git a/jaxb/src/main/java/com/webcohesion/enunciate/modules/jaxb/EnunciateJaxbContext.java b/jaxb/src/main/java/com/webcohesion/enunciate/modules/jaxb/EnunciateJaxbContext.java index f9ceb0b50..ac20d62aa 100644 --- a/jaxb/src/main/java/com/webcohesion/enunciate/modules/jaxb/EnunciateJaxbContext.java +++ b/jaxb/src/main/java/com/webcohesion/enunciate/modules/jaxb/EnunciateJaxbContext.java @@ -19,6 +19,7 @@ import com.webcohesion.enunciate.EnunciateContext; import com.webcohesion.enunciate.EnunciateException; import com.webcohesion.enunciate.javac.decorations.element.DecoratedTypeElement; +import com.webcohesion.enunciate.javac.decorations.element.ElementUtils; import com.webcohesion.enunciate.javac.decorations.type.DecoratedDeclaredType; import com.webcohesion.enunciate.javac.decorations.type.DecoratedTypeMirror; import com.webcohesion.enunciate.metadata.qname.XmlQNameEnum; @@ -191,7 +192,7 @@ protected Map loadKnownTypes() { knownTypes.put(java.net.URI.class.getName(), KnownXmlType.STRING); knownTypes.put(javax.xml.datatype.Duration.class.getName(), KnownXmlType.DURATION); knownTypes.put(java.lang.Object.class.getName(), KnownXmlType.ANY_TYPE); - knownTypes.put(java.lang.Record.class.getName(), KnownXmlType.ANY_TYPE); + knownTypes.put(Record.class.getName(), KnownXmlType.ANY_TYPE); knownTypes.put(java.io.Serializable.class.getName(), KnownXmlType.ANY_TYPE); knownTypes.put(byte[].class.getName(), KnownXmlType.BASE64_BINARY); knownTypes.put(java.nio.ByteBuffer.class.getName(), KnownXmlType.BASE64_BINARY); @@ -473,7 +474,7 @@ protected void add(LocalElementDeclaration led, LinkedList stack) { protected void addReferencedTypeDefinitions(LocalElementDeclaration led, LinkedList stack) { addSeeAlsoTypeDefinitions(led, stack); DecoratedTypeElement scope = led.getElementScope(); - if (scope != null && scope.getKind() == ElementKind.CLASS && !isKnownTypeDefinition(scope)) { + if (scope != null && ElementUtils.isClassOrRecord(scope) && !isKnownTypeDefinition(scope)) { add(createTypeDefinition(scope), stack); } TypeElement typeElement = null; @@ -485,7 +486,7 @@ protected void addReferencedTypeDefinitions(LocalElementDeclaration led, LinkedL } } - if (scope != null && scope.getKind() == ElementKind.CLASS && !isKnownTypeDefinition(typeElement)) { + if (scope != null && ElementUtils.isClassOrRecord(scope) && !isKnownTypeDefinition(typeElement)) { add(createTypeDefinition(typeElement), stack); } } diff --git a/jaxb/src/main/java/com/webcohesion/enunciate/modules/jaxb/JaxbModule.java b/jaxb/src/main/java/com/webcohesion/enunciate/modules/jaxb/JaxbModule.java index d0712eb0b..f9057f63e 100644 --- a/jaxb/src/main/java/com/webcohesion/enunciate/modules/jaxb/JaxbModule.java +++ b/jaxb/src/main/java/com/webcohesion/enunciate/modules/jaxb/JaxbModule.java @@ -160,7 +160,7 @@ else if (!this.jaxbContext.isKnownTypeDefinition((TypeElement) declaration) && i } protected boolean isExplicitTypeDefinition(Element declaration) { - if (declaration.getKind() != ElementKind.CLASS && declaration.getKind() != ElementKind.ENUM) { + if (declaration.getKind() != ElementKind.CLASS && declaration.getKind() != ElementKind.ENUM && !(declaration.getKind() == ElementKind.RECORD)) { debug("%s isn't a potential JAXB type because it's not a class or an enum.", declaration); return false; } diff --git a/jaxb/src/main/java/com/webcohesion/enunciate/modules/jaxb/model/Accessor.java b/jaxb/src/main/java/com/webcohesion/enunciate/modules/jaxb/model/Accessor.java index 626456eae..2bf5dc676 100644 --- a/jaxb/src/main/java/com/webcohesion/enunciate/modules/jaxb/model/Accessor.java +++ b/jaxb/src/main/java/com/webcohesion/enunciate/modules/jaxb/model/Accessor.java @@ -21,6 +21,7 @@ import com.webcohesion.enunciate.javac.decorations.TypeMirrorDecorator; import com.webcohesion.enunciate.javac.decorations.element.DecoratedElement; import com.webcohesion.enunciate.javac.decorations.element.DecoratedTypeElement; +import com.webcohesion.enunciate.javac.decorations.element.ElementUtils; import com.webcohesion.enunciate.javac.decorations.element.PropertyElement; import com.webcohesion.enunciate.javac.decorations.type.DecoratedDeclaredType; import com.webcohesion.enunciate.javac.decorations.type.DecoratedTypeMirror; @@ -40,13 +41,10 @@ import jakarta.activation.DataHandler; import javax.lang.model.element.Element; -import javax.lang.model.element.VariableElement; import javax.lang.model.type.*; -import javax.lang.model.util.ElementFilter; import jakarta.xml.bind.annotation.*; import javax.xml.namespace.QName; import java.util.*; -import java.util.concurrent.Callable; /** * An accessor for a field or method value into a type. @@ -380,7 +378,7 @@ private DecoratedElement getXmlIDAccessor(DecoratedDeclaredType classType) { return null; } - for (VariableElement field : ElementFilter.fieldsIn(declaration.getEnclosedElements())) { + for (Element field : ElementUtils.fieldsOrRecordComponentsIn(declaration)) { if (field.getAnnotation(XmlID.class) != null) { return (DecoratedElement) field; } diff --git a/jaxb/src/main/java/com/webcohesion/enunciate/modules/jaxb/model/TypeDefinition.java b/jaxb/src/main/java/com/webcohesion/enunciate/modules/jaxb/model/TypeDefinition.java index c91a42e7d..b11c28c14 100644 --- a/jaxb/src/main/java/com/webcohesion/enunciate/modules/jaxb/model/TypeDefinition.java +++ b/jaxb/src/main/java/com/webcohesion/enunciate/modules/jaxb/model/TypeDefinition.java @@ -23,6 +23,7 @@ import com.webcohesion.enunciate.javac.decorations.element.DecoratedElement; import com.webcohesion.enunciate.javac.decorations.element.DecoratedExecutableElement; import com.webcohesion.enunciate.javac.decorations.element.DecoratedTypeElement; +import com.webcohesion.enunciate.javac.decorations.element.ElementUtils; import com.webcohesion.enunciate.javac.decorations.element.PropertyElement; import com.webcohesion.enunciate.metadata.ClientName; import com.webcohesion.enunciate.metadata.qname.XmlQNameEnumRef; @@ -32,16 +33,15 @@ import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.TypeElement; -import javax.lang.model.element.VariableElement; import javax.lang.model.type.MirroredTypesException; import javax.lang.model.type.TypeKind; import javax.lang.model.type.TypeMirror; import javax.lang.model.util.ElementFilter; + import jakarta.xml.bind.annotation.*; import javax.xml.namespace.QName; import java.beans.Introspector; import java.util.*; -import java.util.concurrent.Callable; /** * A xml type definition. @@ -200,7 +200,7 @@ protected void aggregatePotentialAccessors(AccessorBag bag, DecoratedTypeElement aggregatePotentialAccessors(bag, superDeclaration, filter, true); } - for (VariableElement fieldDeclaration : ElementFilter.fieldsIn(clazz.getEnclosedElements())) { + for (javax.lang.model.element.Element fieldDeclaration : ElementUtils.fieldsOrRecordComponentsIn(clazz)) { if (!filter.accept((DecoratedElement) fieldDeclaration)) { bag.fields.removeByName(fieldDeclaration); } diff --git a/jaxb/src/main/java/com/webcohesion/enunciate/modules/jaxb/model/types/XmlTypeVisitor.java b/jaxb/src/main/java/com/webcohesion/enunciate/modules/jaxb/model/types/XmlTypeVisitor.java index af5ff28d4..b4832045f 100644 --- a/jaxb/src/main/java/com/webcohesion/enunciate/modules/jaxb/model/types/XmlTypeVisitor.java +++ b/jaxb/src/main/java/com/webcohesion/enunciate/modules/jaxb/model/types/XmlTypeVisitor.java @@ -74,8 +74,7 @@ public XmlType visitDeclared(DeclaredType declaredType, Context context) { } else { switch (declaredElement.getKind()) { - case ENUM: - case CLASS: + case CLASS, ENUM, RECORD -> { XmlType knownType = context.getContext().getKnownType(declaredElement); if (knownType != null) { return knownType; @@ -87,7 +86,7 @@ public XmlType visitDeclared(DeclaredType declaredType, Context context) { return new XmlClassType(typeDefinition); } } - break; + } } } } diff --git a/jaxrs/src/main/java/com/webcohesion/enunciate/modules/jaxrs/model/Resource.java b/jaxrs/src/main/java/com/webcohesion/enunciate/modules/jaxrs/model/Resource.java index e0d918e3f..fa4bc4857 100644 --- a/jaxrs/src/main/java/com/webcohesion/enunciate/modules/jaxrs/model/Resource.java +++ b/jaxrs/src/main/java/com/webcohesion/enunciate/modules/jaxrs/model/Resource.java @@ -18,6 +18,7 @@ import com.webcohesion.enunciate.facets.Facet; import com.webcohesion.enunciate.facets.HasFacets; import com.webcohesion.enunciate.javac.decorations.element.DecoratedTypeElement; +import com.webcohesion.enunciate.javac.decorations.element.ElementUtils; import com.webcohesion.enunciate.javac.decorations.element.PropertyElement; import com.webcohesion.enunciate.javac.decorations.type.TypeVariableContext; import com.webcohesion.enunciate.modules.jaxrs.EnunciateJaxrsContext; @@ -119,7 +120,8 @@ protected List getSubresourceLocators(TypeElement delegate, } } - if (delegate.getKind() == ElementKind.CLASS) { + + if (ElementUtils.isClassOrRecord(delegate)) { TypeMirror superclass = delegate.getSuperclass(); if (superclass instanceof DeclaredType && ((DeclaredType)superclass).asElement() != null) { List superMethods = getSubresourceLocators((TypeElement) ((DeclaredType) superclass).asElement(), variableContext, context); @@ -179,7 +181,7 @@ protected List getResourceMethods(final TypeElement delegate, Ty } } - if (delegate.getKind() == ElementKind.CLASS) { + if (ElementUtils.isClassOrRecord(delegate)) { TypeMirror superclass = delegate.getSuperclass(); if (superclass instanceof DeclaredType && ((DeclaredType)superclass).asElement() != null) { DeclaredType declared = (DeclaredType) superclass; @@ -209,7 +211,7 @@ protected Set getResourceParameters(TypeElement delegate, Enu } Set resourceParameters = new TreeSet(); - for (VariableElement field : ElementFilter.fieldsIn(delegate.getEnclosedElements())) { + for (Element field : ElementUtils.fieldsOrRecordComponentsIn(delegate)) { if (ResourceParameter.isResourceParameter(field, this.context)) { resourceParameters.add(new ResourceParameter(field, this)); } @@ -221,7 +223,7 @@ protected Set getResourceParameters(TypeElement delegate, Enu } } - if (delegate.getKind() == ElementKind.CLASS && delegate.getSuperclass() instanceof DeclaredType) { + if (ElementUtils.isClassOrRecord(delegate) && delegate.getSuperclass() instanceof DeclaredType) { Set superParams = getResourceParameters((TypeElement) ((DeclaredType) delegate.getSuperclass()).asElement(), context); for (ResourceParameter superParam : superParams) { if (!isHidden(superParam, resourceParameters)) { diff --git a/jaxrs/src/main/java/com/webcohesion/enunciate/modules/jaxrs/model/ResourceParameter.java b/jaxrs/src/main/java/com/webcohesion/enunciate/modules/jaxrs/model/ResourceParameter.java index 870fc90fc..63a5a39c9 100644 --- a/jaxrs/src/main/java/com/webcohesion/enunciate/modules/jaxrs/model/ResourceParameter.java +++ b/jaxrs/src/main/java/com/webcohesion/enunciate/modules/jaxrs/model/ResourceParameter.java @@ -31,7 +31,6 @@ import javax.lang.model.element.*; import javax.lang.model.type.DeclaredType; import javax.lang.model.type.TypeMirror; -import javax.lang.model.util.ElementFilter; import java.util.*; @@ -246,7 +245,7 @@ public static List getFormBeanParameters(VariableElement para private static void gatherFormBeanParameters(TypeMirror type, ArrayList beanParams, PathContext context) { if (type instanceof DeclaredType) { DecoratedTypeElement typeDeclaration = (DecoratedTypeElement) ElementDecorator.decorate(((DeclaredType) type).asElement(), context.getContext().getContext().getProcessingEnvironment()); - for (VariableElement field : ElementFilter.fieldsIn(typeDeclaration.getEnclosedElements())) { + for (Element field : ElementUtils.fieldsOrRecordComponentsIn(typeDeclaration)) { if (isResourceParameter(field, context.getContext())) { beanParams.add(new ResourceParameter(field, context)); } @@ -265,7 +264,7 @@ else if (isBeanParameter(property)) { } } - if (typeDeclaration.getKind() == ElementKind.CLASS) { + if (ElementUtils.isClassOrRecord(typeDeclaration)) { gatherFormBeanParameters(typeDeclaration.getSuperclass(), beanParams, context); } } diff --git a/jaxrs/src/main/java/com/webcohesion/enunciate/modules/jaxrs/model/util/RSParamDocComment.java b/jaxrs/src/main/java/com/webcohesion/enunciate/modules/jaxrs/model/util/RSParamDocComment.java index 438f24ea9..e2f578150 100644 --- a/jaxrs/src/main/java/com/webcohesion/enunciate/modules/jaxrs/model/util/RSParamDocComment.java +++ b/jaxrs/src/main/java/com/webcohesion/enunciate/modules/jaxrs/model/util/RSParamDocComment.java @@ -17,7 +17,7 @@ public RSParamDocComment(DecoratedExecutableElement executableElement, String pa @Override protected HashMap loadParamsComments(JavaDoc javaDoc) { - HashMap paramComments = super.loadParamsComments("RSParam", javaDoc); + HashMap paramComments = ParamDocComment.loadParamsComments("RSParam", javaDoc); paramComments.putAll(super.loadParamsComments(javaDoc)); return paramComments; } diff --git a/jaxws/src/main/java/com/webcohesion/enunciate/modules/jaxws/model/EndpointInterface.java b/jaxws/src/main/java/com/webcohesion/enunciate/modules/jaxws/model/EndpointInterface.java index 0e6cb2014..5fca584a7 100644 --- a/jaxws/src/main/java/com/webcohesion/enunciate/modules/jaxws/model/EndpointInterface.java +++ b/jaxws/src/main/java/com/webcohesion/enunciate/modules/jaxws/model/EndpointInterface.java @@ -20,6 +20,7 @@ import com.webcohesion.enunciate.facets.HasFacets; import com.webcohesion.enunciate.javac.TypeElementComparator; import com.webcohesion.enunciate.javac.decorations.element.DecoratedTypeElement; +import com.webcohesion.enunciate.javac.decorations.element.ElementUtils; import com.webcohesion.enunciate.javac.decorations.type.TypeVariableContext; import com.webcohesion.enunciate.metadata.ClientName; import com.webcohesion.enunciate.metadata.soap.SoapBindingName; @@ -76,7 +77,7 @@ public EndpointInterface(TypeElement delegate, Set implementa annotation = getAnnotation(jakarta.jws.WebService.class); impls = new ArrayList(); if (annotation != null) { - if (isClass()) { + if (ElementUtils.isClassOrRecord(this)) { //if the declaration is a class, the endpoint interface is implied... impls.add(new EndpointImplementation(getDelegate(), this, context)); } @@ -105,7 +106,7 @@ public EndpointInterface(TypeElement delegate, Set implementa } } - if (delegate.getKind() == ElementKind.CLASS) { + if (ElementUtils.isClassOrRecord(delegate)) { //the spec says we need to consider superclass methods, too... TypeMirror superclass = delegate.getSuperclass(); if (superclass instanceof DeclaredType) { @@ -310,7 +311,7 @@ public Collection getEndpointImplementations() { * A quick check to see if a declaration is an endpoint implementation. */ protected boolean isEndpointImplementation(TypeElement declaration) { - if (declaration.getKind() == ElementKind.CLASS && !declaration.getQualifiedName().equals(getQualifiedName())) { + if (ElementUtils.isClassOrRecord(declaration) && !declaration.getQualifiedName().equals(getQualifiedName())) { WebService webServiceInfo = declaration.getAnnotation(WebService.class); return webServiceInfo != null && getQualifiedName().toString().equals(webServiceInfo.endpointInterface()); } diff --git a/obj-c-xml-client/src/main/java/com/webcohesion/enunciate/modules/objc_client/ClientClassnameForMethod.java b/obj-c-xml-client/src/main/java/com/webcohesion/enunciate/modules/objc_client/ClientClassnameForMethod.java index 2a3d68292..fa19f5f7a 100644 --- a/obj-c-xml-client/src/main/java/com/webcohesion/enunciate/modules/objc_client/ClientClassnameForMethod.java +++ b/obj-c-xml-client/src/main/java/com/webcohesion/enunciate/modules/objc_client/ClientClassnameForMethod.java @@ -16,6 +16,7 @@ package com.webcohesion.enunciate.modules.objc_client; import com.webcohesion.enunciate.javac.decorations.TypeMirrorDecorator; +import com.webcohesion.enunciate.javac.decorations.element.ElementUtils; import com.webcohesion.enunciate.metadata.ClientName; import com.webcohesion.enunciate.modules.jaxb.EnunciateJaxbContext; import com.webcohesion.enunciate.modules.jaxb.model.Accessor; @@ -27,7 +28,7 @@ import com.webcohesion.enunciate.javac.decorations.type.DecoratedTypeMirror; import jakarta.activation.DataHandler; -import javax.lang.model.element.ElementKind; + import javax.lang.model.element.TypeElement; import javax.lang.model.type.*; import jakarta.xml.bind.JAXBElement; @@ -95,7 +96,7 @@ else if (isCollection(declaration)) { if (adapterType != null) { return convert(adapterType.getAdaptingType()); } - if (declaration.getKind() == ElementKind.CLASS) { + if (ElementUtils.isClassOrRecord(declaration)) { DecoratedTypeMirror superType = (DecoratedTypeMirror) TypeMirrorDecorator.decorate(declaration.getSuperclass(), this.context.getProcessingEnvironment()); if (superType != null && superType.isInstanceOf(JAXBElement.class.getName())) { //for client conversions, we're going to generalize subclasses of JAXBElement to JAXBElement @@ -191,4 +192,4 @@ public String convert(TypeVariable typeVariable) throws TemplateModelException { return conversion; } -} \ No newline at end of file +} diff --git a/spring-web/src/main/java/com/webcohesion/enunciate/modules/spring_web/model/RequestParameterFactory.java b/spring-web/src/main/java/com/webcohesion/enunciate/modules/spring_web/model/RequestParameterFactory.java index 96875d8a9..7e063cd86 100644 --- a/spring-web/src/main/java/com/webcohesion/enunciate/modules/spring_web/model/RequestParameterFactory.java +++ b/spring-web/src/main/java/com/webcohesion/enunciate/modules/spring_web/model/RequestParameterFactory.java @@ -20,6 +20,7 @@ import com.webcohesion.enunciate.javac.decorations.TypeMirrorDecorator; import com.webcohesion.enunciate.javac.decorations.element.DecoratedTypeElement; import com.webcohesion.enunciate.javac.decorations.element.DecoratedVariableElement; +import com.webcohesion.enunciate.javac.decorations.element.ElementUtils; import com.webcohesion.enunciate.javac.decorations.element.PropertyElement; import com.webcohesion.enunciate.javac.decorations.type.DecoratedTypeMirror; import com.webcohesion.enunciate.javac.decorations.type.TypeVariableContext; @@ -31,7 +32,6 @@ import javax.lang.model.type.TypeKind; import javax.lang.model.type.TypeMirror; import javax.lang.model.type.TypeVariable; -import javax.lang.model.util.ElementFilter; import java.util.*; /** @@ -183,7 +183,7 @@ private static void gatherFormObjectParameters(TypeMirror type, ArrayList methods = context.getHttpMethods(); ResourceParameterType defaultType = methods.contains("POST") ? ResourceParameterType.FORM : ResourceParameterType.QUERY; DecoratedTypeElement typeDeclaration = (DecoratedTypeElement) ElementDecorator.decorate(((DeclaredType) type).asElement(), context.getContext().getContext().getProcessingEnvironment()); - for (VariableElement field : ElementFilter.fieldsIn(typeDeclaration.getEnclosedElements())) { + for (Element field : ElementUtils.fieldsOrRecordComponentsIn(typeDeclaration)) { DecoratedVariableElement decorated = (DecoratedVariableElement) field; if (!decorated.isFinal() && !decorated.isTransient() && decorated.isPublic()) { params.add(new SimpleRequestParameter(decorated, context, defaultType)); @@ -196,7 +196,7 @@ private static void gatherFormObjectParameters(TypeMirror type, ArrayList getRequestMappings(final TypeElement delegate, Ty } } - if (delegate.getKind() == ElementKind.CLASS) { + if (ElementUtils.isClassOrRecord(delegate)) { TypeMirror superclass = delegate.getSuperclass(); if (superclass instanceof DeclaredType && ((DeclaredType) superclass).asElement() != null) { DeclaredType declared = (DeclaredType) superclass; diff --git a/spring-web/src/main/java/com/webcohesion/enunciate/modules/spring_web/model/SpringControllerAdvice.java b/spring-web/src/main/java/com/webcohesion/enunciate/modules/spring_web/model/SpringControllerAdvice.java index 50a669edb..8778ad550 100644 --- a/spring-web/src/main/java/com/webcohesion/enunciate/modules/spring_web/model/SpringControllerAdvice.java +++ b/spring-web/src/main/java/com/webcohesion/enunciate/modules/spring_web/model/SpringControllerAdvice.java @@ -16,6 +16,7 @@ package com.webcohesion.enunciate.modules.spring_web.model; import com.webcohesion.enunciate.javac.decorations.element.DecoratedTypeElement; +import com.webcohesion.enunciate.javac.decorations.element.ElementUtils; import com.webcohesion.enunciate.javac.decorations.type.TypeVariableContext; import com.webcohesion.enunciate.modules.spring_web.EnunciateSpringWebContext; import org.springframework.web.bind.annotation.ControllerAdvice; @@ -187,7 +188,7 @@ protected List findRequestMappingAdvice(RequestMapping req } } - if (controllerAdvice.getKind() == ElementKind.CLASS) { + if (ElementUtils.isClassOrRecord(controllerAdvice)) { TypeMirror superclass = controllerAdvice.getSuperclass(); if (superclass instanceof DeclaredType && ((DeclaredType)superclass).asElement() != null) { DeclaredType declared = (DeclaredType) superclass;