Bug 150225 - Flag a missing EE header
Summary: Flag a missing EE header
Status: VERIFIED FIXED
Alias: None
Product: PDE
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.2   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: 3.4 M3   Edit
Assignee: PDE-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: bugday, contributed, noteworthy
: 189579 189580 (view as bug list)
Depends on: 179213
Blocks:
  Show dependency tree
 
Reported: 2006-07-11 05:04 EDT by Aaron Digulla CLA
Modified: 2011-06-20 13:42 EDT (History)
8 users (show)

See Also:
caniszczyk: review? (caniszczyk)


Attachments
mylyn/context/zip (1.20 KB, application/octet-stream)
2007-09-10 14:34 EDT, Chris Aniszczyk CLA
no flags Details
patch (9.72 KB, patch)
2007-09-11 16:33 EDT, Nobody - feel free to take it CLA
no flags Details | Diff
mylyn/context/zip (3.19 KB, application/octet-stream)
2007-09-24 08:11 EDT, Chris Aniszczyk CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Aaron Digulla CLA 2006-07-11 05:04:53 EDT
After installing the plugin eZing Builder (http://sourceforge.net/projects/ezingbuilder), I couldn't open the editor. I always got "ClassNotFoundException".

The root cause was that I was running Eclipse with Java 1.4 but the plugin contains classes which are compiled against Java 1.5.

I'd like to see two enhancements:

- When a plugin contains classes which require Java 1.5, the builder in PDE should disallow to export it without the necessary Execution Environment.

- When the classloader can't load a class because it requires a different Java runtime, it should say so (instead of "The editor class could not be instantiated. This usually indicates that the editor's class name was mistyped in plugin.xml.").

This second enhancement is probably part of Equinox:

java.lang.ClassNotFoundException: com.neusoft.ezingbuilder.designer.editors.HtmlFckDesignerMultiPageEditor
at org.eclipse.osgi.framework.internal.core.BundleLoader.findClass(BundleLoader.java:407)
at org.eclipse.osgi.framework.internal.core.BundleLoader.findClass(BundleLoader.java:352)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:83)
at java.lang.ClassLoader.loadClass(Unknown Source)
Comment 1 Pascal Rapicault CLA 2006-07-11 09:39:06 EDT
This type of error would not happen if the author of the plug-in you are using had specified the required execution environment (see http://wiki.eclipse.org/index.php/Execution_Environments and http://lenettoyeur-on-eclipse.blogspot.com/2006/07/setting-bundle-requiredexecutionenviro.html)
You should open a bug against the author of the component.

Moving to the UI team to see if they can report a better problem.
Note that this could tie in with the serviceability solution.
Comment 2 Aaron Digulla CLA 2006-07-11 15:01:51 EDT
> if the author of the plug-in you are using
> had specified the required execution environment

Yes, you are correct but the same would happen if I accidentially added a JAR, which was compiled with Java 1.5 for some reason, to a plugin.

As long as I run Eclipse with Java 1.5, I wouldn't notice. Therefore my request that PDE should check for these kinds of errors and complain when someone tries to export such a broken plugin.
Comment 3 Wassim Melhem CLA 2006-07-11 16:48:21 EDT
>Therefore my request that PDE should check for these kinds of errors and >complain when someone tries to export such a broken plugin.

Not sure what you mean by "checking for such errors".  The plug-in is not broken.  If it were, the export would fail.

The plug-in just does not specify an execution environment.  No need for PDE to interfere here.  an execution environment is useful/recommended, but it is optional, and not having it is not an error.
Comment 4 Wassim Melhem CLA 2006-07-11 16:51:22 EDT
If the behaviour you see at runtime (ie. the classloading error) is mystifying, then I suggest you reopen and move the bug to Equinox for better error reporting.
Comment 5 Aaron Digulla CLA 2006-07-11 17:02:26 EDT
As it is now, Eclipse requires Java 1.4, so plugins cannot expect to have Java 1.5.

On the other hand, it's perfectly possible to create plugins which *require* Java 1.5 without an execution environment.

From my point of view, that's like digging a hole and waiting for someone to fall into it.

As Java 1.5 becomes more and more widespread, more and more plugins will break.

So, as I said in my first comment, PDE should only allow to create plugins without exec env as long as they don't need features which are outside the default exec env (probably Java SDK 1.4).

I'll create a second bug report for Equinox so we can keep these issues apart.
Comment 6 Wassim Melhem CLA 2006-07-11 17:10:44 EDT
I see what you are saying, but PDE can't police the plug-ins and introspect the code in real time to make sure you have an EE defined if you are using a Java5 feature.

Plus, your code may have a path that uses Java5 features, but that path may only get executed in very specific scenarios, so this plug-in would run just fine with 1.4 under normal circumstances.

This is all very subjective.  That is why PDE should remain out of the way, and it is up to the owner of the plug-in to specify the Execution Environment if one is needed.

Comment 7 Aaron Digulla CLA 2006-07-11 17:22:41 EDT
Of course, there might be corner cases but generally, all class files in a JAR will have been compiled with the same Java version, so checking the bytecode version of just one file in every jar should be enough to generate a warning.

Right now, many plugin developers are unaware that the issue even exists. As a user, I must manually check that the plugin will run even though Eclipse would provide the means.

Maybe for 3.2.1, you could enforce the EE a bit more, ie. generate a warning when it's not set? This way, the person who should know (the developer) can make an educated guess instead of putting this issue on the shoulders of the users.

Wasn't there a FindBugs-like thing for plugins? I thought I remembered something but I'm not sure.
Comment 8 Wassim Melhem CLA 2006-07-11 17:46:20 EDT
As mentioned above, a missing EE header is not an error.  However, it may be desirable by some teams/companies to enforce having it.  So this seems like a reasonable request, and we already have a flag for EE validation in the plug-in compiler preferences.

I'll reopen and rename the bug report to reflect the new focal point.

This is certainly is not a 3.2.x issue though.  It will be evaluated for 3.3 and it will depend on how much we want to enforce having an EE in manifests.
Comment 9 Wassim Melhem CLA 2006-07-11 17:47:15 EDT
The real issue here still needs to be addressed at the platform level which is to give a good error message instead of a class not found exception.

The warning at the PDE level is just a nice-to-have.
Comment 10 Wassim Melhem CLA 2007-05-29 15:16:15 EDT
*** Bug 189580 has been marked as a duplicate of this bug. ***
Comment 11 Wassim Melhem CLA 2007-05-29 15:31:43 EDT
*** Bug 189579 has been marked as a duplicate of this bug. ***
Comment 12 Chris Aniszczyk CLA 2007-09-05 18:50:13 EDT
This is a fairly straightforward warning / quickfix Adam.
Comment 13 Thomas Watson CLA 2007-09-06 08:57:57 EDT
Chris, what did you have in mind for the recommended quickfix.  The developer still needs to make an educated decision on the EE level they want to choose.  Would the quickfix list all the valid EEs a developer can choose?
Comment 14 Chris Aniszczyk CLA 2007-09-06 10:09:05 EDT
Simply a configurable problem marker (warning by default) that tells people that they don't have an EE set. The quickfix can simply set the EE header and let you autocomplete it (which you can do already). We could be smarter and even put down an initial EE as part of the quickfix based on your default JRE and its current perfect match EE.
Comment 15 Adam Archer CLA 2007-09-06 11:41:39 EDT
Moving off PDE.

Back to inbox.
Comment 16 Nobody - feel free to take it CLA 2007-09-10 14:12:45 EDT
Hi guys, i'll take pick this one up again if no one minds.
Comment 17 Chris Aniszczyk CLA 2007-09-10 14:15:07 EDT
Hi Gary, we love contributors ;)

