Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 151172 - PDE Manifest Editor should treat OSGI manifest headers as case insensitive
Summary: PDE Manifest Editor should treat OSGI manifest headers as case insensitive
Status: RESOLVED FIXED
Alias: None
Product: PDE
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P3 normal with 2 votes (vote)
Target Milestone: 3.3 M7   Edit
Assignee: Brian Bauman CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 162583 172045 (view as bug list)
Depends on: 144355
Blocks:
  Show dependency tree
 
Reported: 2006-07-19 23:48 EDT by Simon Archer CLA
Modified: 2007-04-23 15:14 EDT (History)
10 users (show)

See Also:


Attachments
org.eclipse.pde.ui.patch (952 bytes, patch)
2006-07-20 00:26 EDT, Chris Aniszczyk CLA
no flags Details | Diff
patch for pde.core and pde.ui (42.94 KB, patch)
2007-04-23 11:37 EDT, Brian Bauman CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Simon Archer CLA 2006-07-19 23:48:55 EDT
The default color of the reserved OSGi manifest headers is "Red/Bold", whereas the color for all other headers is "Red".  It is too difficult to distinguish the two, making it harder to spot cases where to misspell a header, such as "Bundle-Classpath" when you should have typed "Bundle-ClassPath".

My preference would be for the reserved OSGi manifest headers to be "Blue/Bold".
Comment 1 Chris Aniszczyk CLA 2006-07-20 00:26:00 EDT
Created attachment 46560 [details]
org.eclipse.pde.ui.patch

I didn't notice they were red ;) This helps my red/green color blind arse.
Comment 2 Chris Aniszczyk CLA 2006-07-20 00:26:13 EDT
+1 Wassim
Comment 3 Wassim Melhem CLA 2006-07-20 11:27:57 EDT
Chris, blue does not match with anything in PDE.

Lavender and Salmon are supposed to be hot this fall.
Comment 4 Chris Aniszczyk CLA 2006-07-20 15:07:25 EDT
What about pink? In all seriousness, we need a friendly color :) Do we need to have a vote ;)?
Comment 5 Simon Archer CLA 2006-07-20 16:14:58 EDT
It does not really matter.  Just make it bold, clear and distinct from regular manifest headers.  That's why I like bold blue.
Comment 6 Chris Aniszczyk CLA 2006-07-20 16:16:50 EDT
What's your favorite color Tom ;)?
Comment 7 Jeff McAffer CLA 2006-07-20 23:13:32 EDT
you guys have too much time.  must be summer.  FWIW I thought headers were case insenstive.  Perhaps we are assigning the wrong color regardless of what the color is.
Comment 8 Wassim Melhem CLA 2006-07-20 23:15:56 EDT
oh they're sensitive.  good luck trying to run with Bundle-Classpath instead of Bundle-ClassPath.
Comment 9 Jeff McAffer CLA 2006-07-20 23:21:56 EDT
that's strange.  I was sure we have whacky code in there to make the headers case insensitive.  Headers.get(key) has a comment that says, 
 * support case-insensitivity for keys

Tom?
Comment 10 Thomas Watson CLA 2006-07-21 09:23:00 EDT
Sorry Wassim, headers are definately case INsensitive.  If bundle-classpath does not work then it is likely a "bug" in PDE in setting up the dev classpath ;-)

As color goes, I like it the way it is because it matches the color for key words used in the Java editor.  Can the color for key words be customized?

Also, I'm seeing OSGi manifest headers show up bold.  I can clearly tell they are different for regular manifest headers.  Am I imagining things?
Comment 11 Wassim Melhem CLA 2006-07-21 09:31:38 EDT
does Equinox treat them insensitively or is this a standard behavior?

All colors can be customized on the Plug-in Development > Editors preference page > MANIFEST.MF syntax highlighting.  

I like the fact that OSGi headers are the same color as regular headers but in bold.  A header is a header after all.  

Red is consistent with Java as Tom points out.

