You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@netbeans.apache.org by Peter Nabbefeld <pe...@gmx.de> on 2018/06/28 08:59:27 UTC

How to fix a ClassLoader in a NetBeans module with external libraries?

Hello,

I've got a LinkageError when running a NetBeans plugin with a dependency 
on nb-javac. The plugin uses Maven, and I've noticed the following entry 
in MANIFEST.MF:

Maven-Class-Path: org.netbeans.external:nb-javac-api:RELEASE82 
org.netbeans.external:nb-javac-impl:RELEASE82

This obviously results in creating its own ClassLoader 
(ModuleCL@...[org.netbeans.modules.java.source.base]) for the compiler 
libraries - different from my module's one.  :-(

Both class loaders have the same parent 
(sun.misc.Launcher$AppClassLoader@same_number).

As different classes loaded by different class loaders are different, 
assignment results in a LinkageError. The class is in this case 
"javax.lang.model.util.Elements".

Is there any chance to convert Objects from 
Elements@org.netbeans.modules.java.source.base to Elements@my.module?

Kind regards

Peter

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@netbeans.incubator.apache.org
For additional commands, e-mail: dev-help@netbeans.incubator.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists




Re: How to fix a ClassLoader in a NetBeans module with external libraries?

Posted by Peter Nabbefeld <pe...@gmx.de>.
Most NetBeans APIs belong to group "org.netbeans.api", while nb-javac 
belongs to "org.netbeans.external". Obviously, nbm-maven-plugin treats 
ths as a hint to add "Maven-Class-Path: 
org.netbeans.external:nb-javac-api:RELEASE82 
org.netbeans.external:nb-javac-impl:RELEASE82" to the created module's 
manifest. This seems to cause nb-javac to be loaded as an external 
library, loaded before module execution and thus with a different module 
class loader. However, I'm not an expert on this, so I can only guess.  :-/

If I could find a way load the dependency into the same class loader, 
I'd be fine.

Peter



Am 28.06.2018 um 17:49 schrieb Geertjan Wielenga:
> The real question is why the plugin needs to do any of this.
>
> Gj
>
> On Thu, Jun 28, 2018 at 10:59 AM, Peter Nabbefeld <pe...@gmx.de>
> wrote:
>
>> Hello,
>>
>> I've got a LinkageError when running a NetBeans plugin with a dependency
>> on nb-javac. The plugin uses Maven, and I've noticed the following entry in
>> MANIFEST.MF:
>>
>> Maven-Class-Path: org.netbeans.external:nb-javac-api:RELEASE82
>> org.netbeans.external:nb-javac-impl:RELEASE82
>>
>> This obviously results in creating its own ClassLoader (ModuleCL@
>> ...[org.netbeans.modules.java.source.base]) for the compiler libraries -
>> different from my module's one.  :-(
>>
>> Both class loaders have the same parent (sun.misc.Launcher$AppClassLoa
>> der@same_number).
>>
>> As different classes loaded by different class loaders are different,
>> assignment results in a LinkageError. The class is in this case
>> "javax.lang.model.util.Elements".
>>
>> Is there any chance to convert Objects from Elements@org.netbeans.modules.java.source.base
>> to Elements@my.module?
>>
>> Kind regards
>>
>> Peter
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@netbeans.incubator.apache.org
>> For additional commands, e-mail: dev-help@netbeans.incubator.apache.org
>>
>> For further information about the NetBeans mailing lists, visit:
>> https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
>>
>>
>>
>>


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@netbeans.incubator.apache.org
For additional commands, e-mail: dev-help@netbeans.incubator.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists




Re: How to fix a ClassLoader in a NetBeans module with external libraries?

Posted by Peter Nabbefeld <pe...@gmx.de>.
Thank You Geertjan, I'll go to ask him.

Peter


