-
Notifications
You must be signed in to change notification settings - Fork 922
OSGi : Netigso class badly compute the exported packages #9309
Description
Apache NetBeans version
Apache NetBeans 29
What happened
When OSGi modules are started, the Export-Package information are extracted in the Netigso class and used later to populate the ProxyClassPackages.
The problem is that the Export-Package parsing is too simple and doesn't match the OSGi specification.
The current code split on comma which is working for very basic OSGi manifest but doesn't work on normal ones...
As a simple example to illustrate the parsing issue is to look at the Manifest of the maven-resolver-api we can see stuffs like
Export-Package:
org.eclipse.aether;version="2.0.16";uses:="org.eclipse.aether.artifact,org.eclipse.aether.collection,org.eclipse.aether.deployment,org.eclipse.aether.graph,org.eclipse.aether.installation,org.eclipse.aether.metadata,org.eclipse.aether.repository,org.eclipse.aether.resolution,org.eclipse.aether.scope,org.eclipse.aether.transfer",
org.eclipse.aether.artifact;version="2.0.16",
...
As the uses:="..." section is also relying on comma separated values, the split done on Netigso is producing an incorrect list of exported packages.
As a result, packages (possibly from another module) that are used-by become considered as exported by the module which is incorrect.
This is causing issues later in the process as Netbeans could consider that several modules are exposing the package A while in reality it's not the case...
Language / Project Type / NetBeans Component
No response
How to reproduce
public class Issue {
public static void main(String[] args) {
String exported ="org.eclipse.aether;version=\"2.0.16\";uses:=\"org.ecl"
+ "ipse.aether.artifact,org.eclipse.aether.collection,org.eclips"
+ "e.aether.deployment,org.eclipse.aether.graph,org.eclipse.aeth"
+ "er.installation,org.eclipse.aether.metadata,org.eclipse.aethe"
+ "r.repository,org.eclipse.aether.resolution,org.eclipse.aether"
+ ".scope,org.eclipse.aether.transfer\",org.eclipse.aether.artif"
+ "act;version=\"2.0.16\",org.eclipse.aether.collection;version="
+ "\"2.0.16\";uses:=\"org.eclipse.aether,org.eclipse.aether.arti"
+ "fact,org.eclipse.aether.graph,org.eclipse.aether.repository,o"
+ "rg.eclipse.aether.scope,org.eclipse.aether.version\",org.ecli"
+ "pse.aether.deployment;version=\"2.0.16\";uses:=\"org.eclipse."
+ "aether,org.eclipse.aether.artifact,org.eclipse.aether.metadat"
+ "a,org.eclipse.aether.repository\",org.eclipse.aether.graph;ve"
+ "rsion=\"2.0.16\";uses:=\"org.eclipse.aether.artifact,org.ecli"
+ "pse.aether.repository,org.eclipse.aether.version\",org.eclips"
+ "e.aether.installation;version=\"2.0.16\";uses:=\"org.eclipse."
+ "aether,org.eclipse.aether.artifact,org.eclipse.aether.metadat"
+ "a\",org.eclipse.aether.metadata;version=\"2.0.16\";uses:=\"or"
+ "g.eclipse.aether\",org.eclipse.aether.repository;version=\"2."
+ "0.16\";uses:=\"org.eclipse.aether,org.eclipse.aether.artifact"
+ ",org.eclipse.aether.metadata\",org.eclipse.aether.resolution;"
+ "version=\"2.0.16\";uses:=\"org.eclipse.aether,org.eclipse.aet"
+ "her.artifact,org.eclipse.aether.collection,org.eclipse.aether"
+ ".graph,org.eclipse.aether.metadata,org.eclipse.aether.reposit"
+ "ory,org.eclipse.aether.version\",org.eclipse.aether.scope;ver"
+ "sion=\"2.0.16\";uses:=\"org.eclipse.aether.artifact\",org.ecl"
+ "ipse.aether.transfer;version=\"2.0.16\";uses:=\"org.eclipse.a"
+ "ether,org.eclipse.aether.artifact,org.eclipse.aether.metadata"
+ ",org.eclipse.aether.repository\",org.eclipse.aether.version;v"
+ "ersion=\"2.0.16\";uses:=\"org.eclipse.aether\"";
// Current Netbeans Code
System.out.println("Exported Packages with the current Netbeans code :");
for (String p : exported.toString().split(",")) {
System.out.println("\t" + p);
}
// Suggested changes
System.out.println("Exported Packages with suggested changes:");
String regexp = ",(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)";
for (String p : exported.toString().split(regexp)) {
System.out.println("\t" + p);
}
}
}
Did this work correctly in an earlier version?
No / Don't know
Operating System
Mac
JDK
Zulu 21
Apache NetBeans packaging
Apache NetBeans binary zip
Anything else
No response
Are you willing to submit a pull request?
Yes