Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 407201 - Source bundles for org.eclipse.osgi.services and -.util broken
Summary: Source bundles for org.eclipse.osgi.services and -.util broken
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Releng (show other bugs)
Version: 4.3   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: 4.4 M5   Edit
Assignee: Thomas Watson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 407868 (view as bug list)
Depends on:
Blocks: 407623 407915
  Show dependency tree
 
Reported: 2013-05-03 15:21 EDT by Markus Keller CLA
Modified: 2014-05-17 16:34 EDT (History)
7 users (show)

See Also:


Attachments
services.patch (1.38 KB, patch)
2013-05-04 12:14 EDT, Thanh Ha CLA
no flags Details | Diff
patch v2 (5.69 KB, patch)
2013-05-07 23:00 EDT, Thanh Ha CLA
no flags Details | Diff
patch fix missing root (3.08 KB, patch)
2013-05-13 10:44 EDT, Thanh Ha CLA
no flags Details | Diff
Summary of compile errors in test build (574.28 KB, text/plain)
2013-05-13 15:00 EDT, David Williams CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Keller CLA 2013-05-03 15:21:55 EDT
I20130502-0800

org.eclipse.osgi.services.source_3.3.100.v20130327-1440.jar and org.eclipse.osgi.util.source_3.2.300.v20130327-1440.jar have various problems:

- contain 2 copies of *.class files (at root and inside  'target' folder)
- contain other wrong content like .classpath and .project
- the source files/folders are not at the root of the JAR but in an embedded src.zip

I didn't see such problems in other bundles.
Comment 1 Thomas Watson CLA 2013-05-03 16:27:07 EDT
This project has a PDE build customBuildCallbacks script that obviously is not getting used during the CBI builds.  At this point I am unsure how we fix this in CBI.
Comment 2 Thanh Ha CLA 2013-05-04 12:14:54 EDT
Created attachment 230476 [details]
services.patch

Had some free time this morning so I thought I'd give this a try. The attached patch produces a sources.jar with the java sources in root.

However there are several things wrong with this patch since I made some assumptions that are likely wrong as well as caused other issues.

Assumptions:
- src.zip is pre-unzipped into the bundle directory
- tried to avoid using maven-antrun-plugin
- that it was ok for *.class and *.java files to exist in the same directory