Am 28.06.2018 um 18:57 schrieb Geertjan Wielenga:
> The person to interact with 100% on this is Tim Boudreau who wrote that
> code.
>
> Gj
>
> On Thu, Jun 28, 2018 at 6:39 PM, Peter Nabbefeld <pe...@gmx.de>
> wrote:
>
>> nb-javac is used to scan the Java source code e.g. for construction of
>> wicket components. Using the Java compiler to scan the source's structure
>> seems to be reasonable because it should be the most reliable option. The
>> other would be to implement a parser of my own - I don't think I'll be able
>> to ever fix all the bugs then.
>>
>> Peter
>>
>>
>>
>> Am 28.06.2018 um 18:31 schrieb Geertjan Wielenga:
>>
>>> The real question is why the plugin needs to do any of this -- why does it
>>> have a dependency on nb-javac? What happens when you remove it? Do you
>>> actually need that dependency at all and why? What functionality does it
>>> add?
>>>
>>> Gj
>>>
>>>
>>>
>>> On Thu, Jun 28, 2018 at 6:05 PM, Peter Nabbefeld <pe...@gmx.de>
>>> wrote:
>>>
>>> In some Ant-based module I found this: "OpenIDE-Module-Hide-Classpath
>>>> -Packages:
>>>> com.sun.tools.javac.**, com.sun.tools.javadoc.**, com.sun.tools.javap.**,
>>>> com.sun.tools.classfile.*". Is there sth. I can configure in
>>>> nbm-maven-plugin to put this into my manifest?
>>>>
>>>> Peter
>>>>
>>>>
>>>> Am 28.06.2018 um 17:49 schrieb Geertjan Wielenga:
>>>>
>>>> The real question is why the plugin needs to do any of this.
>>>>> Gj
>>>>>
>>>>> On Thu, Jun 28, 2018 at 10:59 AM, Peter Nabbefeld <
>>>>> peter.nabbefeld@gmx.de
>>>>> wrote:
>>>>>
>>>>> Hello,
>>>>>
>>>>>> I've got a LinkageError when running a NetBeans plugin with a
>>>>>> dependency
>>>>>> on nb-javac. The plugin uses Maven, and I've noticed the following
>>>>>> entry
>>>>>> in
>>>>>> MANIFEST.MF:
>>>>>>
>>>>>> Maven-Class-Path: org.netbeans.external:nb-javac-api:RELEASE82
>>>>>> org.netbeans.external:nb-javac-impl:RELEASE82
>>>>>>
>>>>>> This obviously results in creating its own ClassLoader (ModuleCL@
>>>>>> ...[org.netbeans.modules.java.source.base]) for the compiler
>>>>>> libraries -
>>>>>> different from my module's one.  :-(
>>>>>>
>>>>>> Both class loaders have the same parent (sun.misc.Launcher$AppClassLoa
>>>>>> der@same_number).
>>>>>>
>>>>>> As different classes loaded by different class loaders are different,
>>>>>> assignment results in a LinkageError. The class is in this case
>>>>>> "javax.lang.model.util.Elements".
>>>>>>
>>>>>> Is there any chance to convert Objects from
>>>>>> Elements@org.netbeans.modules.java.source.base
>>>>>> to Elements@my.module?
>>>>>>
>>>>>> Kind regards
>>>>>>
>>>>>> Peter
>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: dev-unsubscribe@netbeans.incubator.apache.org
>>>>>> For additional commands, e-mail: dev-help@netbeans.incubator.ap
>>>>>> ache.org
>>>>>>
>>>>>> For further information about the NetBeans mailing lists, visit:
>>>>>> https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: dev-unsubscribe@netbeans.incubator.apache.org
>>>> For additional commands, e-mail: dev-help@netbeans.incubator.apache.org
>>>>
>>>> For further information about the NetBeans mailing lists, visit:
>>>> https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
>>>>
>>>>
>>>>
>>>>
>>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@netbeans.incubator.apache.org
>> For additional commands, e-mail: dev-help@netbeans.incubator.apache.org
>>
>> For further information about the NetBeans mailing lists, visit:
>> https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
>>
>>
>>
>>


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@netbeans.incubator.apache.org
For additional commands, e-mail: dev-help@netbeans.incubator.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists




Re: How to fix a ClassLoader in a NetBeans module with external libraries?

Posted by Geertjan Wielenga <ge...@googlemail.com.INVALID>.
The person to interact with 100% on this is Tim Boudreau who wrote that
code.

Gj

On Thu, Jun 28, 2018 at 6:39 PM, Peter Nabbefeld <pe...@gmx.de>
wrote:

