Colm O hEigeartaigh created CXFXJC-53:
-----------------------------------------

             Summary: Remove the javassist ModelLoader patch and 
CustomizedLogic from cxf-xjc-plugin
                 Key: CXFXJC-53
                 URL: https://issues.apache.org/jira/browse/CXFXJC-53
             Project: CXF XJC Utils
          Issue Type: Improvement
            Reporter: Colm O hEigeartaigh
             Fix For: 4.3.0


{{XSDToJavaRunner.getModelLoaderClass()}} uses javassist to rewrite 
{{com.sun.tools.xjc.ModelLoader}} at runtime. The change makes 
{{buildDOMForest()}} use {{{}XSDToJavaRunner.CustomizedLogic{}}}, a custom 
{{XMLSchemaInternalizationLogic}} that resolves relative imports and includes 
inside schemas loaded from {{jar:}} URLs.

On JDK 17 and later this patch always fails. {{CtClass.toClass()}} throws 
{{java.lang.reflect.InaccessibleObjectException}} because {{java.base}} doesn’t 
open {{java.lang}} to the unnamed module. The {{Throwable}} is caught and the 
code quietly falls back to the stock {{{}ModelLoader{}}}. So on every JDK this 
release supports, {{CustomizedLogic}} is never used.

Stock XJC handles the case it was written for. With jaxb-xjc 4.0.9, a schema at 
{{jar:file:...!/sub/main.xsd}} that imports {{{}../other/o.xsd{}}}This file is 
outside this session’s folders, so it can’t be opened here. resolves and 
compiles correctly.

Proposed change:
 * Remove {{{}CustomizedLogic{}}}, the javassist patching in 
{{{}getModelLoaderClass(){}}}, and the reflective {{{}loadModel(){}}}. Call 
{{ModelLoader.load(opt, codeModel, listener)}} directly instead.
 * Remove {{checkXmlElementRef()}} and the {{SpecVersion.V2_3}} fallback it 
controls. The check looks for the JAXB 2.1 {{XmlElementRef}} API, which is 
never on the classpath with jakarta.xml.bind 4.x.
 * Remove the {{org.javassist:javassist}} dependency from 
{{{}cxf-xjc-plugin{}}}.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to