You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@felix.apache.org by "Thomas Watson (JIRA)" <ji...@apache.org> on 2018/10/25 15:31:00 UTC

[jira] [Commented] (FELIX-5972) prevent ArrayIndexOutOfBoundsException while resolving

    [ https://issues.apache.org/jira/browse/FELIX-5972?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16663915#comment-16663915 ] 

Thomas Watson commented on FELIX-5972:
--------------------------------------

Thanks for providing the simple to setup and follow recreation scenario, very helpful!

I have tracked this down to an issue in bnd which I need to open an issue for.  The class biz.aQute.resolve.BndResolver is doing something wrong with respect to the osgi.wiring.host namespace.  It appears they are creating multiple osgi.wiring.host capabilities for a single host resource.  This is wrong according to the javadoc for the [osgi.wiring.host namespace|https://osgi.org/javadoc/osgi.core/7.0.0/org/osgi/framework/namespace/HostNamespace.html] where it states:

A non-fragment resource with the with the osgi.bundle type identity provides zero or one† host capabilities. A fragment resource with the osgi.fragment type identity must not declare a host capability and must declare exactly one host requirement.

In this scenario they have one resource that provides 7 osgi.wiring.host capabilities!

Provide[osgi.wiring.host]\{bundle-version=6.0.1, osgi.wiring.host=org.apache.felix.framework}{}
Provide[osgi.wiring.host]\{bundle-version=6.0.1, osgi.wiring.host=system.bundle}{}
Provide[osgi.wiring.host]\{bundle-version=1.2.3, osgi.wiring.host=ch.qos.logback.classic}{}
Provide[osgi.wiring.host]\{bundle-version=1.2.3, osgi.wiring.host=ch.qos.logback.core}{}
Provide[osgi.wiring.host]\{bundle-version=1.7.25, osgi.wiring.host=slf4j.api}{}
Provide[osgi.wiring.host]\{bundle-version=1.2.0, osgi.wiring.host=org.apache.felix.log}{}
Provide[osgi.wiring.host]\{bundle-version=1.0.0, osgi.wiring.host=org.apache.felix.logback}{}

This ends up invalidating some assumptions the resolver makes with regard to a 1-to-1 mapping between a resource and its host capability.

> prevent ArrayIndexOutOfBoundsException while resolving
> ------------------------------------------------------
>
>                 Key: FELIX-5972
>                 URL: https://issues.apache.org/jira/browse/FELIX-5972
>             Project: Felix
>          Issue Type: Bug
>          Components: Resolver
>            Reporter: Stefan Bischof
>            Priority: Major
>
> ***Describe the bug*
>  when resolving I got an java.lang.ArrayIndexOutOfBoundsException: -1
> it may cause the -runpath Instruction
> *To Reproduce*
>  push the resolve button at {{test.log/works.bndrun}} -> it resolves
>  push the resolve button at {{test.log/fail.bndrun}} -> Exception
>  the only diff is that there is one mor required bundle
> i tried so centralize all logging instructions
>  cnf/ext/logging.bnd
> provide an Example
>  Repo: {{[https://github.com/stbischof/logging/tree/master]}}
> Command:
> {code:java}
> java -jar biz.aQute.bnd-4.1.0.jar clean
> java -jar biz.aQute.bnd-4.1.0.jar _par
> java -jar biz.aQute.bnd-4.1.0.jar resolve resolve **/fail.bndrun 
> {code}
>  
> *Expected behavior*
>  it should resolve
> *Stacktrace*
>  
> {code:java}
> java.lang.ArrayIndexOutOfBoundsException: -1 000: Exception: java.lang.ArrayIndexOutOfBoundsException: -1 at java.util.ArrayList.elementData(ArrayList.java:422) at java.util.ArrayList.set(ArrayList.java:450) at org.apache.felix.resolver.util.ShadowList.replace(ShadowList.java:74) at org.apache.felix.resolver.Candidates.prepare(Candidates.java:939) at org.apache.felix.resolver.ResolverImpl.getInitialCandidates(ResolverImpl.java:547) at org.apache.felix.resolver.ResolverImpl.doResolve(ResolverImpl.java:432) at org.apache.felix.resolver.ResolverImpl.resolve(ResolverImpl.java:421) at org.apache.felix.resolver.ResolverImpl.resolve(ResolverImpl.java:375) at biz.aQute.resolve.BndResolver.resolve(BndResolver.java:32) at biz.aQute.resolve.ResolveProcess.resolveRequired(ResolveProcess.java:81) at biz.aQute.resolve.ProjectResolver.resolve(ProjectResolver.java:105) at biz.aQute.resolve.Bndrun.resolve(Bndrun.java:95) at aQute.bnd.main.ResolveCommand._resolve(ResolveCommand.java:275) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at aQute.lib.getopt.CommandLine.execute(CommandLine.java:150) at aQute.lib.getopt.CommandLine.subCmd(CommandLine.java:624) at aQute.bnd.main.bnd._resolve(bnd.java:4237) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at aQute.lib.getopt.CommandLine.execute(CommandLine.java:150) at aQute.bnd.main.bnd._bnd(bnd.java:444) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at aQute.lib.getopt.CommandLine.execute(CommandLine.java:150) at aQute.bnd.main.bnd.start(bnd.java:292) at aQute.bnd.main.bnd.main(bnd.java:269) {code}
> **
>  
>  
> *Environment (please complete the following information):*
>  * bnd-Version: {{bndtools 4.2.0.2018.10.19.2218-SNAPSHOT}}
>  * Java-Version: {{java -version}}
>  
> {code:java}
> openjdk version "1.8.0_181" OpenJDK Runtime Environment (build 1.8.0_181-b15) OpenJDK 64-Bit Server VM (build 25.181-b15, mixed mode)  
> {code}
>  * bnd-Part: bnd-lib,bndtools
>  * OS: Linux
>  * OSGi-Framework: Felix
>  * Related Spec: none
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)