> nb-javac is used to scan the Java source code e.g. for construction of
> wicket components. Using the Java compiler to scan the source's structure
> seems to be reasonable because it should be the most reliable option. The
> other would be to implement a parser of my own - I don't think I'll be able
> to ever fix all the bugs then.
>
> Peter
>
>
>
> Am 28.06.2018 um 18:31 schrieb Geertjan Wielenga:
>
>> The real question is why the plugin needs to do any of this -- why does it
>> have a dependency on nb-javac? What happens when you remove it? Do you
>> actually need that dependency at all and why? What functionality does it
>> add?
>>
>> Gj
>>
>>
>>
>> On Thu, Jun 28, 2018 at 6:05 PM, Peter Nabbefeld <pe...@gmx.de>
>> wrote:
>>
>> In some Ant-based module I found this: "OpenIDE-Module-Hide-Classpath
>>> -Packages:
>>> com.sun.tools.javac.**, com.sun.tools.javadoc.**, com.sun.tools.javap.**,
>>> com.sun.tools.classfile.*". Is there sth. I can configure in
>>> nbm-maven-plugin to put this into my manifest?
>>>
>>> Peter
>>>
>>>
>>> Am 28.06.2018 um 17:49 schrieb Geertjan Wielenga:
>>>
>>> The real question is why the plugin needs to do any of this.
>>>>
>>>> Gj
>>>>
>>>> On Thu, Jun 28, 2018 at 10:59 AM, Peter Nabbefeld <
>>>> peter.nabbefeld@gmx.de
>>>> wrote:
>>>>
>>>> Hello,
>>>>
>>>>> I've got a LinkageError when running a NetBeans plugin with a
>>>>> dependency
>>>>> on nb-javac. The plugin uses Maven, and I've noticed the following
>>>>> entry
>>>>> in
>>>>> MANIFEST.MF:
>>>>>
>>>>> Maven-Class-Path: org.netbeans.external:nb-javac-api:RELEASE82
>>>>> org.netbeans.external:nb-javac-impl:RELEASE82
>>>>>
>>>>> This obviously results in creating its own ClassLoader (ModuleCL@
>>>>> ...[org.netbeans.modules.java.source.base]) for the compiler
>>>>> libraries -
>>>>> different from my module's one.  :-(
>>>>>
>>>>> Both class loaders have the same parent (sun.misc.Launcher$AppClassLoa
>>>>> der@same_number).
>>>>>
>>>>> As different classes loaded by different class loaders are different,
>>>>> assignment results in a LinkageError. The class is in this case
>>>>> "javax.lang.model.util.Elements".
>>>>>
>>>>> Is there any chance to convert Objects from
>>>>> Elements@org.netbeans.modules.java.source.base
>>>>> to Elements@my.module?
>>>>>
>>>>> Kind regards
>>>>>
>>>>> Peter
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: dev-unsubscribe@netbeans.incubator.apache.org
>>>>> For additional commands, e-mail: dev-help@netbeans.incubator.ap
>>>>> ache.org
>>>>>
>>>>> For further information about the NetBeans mailing lists, visit:
>>>>> https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: dev-unsubscribe@netbeans.incubator.apache.org
>>> For additional commands, e-mail: dev-help@netbeans.incubator.apache.org
>>>
>>> For further information about the NetBeans mailing lists, visit:
>>> https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
>>>
>>>
>>>
>>>
>>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@netbeans.incubator.apache.org
> For additional commands, e-mail: dev-help@netbeans.incubator.apache.org
>
> For further information about the NetBeans mailing lists, visit:
> https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
>
>
>
>

Re: How to fix a ClassLoader in a NetBeans module with external libraries?

Posted by Peter Nabbefeld <pe...@gmx.de>.
nb-javac is used to scan the Java source code e.g. for construction of 
wicket components. Using the Java compiler to scan the source's 
structure seems to be reasonable because it should be the most reliable 
option. The other would be to implement a parser of my own - I don't 
think I'll be able to ever fix all the bugs then.

Peter


