Bug 456909 - Implementing Early Startup IStartup causes org.eclipse.core.runtime.CoreException
Summary: Implementing Early Startup IStartup causes org.eclipse.core.runtime.CoreExcep...
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Runtime (show other bugs)
Version: 4.5   Edit
Hardware: All All
: P3 major (vote)
Target Milestone: 4.5 M7   Edit
Assignee: Dani Megert CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 457132 (view as bug list)
Depends on:
Blocks:
 
Reported: 2015-01-07 07:42 EST by Phil Beauvoir CLA
Modified: 2017-05-26 02:02 EDT (History)
11 users (show)

See Also:


Attachments
Modified "Hello RCP" application (135.97 KB, application/zip)
2015-01-07 07:47 EST, Phil Beauvoir CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Phil Beauvoir CLA 2015-01-07 07:42:25 EST
Eclipse Version: Mars (4.5)
Build id: I20150106-0800

Implementing IStartup on an activator (AbstractUIPlugin) plug-in for an RCP app causes this:

!ENTRY org.eclipse.ui.workbench 4 2 2015-01-07 12:37:25.991
!MESSAGE Problems occurred when invoking code from plug-in: "org.eclipse.ui.workbench".
!STACK 1
org.eclipse.core.runtime.CoreException: Executable extension definition for "class" not found.
	at org.eclipse.core.internal.registry.ConfigurationElement.throwException(ConfigurationElement.java:62)
	at org.eclipse.core.internal.registry.ConfigurationElement.createExecutableExtension(ConfigurationElement.java:222)
	at org.eclipse.core.internal.registry.ConfigurationElementHandle.createExecutableExtension(ConfigurationElementHandle.java:55)
	at org.eclipse.ui.internal.WorkbenchPlugin.createExtension(WorkbenchPlugin.java:284)
	at org.eclipse.ui.internal.EarlyStartupRunnable.getExecutableExtension(EarlyStartupRunnable.java:90)
	at org.eclipse.ui.internal.EarlyStartupRunnable.run(EarlyStartupRunnable.java:49)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.ui.internal.Workbench$56.run(Workbench.java:2801)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
!SUBENTRY 1 org.eclipse.equinox.registry 4 1 2015-01-07 12:37:25.999
!MESSAGE Executable extension definition for "class" not found.
!SUBENTRY 1 org.eclipse.equinox.registry 4 1 2015-01-07 12:37:25.999
!MESSAGE Executable extension definition for "class" not found.

!ENTRY Test 4 0 2015-01-07 12:37:26.003
!MESSAGE Unable to execute early startup code for an extension
!STACK 1
org.eclipse.core.runtime.CoreException: Executable extension definition for "class" not found.
	at org.eclipse.core.internal.registry.ConfigurationElement.throwException(ConfigurationElement.java:62)
	at org.eclipse.core.internal.registry.ConfigurationElement.createExecutableExtension(ConfigurationElement.java:222)
	at org.eclipse.core.internal.registry.ConfigurationElementHandle.createExecutableExtension(ConfigurationElementHandle.java:55)
	at org.eclipse.ui.internal.WorkbenchPlugin.createExtension(WorkbenchPlugin.java:284)
	at org.eclipse.ui.internal.EarlyStartupRunnable.getExecutableExtension(EarlyStartupRunnable.java:90)
	at org.eclipse.ui.internal.EarlyStartupRunnable.run(EarlyStartupRunnable.java:49)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.ui.internal.Workbench$56.run(Workbench.java:2801)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
!SUBENTRY 1 org.eclipse.equinox.registry 4 1 2015-01-07 12:37:26.004
!MESSAGE Executable extension definition for "class" not found.
Comment 1 Phil Beauvoir CLA 2015-01-07 07:47:07 EST
Created attachment 249756 [details]
Modified "Hello RCP" application

Modified Test Project "Hello RCP". Implements IStartup in Activator class, and added "org.eclipse.ui.startup" extension point to plugin.xml.