I'm assigning it to you.

Once you're done, we will need a "leafy background" picture of you to put on our PDE hall-of-fame webpage (http://www.eclipse.org/pde/pde-ui/committers/committers.php).

Let us know if you have any troubles or need help, we're here!
Comment 18 Chris Aniszczyk CLA 2007-09-10 14:34:32 EDT
Here is a Mylyn context in your honor Gary ;)
Comment 19 Chris Aniszczyk CLA 2007-09-10 14:34:35 EDT
Created attachment 78007 [details]
mylyn/context/zip
Comment 20 Nobody - feel free to take it CLA 2007-09-11 16:33:21 EDT
Created attachment 78108 [details]
patch
Comment 21 Chris Aniszczyk CLA 2007-09-11 18:31:11 EDT
Setting up a depends relationship on adding the EE selection back the New Plug-in Project wizard.
Comment 22 Chris Aniszczyk CLA 2007-09-11 18:35:45 EDT
btw Gary, the patch was beautiful, just need to wait on one more item because
right now, what happens is when you create a new plug-in project you get a
warning right off the bat since no EE is set. We need to make that not happen
and that is done via bug 179213
Comment 23 Nobody - feel free to take it CLA 2007-09-11 19:50:47 EDT
Should i start looking into bug 179213 to resolve this?
Comment 24 Chris Aniszczyk CLA 2007-09-12 14:24:21 EDT
Assigned it to you Gary. We will need a picture of you in a leafy background to go on our PDE hall of fame ;)

