55import java .lang .annotation .Annotation ;
66import java .nio .file .Files ;
77import java .nio .file .Path ;
8- import java .util .Arrays ;
9- import java .util .Collections ;
108import java .util .List ;
119import java .util .stream .Stream ;
1210
6765
6866class JaxbProcessor {
6967
70- private static final List <Class <? extends Annotation >> JAXB_ANNOTATIONS = Arrays . asList (
68+ private static final List <Class <? extends Annotation >> JAXB_ANNOTATIONS = List . of (
7169 XmlAccessorType .class ,
7270 XmlAnyAttribute .class ,
7371 XmlAnyElement .class ,
@@ -100,7 +98,7 @@ class JaxbProcessor {
10098 XmlJavaTypeAdapter .class ,
10199 XmlJavaTypeAdapters .class );
102100
103- private static final List <Class <?>> JAXB_REFLECTIVE_CLASSES = Collections . singletonList (XmlAccessOrder .class );
101+ private static final List <Class <?>> JAXB_REFLECTIVE_CLASSES = List . of (XmlAccessOrder .class );
104102
105103 private static final DotName XML_ROOT_ELEMENT = DotName .createSimple (XmlRootElement .class .getName ());
106104 private static final DotName XML_TYPE = DotName .createSimple (XmlType .class .getName ());
@@ -110,10 +108,60 @@ class JaxbProcessor {
110108 private static final DotName XML_ANY_ELEMENT = DotName .createSimple (XmlAnyElement .class .getName ());
111109 private static final DotName XML_SEE_ALSO = DotName .createSimple (XmlSeeAlso .class .getName ());
112110
113- private static final List <DotName > JAXB_ROOT_ANNOTATIONS = Arrays .asList (XML_ROOT_ELEMENT , XML_TYPE , XML_REGISTRY );
114-
115- private static final List <DotName > IGNORE_TYPES = Collections
116- .singletonList (DotName .createSimple ("javax.xml.datatype.XMLGregorianCalendar" ));
111+ private static final List <DotName > JAXB_ROOT_ANNOTATIONS = List .of (XML_ROOT_ELEMENT , XML_TYPE , XML_REGISTRY );
112+
113+ private static final List <DotName > IGNORE_TYPES = List .of (DotName .createSimple ("javax.xml.datatype.XMLGregorianCalendar" ));
114+
115+ private static final List <String > NATIVE_PROXY_DEFINITIONS = List .of (
116+ "com.sun.xml.bind.marshaller.CharacterEscapeHandler" ,
117+ "com.sun.xml.txw2.output.CharacterEscapeHandler" ,
118+ "com.sun.xml.bind.v2.schemagen.episode.Bindings" ,
119+ "com.sun.xml.bind.v2.schemagen.episode.SchemaBindings" ,
120+ "com.sun.xml.bind.v2.schemagen.episode.Klass" ,
121+ "com.sun.xml.bind.v2.schemagen.episode.Package" ,
122+ "com.sun.xml.bind.v2.schemagen.xmlschema.Annotated" ,
123+ "com.sun.xml.bind.v2.schemagen.xmlschema.Annotation" ,
124+ "com.sun.xml.bind.v2.schemagen.xmlschema.Any" ,
125+ "com.sun.xml.bind.v2.schemagen.xmlschema.Appinfo" ,
126+ "com.sun.xml.bind.v2.schemagen.xmlschema.AttrDecls" ,
127+ "com.sun.xml.bind.v2.schemagen.xmlschema.AttributeType" ,
128+ "com.sun.xml.bind.v2.schemagen.xmlschema.ComplexContent" ,
129+ "com.sun.xml.bind.v2.schemagen.xmlschema.ComplexExtension" ,
130+ "com.sun.xml.bind.v2.schemagen.xmlschema.ComplexRestriction" ,
131+ "com.sun.xml.bind.v2.schemagen.xmlschema.ComplexType" ,
132+ "com.sun.xml.bind.v2.schemagen.xmlschema.ComplexTypeHost" ,
133+ "com.sun.xml.bind.v2.schemagen.xmlschema.ComplexTypeModel" ,
134+ "com.sun.xml.bind.v2.schemagen.xmlschema.ContentModelContainer" ,
135+ "com.sun.xml.bind.v2.schemagen.xmlschema.Documentation" ,
136+ "com.sun.xml.bind.v2.schemagen.xmlschema.Element" ,
137+ "com.sun.xml.bind.v2.schemagen.xmlschema.ExplicitGroup" ,
138+ "com.sun.xml.bind.v2.schemagen.xmlschema.ExtensionType" ,
139+ "com.sun.xml.bind.v2.schemagen.xmlschema.FixedOrDefault" ,
140+ "com.sun.xml.bind.v2.schemagen.xmlschema.Import" ,
141+ "com.sun.xml.bind.v2.schemagen.xmlschema.List" ,
142+ "com.sun.xml.bind.v2.schemagen.xmlschema.LocalAttribute" ,
143+ "com.sun.xml.bind.v2.schemagen.xmlschema.LocalElement" ,
144+ "com.sun.xml.bind.v2.schemagen.xmlschema.NestedParticle" ,
145+ "com.sun.xml.bind.v2.schemagen.xmlschema.NoFixedFacet" ,
146+ "com.sun.xml.bind.v2.schemagen.xmlschema.Occurs" ,
147+ "com.sun.xml.bind.v2.schemagen.xmlschema.Particle" ,
148+ "com.sun.xml.bind.v2.schemagen.xmlschema.Redefinable" ,
149+ "com.sun.xml.bind.v2.schemagen.xmlschema.Schema" ,
150+ "com.sun.xml.bind.v2.schemagen.xmlschema.SchemaTop" ,
151+ "com.sun.xml.bind.v2.schemagen.xmlschema.SimpleContent" ,
152+ "com.sun.xml.bind.v2.schemagen.xmlschema.SimpleDerivation" ,
153+ "com.sun.xml.bind.v2.schemagen.xmlschema.SimpleExtension" ,
154+ "com.sun.xml.bind.v2.schemagen.xmlschema.SimpleRestriction" ,
155+ "com.sun.xml.bind.v2.schemagen.xmlschema.SimpleRestrictionModel" ,
156+ "com.sun.xml.bind.v2.schemagen.xmlschema.SimpleType" ,
157+ "com.sun.xml.bind.v2.schemagen.xmlschema.SimpleTypeHost" ,
158+ "com.sun.xml.bind.v2.schemagen.xmlschema.TopLevelAttribute" ,
159+ "com.sun.xml.bind.v2.schemagen.xmlschema.TopLevelElement" ,
160+ "com.sun.xml.bind.v2.schemagen.xmlschema.TypeDefParticle" ,
161+ "com.sun.xml.bind.v2.schemagen.xmlschema.TypeHost" ,
162+ "com.sun.xml.bind.v2.schemagen.xmlschema.Union" ,
163+ "com.sun.xml.bind.v2.schemagen.xmlschema.Wildcard" ,
164+ "com.sun.xml.txw2.TypedXmlWriter" );
117165
118166 @ BuildStep
119167 void processAnnotationsAndIndexFiles (
@@ -169,128 +217,27 @@ void processAnnotationsAndIndexFiles(
169217 JAXB_ANNOTATIONS .stream ()
170218 .map (Class ::getName )
171219 .forEach (className -> {
172- proxyDefinitions .produce (new NativeImageProxyDefinitionBuildItem (className ,
173- "com.sun.xml.bind.v2.model.annotation.Locatable" ));
174220 addReflectiveClass (reflectiveClass , true , false , className );
175221 });
176222
177- proxyDefinitions
178- .produce (new NativeImageProxyDefinitionBuildItem ("com.sun.xml.bind.marshaller.CharacterEscapeHandler" ));
179- proxyDefinitions
180- .produce (new NativeImageProxyDefinitionBuildItem ("com.sun.xml.txw2.output.CharacterEscapeHandler" ));
181- proxyDefinitions
182- .produce (new NativeImageProxyDefinitionBuildItem ("com.sun.xml.bind.v2.schemagen.episode.Bindings" ));
183- proxyDefinitions
184- .produce (new NativeImageProxyDefinitionBuildItem ("com.sun.xml.bind.v2.schemagen.episode.SchemaBindings" ));
185- proxyDefinitions
186- .produce (new NativeImageProxyDefinitionBuildItem ("com.sun.xml.bind.v2.schemagen.episode.Klass" ));
187- proxyDefinitions
188- .produce (new NativeImageProxyDefinitionBuildItem ("com.sun.xml.bind.v2.schemagen.episode.Package" ));
189- proxyDefinitions
190- .produce (new NativeImageProxyDefinitionBuildItem ("com.sun.xml.bind.v2.schemagen.xmlschema.Annotated" ));
191- proxyDefinitions
192- .produce (new NativeImageProxyDefinitionBuildItem ("com.sun.xml.bind.v2.schemagen.xmlschema.Annotation" ));
193- proxyDefinitions
194- .produce (new NativeImageProxyDefinitionBuildItem ("com.sun.xml.bind.v2.schemagen.xmlschema.Any" ));
195- proxyDefinitions
196- .produce (new NativeImageProxyDefinitionBuildItem ("com.sun.xml.bind.v2.schemagen.xmlschema.Appinfo" ));
197- proxyDefinitions
198- .produce (new NativeImageProxyDefinitionBuildItem ("com.sun.xml.bind.v2.schemagen.xmlschema.AttrDecls" ));
199- proxyDefinitions
200- .produce (new NativeImageProxyDefinitionBuildItem ("com.sun.xml.bind.v2.schemagen.xmlschema.AttributeType" ));
201- proxyDefinitions
202- .produce (new NativeImageProxyDefinitionBuildItem ("com.sun.xml.bind.v2.schemagen.xmlschema.ComplexContent" ));
203- proxyDefinitions
204- .produce (new NativeImageProxyDefinitionBuildItem ("com.sun.xml.bind.v2.schemagen.xmlschema.ComplexExtension" ));
205- proxyDefinitions
206- .produce (new NativeImageProxyDefinitionBuildItem ("com.sun.xml.bind.v2.schemagen.xmlschema.ComplexRestriction" ));
207- proxyDefinitions
208- .produce (new NativeImageProxyDefinitionBuildItem ("com.sun.xml.bind.v2.schemagen.xmlschema.ComplexType" ));
209- proxyDefinitions
210- .produce (new NativeImageProxyDefinitionBuildItem ("com.sun.xml.bind.v2.schemagen.xmlschema.ComplexTypeHost" ));
211- proxyDefinitions
212- .produce (new NativeImageProxyDefinitionBuildItem ("com.sun.xml.bind.v2.schemagen.xmlschema.ComplexTypeModel" ));
213- proxyDefinitions
214- .produce (new NativeImageProxyDefinitionBuildItem (
215- "com.sun.xml.bind.v2.schemagen.xmlschema.ContentModelContainer" ));
216- proxyDefinitions
217- .produce (new NativeImageProxyDefinitionBuildItem ("com.sun.xml.bind.v2.schemagen.xmlschema.Documentation" ));
218- proxyDefinitions
219- .produce (new NativeImageProxyDefinitionBuildItem ("com.sun.xml.bind.v2.schemagen.xmlschema.Element" ));
220- proxyDefinitions
221- .produce (new NativeImageProxyDefinitionBuildItem ("com.sun.xml.bind.v2.schemagen.xmlschema.ExplicitGroup" ));
222- proxyDefinitions
223- .produce (new NativeImageProxyDefinitionBuildItem ("com.sun.xml.bind.v2.schemagen.xmlschema.ExtensionType" ));
224- proxyDefinitions
225- .produce (new NativeImageProxyDefinitionBuildItem ("com.sun.xml.bind.v2.schemagen.xmlschema.FixedOrDefault" ));
226- proxyDefinitions
227- .produce (new NativeImageProxyDefinitionBuildItem ("com.sun.xml.bind.v2.schemagen.xmlschema.Import" ));
228- proxyDefinitions
229- .produce (new NativeImageProxyDefinitionBuildItem ("com.sun.xml.bind.v2.schemagen.xmlschema.List" ));
230- proxyDefinitions
231- .produce (new NativeImageProxyDefinitionBuildItem ("com.sun.xml.bind.v2.schemagen.xmlschema.LocalAttribute" ));
232- proxyDefinitions
233- .produce (new NativeImageProxyDefinitionBuildItem ("com.sun.xml.bind.v2.schemagen.xmlschema.LocalElement" ));
234- proxyDefinitions
235- .produce (new NativeImageProxyDefinitionBuildItem ("com.sun.xml.bind.v2.schemagen.xmlschema.NestedParticle" ));
236- proxyDefinitions
237- .produce (new NativeImageProxyDefinitionBuildItem ("com.sun.xml.bind.v2.schemagen.xmlschema.NoFixedFacet" ));
238- proxyDefinitions
239- .produce (new NativeImageProxyDefinitionBuildItem ("com.sun.xml.bind.v2.schemagen.xmlschema.Occurs" ));
240- proxyDefinitions
241- .produce (new NativeImageProxyDefinitionBuildItem ("com.sun.xml.bind.v2.schemagen.xmlschema.Particle" ));
242- proxyDefinitions
243- .produce (new NativeImageProxyDefinitionBuildItem ("com.sun.xml.bind.v2.schemagen.xmlschema.Redefinable" ));
244- proxyDefinitions
245- .produce (new NativeImageProxyDefinitionBuildItem ("com.sun.xml.bind.v2.schemagen.xmlschema.Schema" ));
246- proxyDefinitions
247- .produce (new NativeImageProxyDefinitionBuildItem ("com.sun.xml.bind.v2.schemagen.xmlschema.SchemaTop" ));
248- proxyDefinitions
249- .produce (new NativeImageProxyDefinitionBuildItem ("com.sun.xml.bind.v2.schemagen.xmlschema.SimpleContent" ));
250- proxyDefinitions
251- .produce (new NativeImageProxyDefinitionBuildItem ("com.sun.xml.bind.v2.schemagen.xmlschema.SimpleDerivation" ));
252- proxyDefinitions
253- .produce (new NativeImageProxyDefinitionBuildItem ("com.sun.xml.bind.v2.schemagen.xmlschema.SimpleExtension" ));
254- proxyDefinitions
255- .produce (new NativeImageProxyDefinitionBuildItem ("com.sun.xml.bind.v2.schemagen.xmlschema.SimpleRestriction" ));
256- proxyDefinitions
257- .produce (new NativeImageProxyDefinitionBuildItem (
258- "com.sun.xml.bind.v2.schemagen.xmlschema.SimpleRestrictionModel" ));
259- proxyDefinitions
260- .produce (new NativeImageProxyDefinitionBuildItem ("com.sun.xml.bind.v2.schemagen.xmlschema.SimpleType" ));
261- proxyDefinitions
262- .produce (new NativeImageProxyDefinitionBuildItem ("com.sun.xml.bind.v2.schemagen.xmlschema.SimpleTypeHost" ));
263- proxyDefinitions
264- .produce (new NativeImageProxyDefinitionBuildItem ("com.sun.xml.bind.v2.schemagen.xmlschema.TopLevelAttribute" ));
265- proxyDefinitions
266- .produce (new NativeImageProxyDefinitionBuildItem ("com.sun.xml.bind.v2.schemagen.xmlschema.TopLevelElement" ));
267- proxyDefinitions
268- .produce (new NativeImageProxyDefinitionBuildItem ("com.sun.xml.bind.v2.schemagen.xmlschema.TypeDefParticle" ));
269- proxyDefinitions
270- .produce (new NativeImageProxyDefinitionBuildItem ("com.sun.xml.bind.v2.schemagen.xmlschema.TypeHost" ));
271- proxyDefinitions
272- .produce (new NativeImageProxyDefinitionBuildItem ("com.sun.xml.bind.v2.schemagen.xmlschema.Union" ));
273- proxyDefinitions
274- .produce (new NativeImageProxyDefinitionBuildItem ("com.sun.xml.bind.v2.schemagen.xmlschema.Wildcard" ));
275- proxyDefinitions
276- .produce (new NativeImageProxyDefinitionBuildItem ("com.sun.xml.txw2.TypedXmlWriter" ));
277-
278- for (JaxbFileRootBuildItem i : fileRoots ) {
279- iterateResources (applicationArchivesBuildItem , i .getFileRoot (), resource , reflectiveClass );
280- }
281- }
282-
283- @ BuildStep
284- void seeAlso (CombinedIndexBuildItem combinedIndexBuildItem ,
285- BuildProducer <ReflectiveClassBuildItem > reflectiveItems ) {
286- IndexView index = combinedIndexBuildItem .getIndex ();
223+ // Register @XmlSeeAlso
224+ proxyDefinitions .produce (new NativeImageProxyDefinitionBuildItem (XmlSeeAlso .class .getName (),
225+ "com.sun.xml.bind.v2.model.annotation.Locatable" ));
287226 for (AnnotationInstance xmlSeeAlsoAnn : index .getAnnotations (XML_SEE_ALSO )) {
288227 AnnotationValue value = xmlSeeAlsoAnn .value ();
289228 Type [] types = value .asClassArray ();
290229 for (Type t : types ) {
291- reflectiveItems . produce ( new ReflectiveClassBuildItem ( false , false , t .name ().toString () ));
230+ addReflectiveClass ( reflectiveClass , false , false , t .name ().toString ());
292231 }
293232 }
233+ // Register Native proxy definitions
234+ for (String s : NATIVE_PROXY_DEFINITIONS ) {
235+ proxyDefinitions .produce (new NativeImageProxyDefinitionBuildItem (s ));
236+ }
237+
238+ for (JaxbFileRootBuildItem i : fileRoots ) {
239+ iterateResources (applicationArchivesBuildItem , i .getFileRoot (), resource , reflectiveClass );
240+ }
294241 }
295242
296243 @ BuildStep
0 commit comments