Am 28.06.2018 um 18:31 schrieb Geertjan Wielenga:
> The real question is why the plugin needs to do any of this -- why does it
> have a dependency on nb-javac? What happens when you remove it? Do you
> actually need that dependency at all and why? What functionality does it
> add?
>
> Gj
>
>
>
> On Thu, Jun 28, 2018 at 6:05 PM, Peter Nabbefeld <pe...@gmx.de>
> wrote:
>
>> In some Ant-based module I found this: "OpenIDE-Module-Hide-Classpath-Packages:
>> com.sun.tools.javac.**, com.sun.tools.javadoc.**, com.sun.tools.javap.**,
>> com.sun.tools.classfile.*". Is there sth. I can configure in
>> nbm-maven-plugin to put this into my manifest?
>>
>> Peter
>>
>>
>> Am 28.06.2018 um 17:49 schrieb Geertjan Wielenga:
>>
>>> The real question is why the plugin needs to do any of this.
>>>
>>> Gj
>>>
>>> On Thu, Jun 28, 2018 at 10:59 AM, Peter Nabbefeld <peter.nabbefeld@gmx.de
>>> wrote:
>>>
>>> Hello,
>>>> I've got a LinkageError when running a NetBeans plugin with a dependency
>>>> on nb-javac. The plugin uses Maven, and I've noticed the following entry
>>>> in
>>>> MANIFEST.MF:
>>>>
>>>> Maven-Class-Path: org.netbeans.external:nb-javac-api:RELEASE82
>>>> org.netbeans.external:nb-javac-impl:RELEASE82
>>>>
>>>> This obviously results in creating its own ClassLoader (ModuleCL@
>>>> ...[org.netbeans.modules.java.source.base]) for the compiler libraries -
>>>> different from my module's one.  :-(
>>>>
>>>> Both class loaders have the same parent (sun.misc.Launcher$AppClassLoa
>>>> der@same_number).
>>>>
>>>> As different classes loaded by different class loaders are different,
>>>> assignment results in a LinkageError. The class is in this case
>>>> "javax.lang.model.util.Elements".
>>>>
>>>> Is there any chance to convert Objects from
>>>> Elements@org.netbeans.modules.java.source.base
>>>> to Elements@my.module?
>>>>
>>>> Kind regards
>>>>
>>>> Peter
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: dev-unsubscribe@netbeans.incubator.apache.org
>>>> For additional commands, e-mail: dev-help@netbeans.incubator.apache.org
>>>>
>>>> For further information about the NetBeans mailing lists, visit:
>>>> https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
>>>>
>>>>
>>>>
>>>>
>>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@netbeans.incubator.apache.org
>> For additional commands, e-mail: dev-help@netbeans.incubator.apache.org
>>
>> For further information about the NetBeans mailing lists, visit:
>> https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
>>
>>
>>
>>


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@netbeans.incubator.apache.org
For additional commands, e-mail: dev-help@netbeans.incubator.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists




Re: How to fix a ClassLoader in a NetBeans module with external libraries?

Posted by Geertjan Wielenga <ge...@googlemail.com.INVALID>.
The real question is why the plugin needs to do any of this -- why does it
have a dependency on nb-javac? What happens when you remove it? Do you
actually need that dependency at all and why? What functionality does it
add?

Gj



On Thu, Jun 28, 2018 at 6:05 PM, Peter Nabbefeld <pe...@gmx.de>
wrote:

> In some Ant-based module I found this: "OpenIDE-Module-Hide-Classpath-Packages:
> com.sun.tools.javac.**, com.sun.tools.javadoc.**, com.sun.tools.javap.**,
> com.sun.tools.classfile.*". Is there sth. I can configure in
> nbm-maven-plugin to put this into my manifest?
>
> Peter
>
>
> Am 28.06.2018 um 17:49 schrieb Geertjan Wielenga:
>
>> The real question is why the plugin needs to do any of this.
>>
>> Gj
>>
>> On Thu, Jun 28, 2018 at 10:59 AM, Peter Nabbefeld <peter.nabbefeld@gmx.de
>> >
>> wrote:
>>
>> Hello,
>>>
>>> I've got a LinkageError when running a NetBeans plugin with a dependency
>>> on nb-javac. The plugin uses Maven, and I've noticed the following entry
>>> in
>>> MANIFEST.MF:
>>>
>>> Maven-Class-Path: org.netbeans.external:nb-javac-api:RELEASE82
>>> org.netbeans.external:nb-javac-impl:RELEASE82
>>>
>>> This obviously results in creating its own ClassLoader (ModuleCL@
>>> ...[org.netbeans.modules.java.source.base]) for the compiler libraries -
>>> different from my module's one.  :-(
>>>
>>> Both class loaders have the same parent (sun.misc.Launcher$AppClassLoa
>>> der@same_number).
>>>
>>> As different classes loaded by different class loaders are different,
>>> assignment results in a LinkageError. The class is in this case
>>> "javax.lang.model.util.Elements".
>>>
>>> Is there any chance to convert Objects from
>>> Elements@org.netbeans.modules.java.source.base
>>> to Elements@my.module?
>>>
>>> Kind regards
>>>
>>> Peter
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: dev-unsubscribe@netbeans.incubator.apache.org
>>> For additional commands, e-mail: dev-help@netbeans.incubator.apache.org
>>>
>>> For further information about the NetBeans mailing lists, visit:
>>> https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
>>>
>>>
>>>
>>>
>>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@netbeans.incubator.apache.org
> For additional commands, e-mail: dev-help@netbeans.incubator.apache.org
>
> For further information about the NetBeans mailing lists, visit:
> https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
>
>
>
>

