2017 up to now  | 2016 | 2015 | 2014 | 2013 | 2012 | 2011 | 2010 | 2009 | 2008 | 2007

(older archive entries before 2007 are not shown here, but included in the onsite-search)

Mailing List - Entries of 2012

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [QF-Test] Eclipse Class Loading/Imports in SUT scripts

  • Subject: Re: [QF-Test] Eclipse Class Loading/Imports in SUT scripts
  • From: Gregor Schmid <Gregor.Schmid@?.de>
  • Date: Mon, 19 Mar 2012 16:59:37 +0100

Hello Stephen,

thank you for bringing up this question at a good time.

Eclipse - or rather OSGI - class loading is pretty complex. I've been
looking at this time and again but until today my attempts to directly
load classes from other packages were unsuccessful. Today I finally
got the Buddy ClassLoading mechanism to work (see below). It requires
tampering with the eclipse plugins to add an entry to the manifest
files of those plugins from which classes should be loaded, but we can
do so during SWT instrumentation. So there's a chance for a better
solution in the future :-).

As of today, your approach was pretty good - you need to get access to
some class from the plugin that you want to load your class from. In
most cases this is rather difficult, but an
org.eclipse.ui.WorkbenchWindow object can be accessed directly via


and you can load other classes from the org.eclipse.ui package via


For classes from other packages you can manually make use of the Buddy
ClassLoading mechanism as follows:

In the org.eclipse.swt_3.7.1.v3738.jar (numbers may vary) edit
META-INF/MANIFEST.MF and add the line

Eclipse-BuddyPolicy: registered

In the plugin from which you intend to load classes, edit
META-INF/MANIFEST.MF and add the line

Eclipse-RegisterBuddy: org.eclipse.swt

After that you need to start eclipse (or your RCP application) once
with the argument -clean. I managed to get

from org.eclipse.ui import PlatformUI

working that way. My plan is to add a parameter to the
qfs.swt.instrument.setup procedure with a list of plugins to implement
that way automatically.

Best regards,

Stephen Bayne <stephen.bayne@?.com> writes:

> Hello,
> We seem to be having a bit of a problem with getting access to certain
> classes within Eclipse in an SUT Jython script.
> I have tried the following to get access to org.eclipse.ui.PlatformUI
> and none have worked:
> Copying Eclipse plugin jars to QF-Test's plugin directory: This gave
> us the class but outside the context of our application. Also found
> that it's not recommended to do it this way.
> Importing PlatformUI without any jars in the plugins directory:
> Resulted in an ImportError as Jython's ClassLoader is not very good
> with Eclipse classes.
> Getting the ClassLoader and calling loadClass() from an existing
> component using
> rc.getComponent("WorkbenchWindow").getClass().getClassLoader().loadClass("org.eclipse.ui.PlatformUI"):
> This throws a ClassNotFoundException.
> Getting QF-Test's run-context ClassLoader and calling loadClass()
> using
> rc.context.__class__.getClassLoader().loadClass("org.eclipse.ui.PlatformUI"):
> This also throws a ClassNotFoundException
> It is worth noting that using the latter two methods above to access
> any class under org.eclipse.swt.widgets works absolutely fine.
> My question then is this: How can we get access to the classes in
> eclipse bundles outside of SWT using Jython?
> Any help is very much appreciated.
> Regards,
> Stephen

Gregor Schmid                                Gregor.Schmid@?.de
Quality First Software GmbH                     http://www.qfs.de
Tulpenstr. 41                               Tel: +49 8171 38648-0
DE-82538 Geretsried                         Fax: +49 8171 3864816
GF: Gregor Schmid, Karlheinz Kellerer          HRB München 140833