Run as RCP application from Eclipse 4.5 Mars build. Error is logged to console.
Comment 2 Phil Beauvoir CLA 2015-01-07 07:59:37 EST
Note - no error is thrown in Eclipse 4.4 and implementing IStartup in this ways is supported.
Comment 3 Phil Beauvoir CLA 2015-01-08 05:37:40 EST
In the attached example project, it's not necessary to implement IStartup in the Activator class to trigger the exception, only the extension declaration in plugin.xml:

   <extension
         point="org.eclipse.ui.startup">
      <startup></startup>
   </extension>
Comment 4 Phil Beauvoir CLA 2015-01-08 05:42:37 EST
It turns out that if you explicitly set the class that implements IStartup thus:

   <extension
         point="org.eclipse.ui.startup">
      <startup
            class="test.Activator"></startup>
   </extension>

then the exception is not thrown.

However, the documentation for the extension point states:

"Do not specify the plug-in class as the value of the class attribute, or it will be instantiated twice (once by regular plug-in activation, and once by this mechanism)."

In Eclipse 4.4 not specifying the plug-in class (Activator in this example) works, and the startup() method is called. Not so in 4.5.
Comment 5 Phil Beauvoir CLA 2015-02-04 04:40:20 EST
I notice that in Eclipse 4.5 M5a there is now an error reported:

"Attribute 'class' of element 'startup' must be defined"

However, this conflicts with the documentation for org.eclipse.ui.startup:

"Do not specify the plug-in class as the value of the class attribute, or it will be instantiated twice (once by regular plug-in activation, and once by this mechanism)."
Comment 6 David Williams CLA 2015-04-10 18:28:49 EDT
Adding Tom to CC, in case related to changes in equinox.registry?
Comment 7 Lars Vogel CLA 2015-04-10 20:17:16 EDT
Class attribute became mandatory with the removal of the 2.0 campatibility layer, see Bug 455165 and related.