Re: How to fix a ClassLoader in a NetBeans module with external libraries?

Posted by Peter Nabbefeld <pe...@gmx.de>.
In some Ant-based module I found this: 
"OpenIDE-Module-Hide-Classpath-Packages: com.sun.tools.javac.**, 
com.sun.tools.javadoc.**, com.sun.tools.javap.**, 
com.sun.tools.classfile.*". Is there sth. I can configure in 
nbm-maven-plugin to put this into my manifest?

Peter


Am 28.06.2018 um 17:49 schrieb Geertjan Wielenga:
> The real question is why the plugin needs to do any of this.
>
> Gj
>
> On Thu, Jun 28, 2018 at 10:59 AM, Peter Nabbefeld <pe...@gmx.de>
> wrote:
>
>> Hello,
>>
>> I've got a LinkageError when running a NetBeans plugin with a dependency
>> on nb-javac. The plugin uses Maven, and I've noticed the following entry in
>> MANIFEST.MF:
>>
>> Maven-Class-Path: org.netbeans.external:nb-javac-api:RELEASE82
>> org.netbeans.external:nb-javac-impl:RELEASE82
>>
>> This obviously results in creating its own ClassLoader (ModuleCL@
>> ...[org.netbeans.modules.java.source.base]) for the compiler libraries -
>> different from my module's one.  :-(
>>
>> Both class loaders have the same parent (sun.misc.Launcher$AppClassLoa
>> der@same_number).
>>
>> As different classes loaded by different class loaders are different,
>> assignment results in a LinkageError. The class is in this case
>> "javax.lang.model.util.Elements".
>>
>> Is there any chance to convert Objects from Elements@org.netbeans.modules.java.source.base
>> to Elements@my.module?
>>
>> Kind regards
>>
>> Peter
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@netbeans.incubator.apache.org
>> For additional commands, e-mail: dev-help@netbeans.incubator.apache.org
>>
>> For further information about the NetBeans mailing lists, visit:
>> https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
>>
>>
>>
>>


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@netbeans.incubator.apache.org
For additional commands, e-mail: dev-help@netbeans.incubator.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists




Re: How to fix a ClassLoader in a NetBeans module with external libraries?

Posted by Geertjan Wielenga <ge...@googlemail.com.INVALID>.
The real question is why the plugin needs to do any of this.

Gj

On Thu, Jun 28, 2018 at 10:59 AM, Peter Nabbefeld <pe...@gmx.de>
wrote:

>
> Hello,
>
> I've got a LinkageError when running a NetBeans plugin with a dependency
> on nb-javac. The plugin uses Maven, and I've noticed the following entry in
> MANIFEST.MF:
>
> Maven-Class-Path: org.netbeans.external:nb-javac-api:RELEASE82
> org.netbeans.external:nb-javac-impl:RELEASE82
>
> This obviously results in creating its own ClassLoader (ModuleCL@
> ...[org.netbeans.modules.java.source.base]) for the compiler libraries -
> different from my module's one.  :-(
>
> Both class loaders have the same parent (sun.misc.Launcher$AppClassLoa
> der@same_number).
>
> As different classes loaded by different class loaders are different,
> assignment results in a LinkageError. The class is in this case
> "javax.lang.model.util.Elements".
>
> Is there any chance to convert Objects from Elements@org.netbeans.modules.java.source.base
> to Elements@my.module?
>
> Kind regards
>
> Peter
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@netbeans.incubator.apache.org
> For additional commands, e-mail: dev-help@netbeans.incubator.apache.org
>
> For further information about the NetBeans mailing lists, visit:
> https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
>
>
>
>