YannLeCorse opened a new issue, #9309:
URL: https://github.com/apache/netbeans/issues/9309

   ### Apache NetBeans version
   
   Apache NetBeans 29
   
   ### What happened
   
   When OSGi modules are started, the Export-Package information are extracted 
in the [Netigso 
class](https://github.com/apache/netbeans/blob/master/platform/core.netigso/src/org/netbeans/core/netigso/Netigso.java#L294)
 and used later to populate the 
[ProxyClassPackages](https://github.com/apache/netbeans/blob/master/platform/o.n.bootstrap/src/org/netbeans/ProxyClassPackages.java).
   
   The problem is that the Export-Package parsing is too simple and doesn't 
match the [OSGi 
specification](https://docs.osgi.org/specification/osgi.core/7.0.0/framework.module.html#framework.module.exportpackage).
   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](https://repo1.maven.org/maven2/org/apache/maven/resolver/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](https://github.com/apache/netbeans/blob/master/platform/core.netigso/src/org/netbeans/core/netigso/Netigso.java#L294)
 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


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to