You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Freeman Fang (JIRA)" <ji...@apache.org> on 2018/04/18 07:36:00 UTC

[jira] [Comment Edited] (CXFXJC-25) cxf-xjc-plugin can't load xjc plugin extensions which is already on the classpath with jax-xjc 2.3.0

    [ https://issues.apache.org/jira/browse/CXFXJC-25?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16442053#comment-16442053 ] 

Freeman Fang edited comment on CXFXJC-25 at 4/18/18 7:35 AM:
-------------------------------------------------------------

This is caused by that the getAllPlugins() method in com.sun.tools.xjc.Options class changed since jaxb-xjc 2.3.0

In 2.2.11 it's
{code:java}
public List<Plugin> getAllPlugins() {
        if(allPlugins==null) {
            allPlugins = new ArrayList<Plugin>();
            ClassLoader ucl = getUserClassLoader(SecureLoader.getClassClassLoader(getClass()));
            allPlugins.addAll(Arrays.asList(findServices(Plugin.class,ucl)));
        }

        return allPlugins;
    }

/**
     * Gets a classLoader that can load classes specified via the
     * -classpath option.
     */
    public ClassLoader getUserClassLoader( ClassLoader parent ) {
        if (classpaths.isEmpty())
            return parent;
        return new URLClassLoader(
                classpaths.toArray(new URL[classpaths.size()]),parent);
    }

{code}
while in 2.3.0 it's
{code:java}
public List<Plugin> getAllPlugins() {
        if (allPlugins == null) {
            allPlugins = findServices(Plugin.class);
        }

        return allPlugins;
    }

{code}
The getUserClassLoader method used in 2.2.11 ensure it can load plugin extensions from the classpath, this is essential. We should fix this and ensure cxf-xjc-plugin can both work with jaxb 2.2.x and jaxb 2.3

 


was (Author: ffang):
This is caused by that the getAllPlugins() method in com.sun.tools.xjc.Options class changed since jaxb-xjc 2.3.0

In 2.2.11 it's

{code}

public List<Plugin> getAllPlugins() {
        if(allPlugins==null) {
            allPlugins = new ArrayList<Plugin>();
            ClassLoader ucl = getUserClassLoader(SecureLoader.getClassClassLoader(getClass()));
            allPlugins.addAll(Arrays.asList(findServices(Plugin.class,ucl)));
        }

        return allPlugins;
    }

{code}

while in 2.3.0 it's

{code}

public List<Plugin> getAllPlugins() {
        if (allPlugins == null) {
            allPlugins = findServices(Plugin.class);
        }

        return allPlugins;
    }

{code}

The getUserClassLoader method used in 2.2.11 ensure it can load plugin extensions from the classpath, this is essential. We should fix this and ensure cxf-xjc-plugin can both work with jaxb 2.2.x and jaxb 2.3

 

> cxf-xjc-plugin can't load xjc plugin extensions which is already on the classpath with jax-xjc 2.3.0
> ----------------------------------------------------------------------------------------------------
>
>                 Key: CXFXJC-25
>                 URL: https://issues.apache.org/jira/browse/CXFXJC-25
>             Project: CXF XJC Utils
>          Issue Type: Improvement
>            Reporter: Freeman Fang
>            Assignee: Freeman Fang
>            Priority: Major
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)