I suggest not taking any action here wrt colors, since they are customizable, unless Chris feels otherwise about accessibility.
Comment 12 Simon Archer CLA 2006-07-21 09:33:52 EDT
Tom, you've got young eyes!  While you are correct that "red" and "bold red" are distinct on careful inspection, I'm more in favor of two separate colors for JAR manifest headers and bundle manifest headers that can be spotted immediately regardless of the font, screen resolution, distance from the monitor and eye capacity!
Comment 13 Thomas Watson CLA 2006-07-21 10:20:20 EDT
The Equinox Framework does handle the header keys case insensitively.  This is standard spec'ed behavior according the the jar manifest specification.  I was under the impression that this is standard behavior of the jar Manifest class as well, but we do not use that class in the framework so I could be wrong.

I don't have a strong opinion either way on color of non-OSGi headers.  It does make some sense to make them use just the standard text color (black) instead of the color used to highlight key words.
Comment 14 Jeff McAffer CLA 2006-07-22 20:57:40 EDT
Two things
- we need to track down this case insensitivity thing.  Wassim is claiming that it doesn't work.  Tom and I are claiming that it should work.  PDE should be coloring as per the spec and Equinox should be running according to the spec.  Who is doing what?

- Given the problems I have with the eclipse.org web site I am loath to counter Simon's arguments.  For the record however, I will say that for me, red and bold red are readily (haha pun!) distinguishable and that these things really are "shades of one another" (manifest header and OSGi header) so bolding is appropriate.  Beyond that I am perfectly happy with flaming pink and dayglow green.  It would look like angry fruit salad.  (btw, I'm not keen on leaving them black)
Comment 15 Wassim Melhem CLA 2006-09-18 00:37:18 EDT
Since the colors are customizable, we will take no action on changing defaults.  They are fine.

Will keep the bug open to track the case (in)sensitivity issue.
Comment 16 Thomas Watson CLA 2006-09-18 09:28:05 EDT
There is no room for discussion, the OSGi specification follows the jar manifest syntax which states the following for "Attributes" (which are header names)

Attributes: 
In all cases for all sections, attributes which are not understood are ignored. 

Attribute names are case insensitive. Programs which generate manifest and signature files should use the cases shown in this specification however. 

Attribute names cannot be repeated within a section.

See http://java.sun.com/j2se/1.3/docs/guide/jar/jar.html#Main%20Attributes
Comment 17 Brian Bauman CLA 2006-09-19 18:27:46 EDT
Will look at fixing this post M2.
Comment 18 Jim Adams CLA 2006-09-22 14:13:21 EDT
Was a bug ever opened on the case sensativity issue? I just spent 2 days trying to figure out why the jars in my plugin were not visible to PDE NOR the runtime. Turns out the problem was that I had Bundle-Classpath instead of Bundle-ClassPath. The PDE Manifest editor showed them as not bold and bold when I fixed the case. I also see contants in the code for Bundle-ClassPath. In debugging the code the PluginInfo object had no entries for the libraries in my plugin/bundle when the case was wrong.
Comment 19 Joel Kamentz CLA 2006-09-22 14:30:24 EDT
An additional data point.  For me, if the case-sensitivity only shows up for a plugin when it is expanded and the manifest is a loose file.  I can take the exact same content, jar it up and have it work.
Comment 20 Jim Adams CLA 2006-09-22 14:31:56 EDT
That is because the default for Bundle-ClassPath is . Since Bundle-ClassPath is missing this works by happy accident.
Comment 21 Wassim Melhem CLA 2006-10-27 18:12:43 EDT
*** Bug 162583 has been marked as a duplicate of this bug. ***
Comment 22 Chris Aniszczyk CLA 2006-11-16 16:59:02 EST
We now depend on another jface text fix that I have a patch against.

