felix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Peter Kriens (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (FELIX-3407) Imports are missed for generics
Date Tue, 29 May 2012 18:46:22 GMT

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

Peter Kriens edited comment on FELIX-3407 at 5/29/12 6:45 PM:
--------------------------------------------------------------

It turns out that I had commented out a section due to a not understanding of the JVM spec
class file format caused this.

That said, it took a long time to work out since the example is rather convoluted since it
contains Blueprint and hard to parse names. The following minimal example showed the problem:

bundle a:  class a.A implements B<C> { }
bundle b:  public interface b.B<T> { }
bundle c:  public class c.C {}

It really helps if the problems are brought back to their absolute minimum since I can then
create a test case without too much effort.

Anyway, this is in the next branch and will be released in about 3 weeks.
                
      was (Author: pkriens):
    It turns out that I had commented out a section due to a not understanding of the JVM
spec class file format caused this.

That said, it took a long time to work out since the example is rather convoluted since it
contains Blueprint and hard to parse names. The following minimal example showed the problem:

a:  class A implements B<C> { }
b:  public interface B<T> { }
c:  public class C {}

It really helps if the problems are brought back to their absolute minimum since I can then
create a test case without too much effort.

Anyway, this is in the next branch and will be released in about 3 weeks.
                  
> Imports are missed for generics
> -------------------------------
>
>                 Key: FELIX-3407
>                 URL: https://issues.apache.org/jira/browse/FELIX-3407
>             Project: Felix
>          Issue Type: Bug
>          Components: Maven Bundle Plugin
>    Affects Versions: maven-bundle-plugin-2.3.7
>            Reporter: Tomas Forsman
>         Attachments: example.zip
>
>
> The bundle plugin miss to add imports to classes/interfaces that are used in generic
blocks due to type erasure.
> Consider the following (the code is in the attached zip):
> bundle-a:
> package example.a.one;
> public interface ExampleInterfaceA<T extends ExampleInterfaceB> {
>     String getGreeting(T example);
> }
> package example.a.two;
> public interface ExampleInterfaceB {
> }
> bundle-b:
> package example.b.two;
> import example.a.two.ExampleInterfaceB;
> public interface ExampleImplementationB extends ExampleInterfaceB {
> }
> bundle-c:
> package example.c;
> import example.a.one.ExampleInterfaceA;
> import example.b.two.ExampleImplementationB;
> public interface ExampleExtendedInterfaceA extends ExampleInterfaceA<ExampleImplementationB>
{
> }
> package example.c;
> public class ExampleReferenceListener {
>     public void register(final ExampleExtendedInterfaceA example) {
>     }
>     public void unregister(final ExampleExtendedInterfaceA example) {
>     }
> }
> OSGI-INF/blueprint/services.xml
> <?xml version="1.0" encoding="UTF-8"?>
> <blueprint xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>            xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
>            xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
>     <reference-list id="exampleReferenceListener"
>                     interface="example.c.ExampleExtendedInterfaceA"
>                     availability="optional">
>         <reference-listener bind-method="register" unbind-method="unregister">
>             <bean class="example.c.ExampleReferenceListener"/>
>         </reference-listener>
>     </reference-list>
> </blueprint>
> bundle-d:
> package example.d;
> import example.b.two.ExampleImplementationB;
> import example.c.ExampleExtendedInterfaceA;
> public class ExampleExtendedImplementation implements ExampleExtendedInterfaceA {
>     public String getGreeting(final ExampleImplementationB example) {
>         return "Hello World";
>     }
> }
> OSGI-INF/blueprint/services.xml
> <?xml version="1.0" encoding="UTF-8"?>
> <blueprint xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>            xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
>            xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
>     <bean id="exampleBean" class="example.d.ExampleExtendedImplementation"/>
>     <service id="exampleService" interface="example.c.ExampleExtendedInterfaceA" ref="exampleBean"/>
> </blueprint>
> Since the bundle plugin uses byte-code to find out which imports to add to the manifest,
the bundle-c manifest look like this:
> Manifest-Version: 1.0
> Bnd-LastModified: 1332925553008
> Build-Jdk: 1.6.0_26
> Built-By: tofo01
> Bundle-ManifestVersion: 2
> Bundle-Name: example.bundle-c
> Bundle-SymbolicName: example.bundle-c
> Bundle-Version: 1.0.0.SNAPSHOT
> Created-By: Apache Maven Bundle Plugin
> Export-Package: example.c;uses:="example.a.one";version="1.0.0.SNAPSHOT"
> Import-Package: example.a.one;version="[1.0,2)",org.osgi.service.blueprint;version="[1.0.0,2.0.0)"
> Import-Service: example.c.ExampleExtendedInterfaceA;multiple:=true;availability:=optional
> Tool: Bnd-1.50.0
> The "example.a.two" package import is missing since type-erasure removes the generic
part of ExampleInterfaceA in the bundle-c interface.
> This results in a NoClassDefFondError of example.a.two.ExampleInterfaceB from bundle-c
when trying to deploy bundle-d.
> "Error tracking new service reference java.lang.NoClassDefFoundError: example.a.two.ExampleInterfaceB
not found by example.bundle-c [159]"

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message