Issues:
- the non-source.jar now contains *.java files in addition to *.class files :(
- you must manually unzip src.zip for the bundle before running the build

I tried putting src.zip files into a subdirectory such as src/ but when I added that into "src.includes = src/" it would include the src/ folder as part of the path too, I'm not sure if there's a way to tell build.properties to use src/ as a root path?

I'm probably taking the wrong approach but hope it spurs some ideas.
Comment 3 Dani Megert CLA 2013-05-06 04:49:30 EDT
Should try to get this fixed for 4.3.
Comment 4 David Williams CLA 2013-05-07 21:29:39 EDT
(In reply to comment #2)

> - tried to avoid using maven-antrun-plugin

I think at this point in Kepler, if we can fix using antrun plugin, using existing "customBuildCallbacks", that would be suffice (i.e. great even). 

No idea if the customBuildCallback would work "as is", or need a lot of adjustment ... just saying we should not hesitate to use antrun at this late date.
Comment 5 Thanh Ha CLA 2013-05-07 23:00:41 EDT
Created attachment 230622 [details]
patch v2

I think I have a working patch now.

I use antrun to unzip src.zip into the project dir so now both *.java and *.classes files exist in the same "org/" directory.

I then use tycho-packaging-plugin's "additionalFileSets" configuration to filter only *.classes files for inclusion in the bundle.jar. I also removed "org/" from build.properties bin.includes= parameter so that it doesn't pull in the *.java files.

I use tycho-source-plugin to filter "*.java" and "packageinfo" files for inclusion in the sources.jar

As far as I can tell the bundle.jar and sources.jar appear to create similar contents from those of Juno SR2 PDE build. One discrepancy I noticed but I'm not sure if it's a problem is there appears to be adding additional metadata files in the sources.jar listed below.

   creating: OSGI-INF/
   creating: OSGI-INF/l10n/
  inflating: OSGI-INF/l10n/bundle-src.properties
Comment 6 Thomas Watson CLA 2013-05-08 08:52:30 EDT
I will review and release patch.(In reply to comment #5)

> As far as I can tell the bundle.jar and sources.jar appear to create similar
> contents from those of Juno SR2 PDE build. One discrepancy I noticed but I'm
> not sure if it's a problem is there appears to be adding additional metadata
> files in the sources.jar listed below.
> 
>    creating: OSGI-INF/
>    creating: OSGI-INF/l10n/
>   inflating: OSGI-INF/l10n/bundle-src.properties

That is strange, I will have to take a look at the content when a build is done.  I am curious if the source bundle has a Bundle-Localization header.
Comment 7 Thomas Watson CLA 2013-05-08 09:28:56 EDT
An issue with the patch is that it breaks exporting the bundle using PDE from the workspace.  Not sure if we can get a solution that works for both CBI and PDE-Build.  If I had to choose I would get the CBI build correct since breaking the export of this project from the workspace will impact very few developers.  We can always add a PDE specific build.properties that one would need to rename when trying to export these bundles if they need to.
Comment 8 Thomas Watson CLA 2013-05-08 15:35:59 EDT
I went ahead and released this fix so that we can get a test build:

http://git.eclipse.org/c/equinox/rt.equinox.framework.git/commit/?id=6447261180fce2fef30fbdc7175b49fa025f6864
Comment 9 David Williams CLA 2013-05-08 18:29:35 EDT
(In reply to comment #8)
> I went ahead and released this fix so that we can get a test build:
> 
> http://git.eclipse.org/c/equinox/rt.equinox.framework.git/commit/
> ?id=6447261180fce2fef30fbdc7175b49fa025f6864

Well, it didn't break the build. But, no idea if its right. :) 

You can "see" the results of test build on build machine at 

http://build.eclipse.org/eclipse/builds/4I/siteDir/eclipse/downloads/drops4/I20130508-1535/
Comment 10 Thomas Watson CLA 2013-05-08 21:54:41 EDT
The content of the source bundles looks correct to me, but they still don't seem to work as proper source bundles by PDE.  I'm not sure why but when looking up any source contained in the osgi.services bundle PDE is not finding the source still.
Comment 11 David Williams CLA 2013-05-09 03:34:39 EDT
To cross reference, think these changes are related to bug 407623. 

FYI, there is long bug where Curtis was explaining what form source had to be in for multiple source folders ... bug 400740 ... perhaps that'd give some insight?
Comment 12 Thomas Watson CLA 2013-05-09 08:19:45 EDT
Curtis, could you have a look at the latest org.eclipse.osgi.services.source bundle to see if you can spot what is wrong with it from the PDE perspective?
Comment 13 Curtis Windatt CLA 2013-05-09 10:02:11 EDT
(In reply to comment #12)
> Curtis, could you have a look at the latest org.eclipse.osgi.services.source
> bundle to see if you can spot what is wrong with it from the PDE perspective?

I haven't debugged, but the source roots is listed as "", when it should be ".".
Comment 14 Curtis Windatt CLA 2013-05-09 11:19:11 EDT
The missing '.' (meaning the source is at the root of the bundle) is the problem, but not because PDE is looking at the source in the wrong place.  We actually get an exception when trying to parse the header.  It appears that having a header value of a 0 length string gets replaced with null and osgi utils throws an exception.  PDE throws the source bundle out as its header can't be parsed.

org.osgi.framework.BundleException: Invalid manifest header Eclipse-SourceBundle: "org.eclipse.osgi.services;version="3.3.100.v20130508-1933";roots:="""
	at org.eclipse.osgi.util.ManifestElement.parseHeader(ManifestElement.java:414)
	at org.eclipse.pde.internal.core.BundleManifestSourceLocationManager.setPlugins(BundleManifestSourceLocationManager.java:202)
Comment 15 Thanh Ha CLA 2013-05-13 09:59:37 EDT
I think this is because my patch removes the line:

    sources..=.

But if I don't remove that line Tycho will try to compile the code and fail.
Comment 16 Thomas Watson CLA 2013-05-13 10:15:03 EDT
(In reply to comment #14)
> The missing '.' (meaning the source is at the root of the bundle) is the
> problem, but not because PDE is looking at the source in the wrong place. 
> We actually get an exception when trying to parse the header.  It appears
> that having a header value of a 0 length string gets replaced with null and
> osgi utils throws an exception.  PDE throws the source bundle out as its
> header can't be parsed.
> 
> org.osgi.framework.BundleException: Invalid manifest header
> Eclipse-SourceBundle:
> "org.eclipse.osgi.services;version="3.3.100.v20130508-1933";roots:="""
> 	at
> org.eclipse.osgi.util.ManifestElement.parseHeader(ManifestElement.java:414)
> 	at
> org.eclipse.pde.internal.core.BundleManifestSourceLocationManager.
> setPlugins(BundleManifestSourceLocationManager.java:202)

I could look into allowing empty string directives.  I need to look at the OSGi spec details to see if that should be allowed, if so then the BundleException could be considered a bug in the framework manifest parser.  But if I did that would PDE treat the empty string as an alias for '.'?
Comment 17 Dani Megert CLA 2013-05-13 10:17:26 EDT
(In reply to comment #16)
> But if I did that would PDE treat the empty string as an alias for '.'?

I don't think this is a good idea.
Comment 18 Thomas Watson CLA 2013-05-13 10:26:38 EDT
(In reply to comment #17)
> (In reply to comment #16)
> > But if I did that would PDE treat the empty string as an alias for '.'?
> 
> I don't think this is a good idea.

What else would empty string mean?

Just to confirm, it does seem to be a bug in the framework manifest parser.  The syntax for quoted strings is:

quoted-string::= ’"’ ( ~["\#x0D#x0A#x00] | ’\"’|’\\’)* ’"’

So my question still remains.  If we fixed that what would PDE do?
Comment 19 Dani Megert CLA 2013-05-13 10:29:14 EDT
(In reply to comment #18)
> (In reply to comment #17)
> > (In reply to comment #16)
> > > But if I did that would PDE treat the empty string as an alias for '.'?
> > 
> > I don't think this is a good idea.
> 
> What else would empty string mean?

It could e.g. mean "not having source". Implicit assumptions are a maintenance hell.
Comment 20 Thomas Watson CLA 2013-05-13 10:33:45 EDT
(In reply to comment #19)
> (In reply to comment #18)
> > (In reply to comment #17)
> > > (In reply to comment #16)
> > > > But if I did that would PDE treat the empty string as an alias for '.'?
> > > 
> > > I don't think this is a good idea.
> > 
> > What else would empty string mean?
> 
> It could e.g. mean "not having source". Implicit assumptions are a
> maintenance hell.

I understand your point about assumptions, but I don't understand why a bundle would have Eclipse-SourceBundle and "not having source".  Also, I am wondering what would happen if there was not roots directive at all for this header?  is there some default value for the roots directive?
Comment 21 Thomas Watson CLA 2013-05-13 10:35:42 EDT
The docs state:

If no roots directive is specified, then a value of "." is assumed.
Comment 22 Dani Megert CLA 2013-05-13 10:41:37 EDT
(In reply to comment #21)
> The docs state:
> 
> If no roots directive is specified, then a value of "." is assumed.

Point taken! ;-).
Comment 23 Paul Webster CLA 2013-05-13 10:44:08 EDT
*** Bug 407868 has been marked as a duplicate of this bug. ***
Comment 24 Thanh Ha CLA 2013-05-13 10:44:25 EDT
Created attachment 230863 [details]
patch fix missing root

If it matters, attached patch fixes the issue so that the bundles are now setting root="." again by restoring lines:

source.. = .
output.. = .

I was able to workaround tycho-compiler-plugin trying to compile the sources by disabling the plugin for these 2 bundles by setting the build phase to "none".
Comment 25 Thomas Watson CLA 2013-05-13 10:52:32 EDT
(In reply to comment #24)
> Created attachment 230863 [details]
> patch fix missing root
> 
> If it matters, attached patch fixes the issue so that the bundles are now
> setting root="." again by restoring lines:
> 
> source.. = .
> output.. = .
> 
> I was able to workaround tycho-compiler-plugin trying to compile the sources
> by disabling the plugin for these 2 bundles by setting the build phase to
> "none".

Thanks Thanh, at this point I think this is the more safe option rather than fixing the manifest parser and hoping PDE 'does the right thing'.  FWIW in my branch for luna I have already fixed the manifest parser.  I discovered this while implementing some new OSGi R6 native environment requirements.  I knew this sounded familiar.
Comment 26 Thomas Watson CLA 2013-05-13 10:58:33 EDT
I released the latest patch from Thanh with:

http://git.eclipse.org/c/equinox/rt.equinox.framework.git/commit/?id=8f4dc6841991e7a9977e40c8bad5dd8bc39b641e
Comment 27 David Williams CLA 2013-05-13 15:00:36 EDT
Created attachment 230892 [details]
Summary of compile errors in test build

Any chance this latest change would cause compile errors like those attached? 

I was trying a test build (for other reasons) and got these errors. Of course, is could be something completely unrelated (perhaps related to "the test" I was trying out) .... but, thought I'd report it as soon as I could, in case related to this change.
Comment 28 Thomas Watson CLA 2013-05-13 15:59:02 EDT
(In reply to comment #27)
> Created attachment 230892 [details]
> Summary of compile errors in test build
> 
> Any chance this latest change would cause compile errors like those
> attached? 
> 

I would say this is highly likely.  I am going to revert the change and you can test it out.

> I was trying a test build (for other reasons) and got these errors. Of
> course, is could be something completely unrelated (perhaps related to "the
> test" I was trying out) .... but, thought I'd report it as soon as I could,
> in case related to this change.

I think it is pretty safe to say this fix has something to do with this.  The runway is getting short and I think any changes here are going to continue to cause us grief while we try to stabilize and ramp-down our build.  I have reverted both commits until we can get a complete and well tested solution.  Thanks Thanh for all your help!  If you have something else you would like us to try please let us know, but at this point I am leaning to deferring this fix until SR1.

Reverted commits:

http://git.eclipse.org/c/equinox/rt.equinox.framework.git/commit/?id=1b5390f6a774b6098d09c7db041d8885f5683dce
http://git.eclipse.org/c/equinox/rt.equinox.framework.git/commit/?id=4a43819806e41156205f1bea2bd52011f409f242
Comment 29 David Williams CLA 2013-05-13 18:20:30 EDT
(In reply to comment #28)
> (In reply to comment #27)
> > Created attachment 230892 [details]
> > Summary of compile errors in test build
> > 
> > Any chance this latest change would cause compile errors like those
> > attached? 
> > 
> 
> I would say this is highly likely.  I am going to revert the change and you
> can test it out.
> 

No compile errors in my local test build (which is faster than build.eclipse.org, since not signed ... one on build.eclipse.org still running).
Comment 30 David Williams CLA 2013-05-15 13:37:30 EDT
I added bug 407623 to the "blocks" list, since I think "fixing" this bug caused that bug ... so, by implication, any proposed fixes should be sure to be tested with "the comparator" to be sure these stray classes are not sprinkled around. 

If I had to take a wild guess, I'd guess the was some "weaving" or "injector" type jar in the "source jars" that some how gets "on the classpath" and has some effect on subsequent build steps. Probably using with wrong terminology, but hopefully the concept is clear (wild guess as it is). 

In any case, I'd suggest deferring also, unless a simple, safe fix is imminent. One that tests not only that "the right source jars are created", but that it does not have any side effects.
Comment 31 David Williams CLA 2013-05-23 00:04:19 EDT
Tentatively setting to SR1. 

Probably a good question to investigate, though, is if these bundles had "source bundles" in Juno. I seem to recall there were always some missing. Not sure which, thought. (That is, if regression, probably should be addressed in SR1 ... but if not a regression, I'd suggest Luna).
Comment 32 Thomas Watson CLA 2013-05-23 08:19:56 EDT
(In reply to comment #31)
> Tentatively setting to SR1. 
> 
> Probably a good question to investigate, though, is if these bundles had
> "source bundles" in Juno. I seem to recall there were always some missing.
> Not sure which, thought. (That is, if regression, probably should be
> addressed in SR1 ... but if not a regression, I'd suggest Luna).

Yes, these bundles had source bundles in Juno.  This is a regression.
Comment 33 Thomas Watson CLA 2013-06-21 13:15:05 EDT
For luna I plan to build the osgi source properly (see bug 411404).  This is not an acceptable solution for Kepler SR1 though since it will involve removing an API package org.osgi.service.io from org.eclips.osgi.services (although it is likely a package that nobody will notice is missing).
Comment 34 David Williams CLA 2013-08-26 22:04:26 EDT
Assuming no changes planned here for Kepler? Let me know if I've misunderstood.
Comment 35 Thomas Watson CLA 2013-08-27 08:39:41 EDT
(In reply to comment #34)
> Assuming no changes planned here for Kepler? Let me know if I've
> misunderstood.

No, but this should be fixed in Luna since we now build these projects like normal  projects.
Comment 36 David Williams CLA 2014-05-17 16:34:37 EDT
This seems fixed in Luna. I'm going to arbitrarily put "M5", but Tom, please re-open if there's something more to do, or set target accurately if you now.