Better would also be for the API to not take a String class name but a Class object. The caller likely has access to the named class (or can easily be configured to have access), while the library code which has to load the class from the String class name generally does not which is why we have the "magic" of TCCLs... (sigh)
--

BJ Hargrave
Senior Technical Staff Member, IBM // office: +1 386 848 1781
OSGi Fellow and CTO of the OSGi Alliance // mobile: +1 386 848 3788
hargr...@us.ibm.com
 
 
----- Original message -----
From: Justin Edelson <jus...@justinedelson.com>
Sent by: osgi-dev-boun...@mail.osgi.org
To: OSGi Developer Mail List <osgi-dev@mail.osgi.org>
Cc:
Subject: Re: [osgi-dev] Class.forName Hell
Date: Fri, Sep 15, 2017 2:55 PM
 
Given that the Thread Context Classloader is used, can you just set this to the correct value before invoking DefaultComponentFactory.createComponent()? I don't know the fully calling context, so perhaps that won't work. If the TCCL is the wrong choice but happens to work in a non-OSGi environment, the right solution generally is to allow for an alternate classloader to be passed in.
 
On Thu, Sep 14, 2017 at 11:24 PM Paul F Fraser <pa...@a2zliving.com> wrote:
Hi,

I do not have the slightest idea if this situation can be handled, but perhaps some kind person can
assist.

Vaadin uses forName in the following situation and the classes are not found when used in OSGi project.

https://github.com/vaadin/framework/blob/master/server/src/main/java/com/vaadin/ui/declarative/Design.java
(~ line 200)

https://github.com/vaadin/framework/blob/master/server/src/main/java/com/vaadin/server/VaadinServiceClassLoaderUtil.java

If possible it would be a good contribution if we could suggest a way to Vaadin as to how this
should/could be handled.

Paul Fraser

_______________________________________________
OSGi Developer Mail List
osgi-dev@mail.osgi.org
https://mail.osgi.org/mailman/listinfo/osgi-dev
 

_______________________________________________
OSGi Developer Mail List
osgi-dev@mail.osgi.org
https://mail.osgi.org/mailman/listinfo/osgi-dev

Reply via email to