Once this is fixed, we should be able to handle case insensitivity. One thing we may have to do is update some of our error reporters to be case insensitive too :(
Comment 23 Chris Aniszczyk CLA 2007-01-29 15:11:29 EST
*** Bug 172045 has been marked as a duplicate of this bug. ***
Comment 24 Wassim Melhem CLA 2007-03-15 03:45:09 EDT
Brian, I am putting this one on your plate.

What is more important than syntax highlighting is that the plug-in manifest editor model treats the header names without regard to case-sensitivity (see bug 172045)
Comment 25 Brian Bauman CLA 2007-04-20 13:28:52 EDT
Tom, are you sure the runtime supports case insensitivity?  In my target platform I have a bundle who uses "Bundle-Symbolicname" instead of "Bundle-SymbolicName".  When I try to create a BundleDescription for the element, I get a BundleException.  It seems that when we try to create a new BundleDescription, the StateBuilder.validateHeaders() is called.  This seems to look only for the case sensitive header "Bundle-SymbolicName" and if it can't find it, throws a BundleException.  

I doubled checked it this result with developing a similar bundle in my workspace.  Again, wrong capitalization for Bundle-SymbolicName.  For this case, PDE tooling highlights the header, validates it as correct, and allows the user to modify it with the Manifest Editor.  When I ran it, the bundle never showed up.

With no errors or indications from the tooling or runtime, this could cause headaches for users down the road.
Comment 26 Simon Archer CLA 2007-04-20 14:49:01 EDT
I just tried changing "Bundle-SymbolicName" to "Bundle-Symbolicname" for one of my plug-in projects in my workspace.  Once changed, the project was no recognized by PDE as a bundle.  For example, when I tried to export the projects using "File > Export > Deployable plug-ins and fragments" the project was not available to select.  Also, the Equinox launch configuration no longer recognized the projects as a bundle.

But the Equinox framework does not care at runtime.  I used PDE to exported the bundle to a JAR with the "Bundle-SymbolicName" set correctly, unzipped the JAR, changed the manifest to "Bundle-Symbolicname" and re-zipped the JAR.  I was able to install the JAR and start the bundle without problem.
Comment 27 Wassim Melhem CLA 2007-04-20 14:52:15 EDT
Brian,

when creating the state, we (PDE) read the manifest ourselves into a dictionary and send it to the runtime only if it has a Bundle-SymbolicName header.  I think this is the first place where we need to relax the case of the header.
Comment 28 Brian Bauman CLA 2007-04-20 15:18:29 EDT
Wassim, I traced the code and was able to find the Bundle-SymbolicName if the capitalization was not correct.  So far so good.  Then when we call stateObjectFactory.createBundleDescription and pass the dictionary with the incorrect capitalization, a BundleException is thrown and no BundleDescription is created.  

I tracked the BundleException down to org.eclipse.osgi.internal.resolver.StateBuilder.validateHeaders(Dictionary manifest, boolean jreBundle), line 193.  This line is executed when we look in the Dictionary for Constants.BUNDLE_SYMBOLICNAME and it returns null.
Comment 29 Wassim Melhem CLA 2007-04-20 15:27:46 EDT
Then I suggest opening a bug against equinox and make this bug dependent on it.
Comment 30 Thomas Watson CLA 2007-04-22 21:17:21 EDT
You will need to implement a Map which has case insensitive keys.  In the Framework the Headers class to accomplish this.

One way to solve this would be to copy the manifest headers passed to org.eclipse.osgi.internal.resolver.StateBuilder.validateHeaders into a case insensitive Map like the Headers class.  It is probably more appropriate to do that within the StateBuilder class instead of forcing clients of the StateObjectFactory to do it.
Comment 31 Brian Bauman CLA 2007-04-23 11:37:51 EDT
Created attachment 64626 [details]
patch for pde.core and pde.ui

Adding a patch of all the files modified just in case we run into problems and have to back out changes.
Comment 32 Brian Bauman CLA 2007-04-23 12:04:27 EDT
Should be fixed in 3.3M7.  

Copied the runtimes Headers class to create a case insensitive Dictionary element for when loading the State and create a TreeMap with a custom Comparator to store headers in a case insensitive manner.
Comment 33 Simon Archer CLA 2007-04-23 12:21:32 EDT
Thank you, Brian.
Comment 34 Wassim Melhem CLA 2007-04-23 12:29:01 EDT
That was a lot of work.  Thanks Brian.
Comment 35 Thomas Watson CLA 2007-04-23 13:46:19 EDT
Brian, can you describe the solution?  I was leaning toward a fix in StateObjectFactory.  I gather you came up with a fix outside the Framework.
Comment 36 Thomas Watson CLA 2007-04-23 14:21:23 EDT
Nevermind, I did not see comment 32 with Brians description.  Still not sure that is the right thing to do.  Brian please open a bug against Framework so we can think about fixing that in the framework in the future.  Unless you need a case-insensitive Map for other reasons ...
Comment 37 Wassim Melhem CLA 2007-04-23 15:14:15 EDT
Tom, we needed to do something as drastic as what Brian did for handling headers in the manifest editors, where we don't use State stuff.