Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » e(fx)clipse » ClassLoaderHook(Any examples of how to implement ClassLoaderHook?)
ClassLoaderHook [message #1752424] Mon, 23 January 2017 16:19 Go to next message
Bob Flannigon is currently offline Bob FlannigonFriend
Messages: 5
Registered: October 2015
Junior Member
I'm looking for an example of implementing a ClassLoaderHook but so far I've not managed to work out how to get my plugin to actually invoke my ClassLoaderHook. I registered a service against the bundle context but it is never called.
There are some examples that use a file called hookconfigurators.properties is still the recommended way?

Perhaps you have an alternative approach instead? What I'm trying to do is import the JavaFX SWT libraries into my plugin project but I'm trying to avoid using the Efx project because I want to use gradle and in addition I don't want any users of the software to be dependent on Efx in their environment to be able use my plugin.

Thanks in advance.
Re: ClassLoaderHook [message #1752439 is a reply to message #1752424] Mon, 23 January 2017 18:44 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6313
Registered: July 2009
Senior Member
a) yes you need to use the .properties-File (please also follow the steps described in the wiki exactly - the hook is only resolved if org.eclipse.osgi is PHYSICALLY next to your hook-fragement!)
b) I'm not sure what import means. Do you mean a development time or runtime? The Classloader-Hook only solves the runtime problem but does not have anything to do with compile/development time. e(fx)clipe does the following 2 things:
b.1) It injects itself into the classpath-container creation for PDE (if you do OSGi-Module development)
b.2) Our maven-tycho build simply adds the swt-javafx integration jar to the compile time path
c) You know that we have a minimal feature for you to integrate and depend via the Eclipse Release Train repository? So all contained there is the adapter-hook!
d) Your strategy of rebuilding what e(fx)clipse adapter hook does not might look dangerous could turn out as a disaster if e(fx)clipse (or eg GEF4 who just uses the adapterhook-feature i talked about in (c)) and your adapter hook are installed next to each other and both creating distinct classloaders because suddenly TWO FXCanvas-Classes are loaded. It's just a wild guess but I don't think FXCanvas (or one of its helpers) expect that to be the case, or worse it works today but breaks in any JDK-Update
e) You need to make sure things don't break in future. eg our adapter hook already support Java9s-JPMS so you need to solve problems solved already

To sum up, rolling your own hook is possible just look at how we do it but please reconsider and just depend on our minimal runtime feature who just contains the hook and nothing else.
Re: ClassLoaderHook [message #1752476 is a reply to message #1752439] Tue, 24 January 2017 09:44 Go to previous messageGo to next message
Bob Flannigon is currently offline Bob FlannigonFriend
Messages: 5
Registered: October 2015
Junior Member
Thank you, Thomas.

The minimal runtime feature looks promising so I'll give that a go, I have some questions relating to it, if I may...

1. To install the minimal runtime would that require that I install just the 'PDE' part from the Efx update site?

2. There appears to be a "Target Platform" that refers to the minimal integration. Can I combine that with the eclipse_home dependencies and have access to everything I would usually (e.g. org.eclipse.ui) plus the additional JavaFx libraries?

3. How does distribution work in regard to the JavaFX dependencies? With Eclipse plugin libraries I can mark them as provided (compileOnly in gradle) and the target machine will have access to them naturally. Will the presence of Efx mean that if I mark the Efx stuff as provided too (I think this happens automatically in the manifest | Imported Packages) when I deploy my feature, without packaging any JavafX jars, it'll work on the target machine? Instead of saying, for example ClassNotFoundException: ... javafx/scene/Parent

Regards.
Re: ClassLoaderHook [message #1752495 is a reply to message #1752476] Tue, 24 January 2017 13:41 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6313
Registered: July 2009
Senior Member
* No PDE is only for development time to fix the PDE-Classpath - the best update site for you is http://download.eclipse.org/efxclipse/runtime-shared-nightly/site
* The target-platform feature is for those writing e4 on JavaFX applications
* JavaFX is and can not be distributed with your application/plugin (although it has to be on the classpath when compiling) so yes I guess "provided" is the correct term, the adapter hook we ship makes sure JavaFX and JavaFX/SWT classes are found (for pure JavaFX without the use of the SWT integration an adapter hook is not strictly required)
Re: ClassLoaderHook [message #1752707 is a reply to message #1752495] Thu, 26 January 2017 12:09 Go to previous messageGo to next message
Bob Flannigon is currently offline Bob FlannigonFriend
Messages: 5
Registered: October 2015
Junior Member
Thomas, thanks for your comments so far. I now have a working setup that I can build using Gradle and deploy as a new feature to a target Eclipse, that has the minimal runtime installed. This displays JavaFx components.

What I'm unable to solve is when launching from my development environment as an Eclipse Application I get errors associated to javafx, i.e.:
Caused by: java.lang.ClassNotFoundException: javafx.event.EventHandler cannot be found by Plugin_View1_1.0.10

Do you know how the launched Eclipse Application is furnished with the appropriate dependencies? In-particular the EFx stuff.
I've tried setting the launch configuration to allow software installation and added the Efx project (fails install the PDE plugin but I can install the minimal runtime, though that does not work). This seems an somewhat cumbersome approach, anyway.
Re: ClassLoaderHook [message #1753703 is a reply to message #1752707] Thu, 09 February 2017 07:05 Go to previous message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6313
Registered: July 2009
Senior Member
Well in an inner Eclipse you need to pass need to enable the AdapterHook excplictly because the config.ini generated by PDE misses this information, Just add -Dosgi.framework.extensions=org.eclipse.fx.osgi to your VM-args like it is described at http://wiki.eclipse.org/Efxclipse/Tutorials/Tutorial2
Previous Topic:Status of and information about org.eclipse.fx.text.ui.source etc
Next Topic:java.lang.NoClassDefFoundError only on Mac OS
Goto Forum:
  


Current Time: Thu May 25 16:24:22 GMT 2017

Powered by FUDForum. Page generated in 0.03798 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software