I thought we updated the (schema) documentation, can you point me to the documentation your are looking at?
Comment 8 Marco Hunsicker CLA 2015-04-12 19:33:03 EDT
(In reply to Phil Beauvoir from comment #4)

> In Eclipse 4.4 not specifying the plug-in class (Activator in this example)
> works, and the startup() method is called. Not so in 4.5.

I was using this approach as well (it's still mentioned in the wiki without any pointer to this breaking change). Are there any plans to reinstall support for this behavior or do plugins have to be adjusted with future releases?

My workaround for now is to use a separate class as required, get the plugin bundle and start it manually.
Comment 9 Dani Megert CLA 2015-04-13 04:30:53 EDT
Lars, we have to fix this for 4.5.

I agree with Konstantin that this was not properly communicated. Even if one reads our removals page [1], one cannot have known that this will affect the extension point.


[1] http://help.eclipse.org/luna/topic/org.eclipse.platform.doc.isv/porting/removals.html?cp=2_3_0
Comment 10 Lars Vogel CLA 2015-04-13 05:58:37 EDT
(In reply to Dani Megert from comment #9)
> Lars, we have to fix this for 4.5.
> 
> I agree with Konstantin that this was not properly communicated. Even if one
> reads our removals page [1], one cannot have known that this will affect the
> extension point.
> 
> 
> [1]
> http://help.eclipse.org/luna/topic/org.eclipse.platform.doc.isv/porting/
> removals.html?cp=2_3_0

See Bug 394739 for the removal of the 2.0 comp. layer. I think there is nothing to fix here, we enhanced the Javadoc and error messages via Bug 455165 and Bug 457132.
Comment 11 Dani Megert CLA 2015-04-13 06:04:01 EDT
(In reply to Lars Vogel from comment #10)
> (In reply to Dani Megert from comment #9)
> > Lars, we have to fix this for 4.5.
> > 
> > I agree with Konstantin that this was not properly communicated. Even if one
> > reads our removals page [1], one cannot have known that this will affect the
> > extension point.
> > 
> > 
> > [1]
> > http://help.eclipse.org/luna/topic/org.eclipse.platform.doc.isv/porting/
> > removals.html?cp=2_3_0
> 
> See Bug 394739 for the removal of the 2.0 comp. layer. 

How should one know that this affects the extension point?
Comment 12 Lars Vogel CLA 2015-04-13 07:16:16 EDT
(In reply to Dani Megert from comment #11)
> > See Bug 394739 for the removal of the 2.0 comp. layer. 
> 
> How should one know that this affects the extension point?

IIRC the extension point stated that this only works with the comp. layer present. See https://git.eclipse.org/r/#/c/36310/3/bundles/org.eclipse.ui/schema/startup.exsd where I removed this info after we removed the comp. layer.
Comment 13 Dani Megert CLA 2015-04-13 07:28:21 EDT
(In reply to Lars Vogel from comment #12)
> (In reply to Dani Megert from comment #11)
> > > See Bug 394739 for the removal of the 2.0 comp. layer. 
> > 
> > How should one know that this affects the extension point?
> 
> IIRC the extension point stated that this only works with the comp. layer
> present. See
> https://git.eclipse.org/r/#/c/36310/3/bundles/org.eclipse.ui/schema/startup.exsd
> where I removed this info after we removed the comp. layer.

That may be, but we cannot expect that our users read all extension point doc and all Java type doc to check whether they might get broken. This needs to be listed in the removals doc. If we can't add code that simply supports the old-style of the extension point, then we have to revert the compat layer for 4.5.
Comment 14 Marco Hunsicker CLA 2015-04-13 08:50:39 EDT
> That may be, but we cannot expect that our users read all extension point
> doc and all Java type doc to check whether they might get broken.

My personal expectation would have been to read about this change in the plug-in migration guide. From the error message and the Javadoc it is clear what changes one has to apply to conform with the API, but IMHO it would be better to be able to read about it upfront.

Plus, currently there is no information available how to mimic the previous behavior, which might be intentional given that lazy activation is recommended and favorable. It took me about 10 minutes to come up with a solution, which fares really quite well compared to the competition. But including a pointer to a wiki entry with the relevant code in the migration guide would be nice and should really ease any pain this change might yield.


> This needs  to be listed in the removals doc.

+1


> If we can't add code that simply supports
> the old-style of the extension point, then we have to revert the compat
> layer for 4.5.

If you don't want to break plugins at all cost, this seems like the easiest solution. Personally, I don't mind to have to perform housekeeping from time to time. It should affect only a minority of plugins anyway.

Thanks much for all your work!
Comment 15 Lars Vogel CLA 2015-04-13 08:55:14 EDT
(In reply to Dani Megert from comment #13)
> That may be, but we cannot expect that our users read all extension point
> doc and all Java type doc to check whether they might get broken. This needs
> to be listed in the removals doc. 

I think that is how we define API. IIRC the removal was started in 4.2 (I was not involved in this discussion) so John or Paul might have more info  on this.

If we can't add code that simply supports
> the old-style of the extension point, then we have to revert the compat
> layer for 4.5.

The removal and / or deprecation of the compatibility resulted in several commits all over the places, I don't think it is realistic or desirable to restore it in M7. But again IIRC the plan was started in 4.2 without my involvement so maybe people like John or Paul can give more input here.
Comment 16 Dani Megert CLA 2015-04-13 09:15:27 EDT
(In reply to Lars Vogel from comment #15)
> (In reply to Dani Megert from comment #13)
> > That may be, but we cannot expect that our users read all extension point
> > doc and all Java type doc to check whether they might get broken. This needs
> > to be listed in the removals doc. 
> 
> I think that is how we define API. IIRC the removal was started in 4.2 (I
> was not involved in this discussion) so John or Paul might have more info 
> on this.

We agree that the removal was not communicated/written well enough.

 
> If we can't add code that simply supports
> > the old-style of the extension point, then we have to revert the compat
> > layer for 4.5.
> 
> The removal and / or deprecation of the compatibility resulted in several
> commits all over the places, I don't think it is realistic or desirable to
> restore it in M7.

I'm pretty sure we could revert the responsible commits, but it should also be possible to support the old-style extension point without doing that.
Comment 17 Lars Vogel CLA 2015-04-13 10:29:16 EDT
For reference, the info that this described usage of the extension point is deprecated, should no longer be used and depends on the comp. layer seems to have added 2006 with the following commit:

http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/?id=6c0feb455e1e3b22c5bd7a0c979ead667c317d2d
Comment 18 Konstantin Komissarchik CLA 2015-04-13 12:30:34 EDT
> For reference, the info that this described usage of the extension point is
> deprecated, should no longer be used and depends on the comp. layer seems to
> have added 2006 with the following commit:
> 
> http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/?
> id=6c0feb455e1e3b22c5bd7a0c979ead667c317d2d

This by itself is insufficient as a means to properly notify the community of deprecation and eventual removal. It doesn't account for existing extensions. It doesn't account for the fact that extensions are often added by copy-paste from other plugins. It doesn't account for the fact that extension point documentation, especially for simple extension points, is often never read.

Note that I am not asking for a reversal. My goal is ensure that similar changes are communicated better next time and to ensure that the bundles with breaking API changes have an incremented major version component.
Comment 19 Lars Vogel CLA 2015-04-13 15:00:42 EDT
(In reply to Konstantin Komissarchik from comment #18)

> Note that I am not asking for a reversal. My goal is ensure that similar
> changes are communicated better next time and to ensure that the bundles
> with breaking API changes have an incremented major version component.

I agree to that, as soon as we in the platform.ui realized that this info was missing we added it to the migration guide for 4.5 (beginning of this year) See https://git.eclipse.org/c/platform/eclipse.platform.common.git/commit/?id=bddd25a0ff2903c4edfdec84f7c21dc025401784 

I was not aware that this stuff is communicated also via email
Comment 20 Dani Megert CLA 2015-04-14 10:25:04 EDT
(In reply to Dani Megert from comment #16)
> I'm pretty sure we could revert the responsible commits, but it should also
> be possible to support the old-style extension point without doing that.

The old-style way already heavily relied on reflection. Now, instead of calling removed methods we can get the bundle activator from BundleContextImpl via reflection in case the class attribute is not there. In addition we log a warning, telling that this should be fixed in the code. A test also needs to be added which verifies that the reflection still works in newer releases.

Lars, or anyone else on this bug, can you provide a Gerrit change for review? Thanks.
Comment 21 Lars Vogel CLA 2015-04-14 11:42:04 EDT
I try to look this next week, can't promise anything, as I already have lots of other things on my hand. So is someone else can pick this up, that would be great.

Can also clients indicate how important that temporary support is for them? The solution on the client side is relatively easy IMHO.
Comment 22 Dani Megert CLA 2015-04-14 12:47:48 EDT
(In reply to Lars Vogel from comment #21)
> Can also clients indicate how important that temporary support is for them?
> The solution on the client side is relatively easy IMHO.

No one doubts that it is easy to fix on the client side. But assume you have downloaded a few plug-ins some time ago and they are no longer maintained. Maybe you even only have the binaries. You would be pretty frustrated that you can no longer use it, and so would I be.
Comment 23 Dani Megert CLA 2015-04-16 08:24:51 EDT
This is actually trivial to fix since the compatibility layer is still there in 4.5.

I've reverted the change from bug 44584 and also log a warning when the 'class' attribute is not there.

Fixed with http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/?id=4d6cbc5234a2d5216fdaf1551bc5b69ee25507e7

Bug 445484 has been reopened to properly announce the change in 4.5 and remove it during 4.6.
Comment 24 Dani Megert CLA 2015-04-16 08:26:11 EDT
(In reply to Dani Megert from comment #23)
> I've reverted the change from bug 44584

Sorry, it's bug 445484.
Comment 25 Dani Megert CLA 2015-04-16 08:26:20 EDT
*** Bug 457132 has been marked as a duplicate of this bug. ***
Comment 26 Lars Vogel CLA 2015-04-16 10:07:26 EDT
Thanks Dani for handling the fix for 4.5.
Comment 27 Marcel Bruch CLA 2015-04-25 05:51:10 EDT
FWIW, I'm linking the two most popular platform error reports (in total ~1.000 users) to this bug.


https://dev.eclipse.org/recommenders/committers/confess/#/problems/551194a2e4b0b71121dad676/details
https://dev.eclipse.org/recommenders/committers/confess/#/problems/54c4f0a7bee810030da08462/details
Comment 28 Eclipse Genie CLA 2015-07-30 12:26:19 EDT
New Gerrit change created: https://git.eclipse.org/r/52879