You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by "Hampel, Michael" <mi...@siemens.com> on 2008/05/28 14:47:30 UTC

maven-bundle-plugin and generics

Hello,
 
I have a class with a method
 
  public Collection<MyType> getJobs(Object jobProcessor) {
    return jobProcessor.getJobs();
  }
 
The class imports MyType.
 
When I build the class with the maven-bundle-plugin the resulting
Manifest is not adding the MyTypes package
to its Import-Packages.
 
When I add 
 
 public Collection<MyType> getJobs(Object jobProcessor) {
   MyType mt = new MyType();
    return jobProcessor.getJobs();
  }
 
 then I have the package exporting MyType in the Manifest.
 
Is this a limitation of the maven-bundle-plugin or bnd or is there
another reason?
 
Thanx in advance for any help,
 
Michael
 

AW: maven-bundle-plugin and generics

Posted by "Hampel, Michael" <mi...@siemens.com>.
 
Hello,

thanx for your answers - I already assumed that the type erasure is the reason.
And I don't get problems at runtime - at least until now - because I don't
Access an object in the collection but only pass the Collection.

Thank you again,

Michael



-----Ursprüngliche Nachricht-----
Von: mcculls@gmail.com [mailto:mcculls@gmail.com] Im Auftrag von Stuart McCulloch
Gesendet: Mittwoch, 28. Mai 2008 15:24
An: users@felix.apache.org
Betreff: Re: maven-bundle-plugin and generics

2008/5/28 Clement Escoffier <cl...@gmail.com>:

> Hi,
>
> It is just an hypothesis, but the maven-bundle-plugin is based on BND which
> is based on a bytecode analysis. The bytecode does not contain specific
> instructions about generics. It's more a syntactic sugar. So, when
> analyzed,
> I'm pretty sure that generics are not detected as they are not present in
> the classes.
>

that's correct - the generic type parameters are erased by
the compiler and don't appear in bytecode (this is also why
generic parameters aren't available at runtime, unless you
decide to subclass the generic type as a concrete type)

however, you shouldn't need to import this package unless
you actually use the type - otherwise the bytecode would
reference the containing package

do you have an example where the package is missing and
this causes an exception at runtime? (if so please open a
JIRA issue and attach the example project)

Clement
>
> > -----Message d'origine-----
> > De : Hampel, Michael [mailto:michael.hampel@siemens.com]
> > Envoyé : mercredi 28 mai 2008 08:48
> > À : users@felix.apache.org
> > Objet : maven-bundle-plugin and generics
> >
> > Hello,
> >
> > I have a class with a method
> >
> >   public Collection<MyType> getJobs(Object jobProcessor) {
> >     return jobProcessor.getJobs();
> >   }
> >
> > The class imports MyType.
> >
> > When I build the class with the maven-bundle-plugin the resulting
> > Manifest is not adding the MyTypes package
> > to its Import-Packages.
> >
> > When I add
> >
> >  public Collection<MyType> getJobs(Object jobProcessor) {
> >    MyType mt = new MyType();
> >     return jobProcessor.getJobs();
> >   }
> >
> >  then I have the package exporting MyType in the Manifest.
> >
> > Is this a limitation of the maven-bundle-plugin or bnd or is there
> > another reason?
> >
> > Thanx in advance for any help,
> >
> > Michael
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
>


-- 
Cheers, Stuart

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: maven-bundle-plugin and generics

Posted by Stuart McCulloch <st...@jayway.net>.
2008/5/28 Clement Escoffier <cl...@gmail.com>:

> Hi,
>
> It is just an hypothesis, but the maven-bundle-plugin is based on BND which
> is based on a bytecode analysis. The bytecode does not contain specific
> instructions about generics. It's more a syntactic sugar. So, when
> analyzed,
> I'm pretty sure that generics are not detected as they are not present in
> the classes.
>

that's correct - the generic type parameters are erased by
the compiler and don't appear in bytecode (this is also why
generic parameters aren't available at runtime, unless you
decide to subclass the generic type as a concrete type)

however, you shouldn't need to import this package unless
you actually use the type - otherwise the bytecode would
reference the containing package

do you have an example where the package is missing and
this causes an exception at runtime? (if so please open a
JIRA issue and attach the example project)

Clement
>
> > -----Message d'origine-----
> > De : Hampel, Michael [mailto:michael.hampel@siemens.com]
> > Envoyé : mercredi 28 mai 2008 08:48
> > À : users@felix.apache.org
> > Objet : maven-bundle-plugin and generics
> >
> > Hello,
> >
> > I have a class with a method
> >
> >   public Collection<MyType> getJobs(Object jobProcessor) {
> >     return jobProcessor.getJobs();
> >   }
> >
> > The class imports MyType.
> >
> > When I build the class with the maven-bundle-plugin the resulting
> > Manifest is not adding the MyTypes package
> > to its Import-Packages.
> >
> > When I add
> >
> >  public Collection<MyType> getJobs(Object jobProcessor) {
> >    MyType mt = new MyType();
> >     return jobProcessor.getJobs();
> >   }
> >
> >  then I have the package exporting MyType in the Manifest.
> >
> > Is this a limitation of the maven-bundle-plugin or bnd or is there
> > another reason?
> >
> > Thanx in advance for any help,
> >
> > Michael
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
>


-- 
Cheers, Stuart

RE: maven-bundle-plugin and generics

Posted by Clement Escoffier <cl...@gmail.com>.
Hi,

It is just an hypothesis, but the maven-bundle-plugin is based on BND which
is based on a bytecode analysis. The bytecode does not contain specific
instructions about generics. It's more a syntactic sugar. So, when analyzed,
I'm pretty sure that generics are not detected as they are not present in
the classes. 

Clement

> -----Message d'origine-----
> De : Hampel, Michael [mailto:michael.hampel@siemens.com]
> Envoyé : mercredi 28 mai 2008 08:48
> À : users@felix.apache.org
> Objet : maven-bundle-plugin and generics
> 
> Hello,
> 
> I have a class with a method
> 
>   public Collection<MyType> getJobs(Object jobProcessor) {
>     return jobProcessor.getJobs();
>   }
> 
> The class imports MyType.
> 
> When I build the class with the maven-bundle-plugin the resulting
> Manifest is not adding the MyTypes package
> to its Import-Packages.
> 
> When I add
> 
>  public Collection<MyType> getJobs(Object jobProcessor) {
>    MyType mt = new MyType();
>     return jobProcessor.getJobs();
>   }
> 
>  then I have the package exporting MyType in the Manifest.
> 
> Is this a limitation of the maven-bundle-plugin or bnd or is there
> another reason?
> 
> Thanx in advance for any help,
> 
> Michael
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org