http://www.eclipse.org/pde/pde-ui/committers/committers.php
Comment 25 Chris Aniszczyk CLA 2007-09-21 11:02:18 EDT
moving to M3
Comment 26 Chris Aniszczyk CLA 2007-09-24 08:11:31 EDT
thanks Gary, patch was pretty clean.

I've created a TODO to refactor some of the code in the resolution to the VMHelper class to minimize redundancy.
Comment 27 Chris Aniszczyk CLA 2007-09-24 08:11:36 EDT
Created attachment 79069 [details]
mylyn/context/zip
Comment 28 Brian Bauman CLA 2007-10-30 18:49:15 EDT
Verified on I20071030-0010
Comment 29 Chris Aniszczyk CLA 2007-10-30 21:05:05 EDT
will mark this noteworthy, part of the EE for the new plug-in project wizard
Comment 30 Martin Oberhuber CLA 2008-02-05 14:58:12 EST
Stumbling over this warning in my Doc plugins.

I'm wondering what the PDE team thinks would be a proper setting of Bundle-RequiredExecutionEnvironment if my bundle does not have anything executable (like my doc plugins)?

I'm trying to keep exactly the same compiler settings for all my plugins, so I'd like to avoid having a different warning level in the doc plugins than the code plugins.
Comment 31 Chris Aniszczyk CLA 2008-02-05 15:03:30 EST
(In reply to comment #30)
> Stumbling over this warning in my Doc plugins.

Which version are Eclipse are you using?

Are your doc plug-ins java projects by mistake? It's possible to be a Plug-in project without being a Java project.
Comment 32 Martin Oberhuber CLA 2008-02-05 15:07:29 EST
Using I20080129-1400

It's got a PDE nature indeed although it's not a Java project -- guess the EE warning should be disabled in that case? Here is the .project file:

<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
	<name>org.eclipse.rse.doc.user</name>
	<comment></comment>
	<projects>
	</projects>
	<buildSpec>
		<buildCommand>
			<name>org.eclipse.pde.ManifestBuilder</name>
			<arguments>
			</arguments>
		</buildCommand>
		<buildCommand>
			<name>org.eclipse.pde.SchemaBuilder</name>
			<arguments>
			</arguments>
		</buildCommand>
	</buildSpec>
	<natures>
		<nature>org.eclipse.pde.PluginNature</nature>
	</natures>
</projectDescription>
Comment 33 Chris Aniszczyk CLA 2008-02-05 15:22:30 EST
Brian and I can't see anything... can you try rebuilding the project...? I think it's a stale marker as there was a time when we had an issue with validating non-Java projects when we shoudln't have.
Comment 34 Martin Oberhuber CLA 2008-02-05 16:19:06 EST
Right, the warnings were gone on a clean rebuild.
Thanks for your help!