As Felix said, there is nothing specific about Felix framework here. Class.getAnnotations() ignores annotations for which it could not load corresponding classes. That's by design. See [1] for example.

Thanks,
Sahoo

[1] http://weblogs.java.net/blog/ss141213/archive/2009/10/08/should-classgetannotations-fail-if-annotation-type-not-available

Felix Meschberger wrote:
Hi,

I am pretty sure that the Felix framework does nothing around annotations.

According to the JavaDoc of the RetentionPolicy annotation, only a
retention policy of "RUNTIME" ensures an annotation is available at
runtime. A policy of COMPILE will put it into the class file but the VM
need not retain it at runtime (this seems to be the default, too).

Regards
Felix

On 15.01.2010 08:57, Brodie wrote:
hi, i find that when felix installing a bundle, if the bundle referred to some
other bundle's exported Annotation, and if the Annotation class is not
accessible(for example the annotation class is deleted) , felix omit the
Annotation.
i am not sure if this is a bug, or the JVM runs in this way, but it is
definitely not reasonable. i waste much time on it.

Here is the test, public class TestLoadAnnotation {
        @Test
        public void testLoad() throws Exception{
                Felix f = new Felix(new HashMap());
                f.init(); f.start();
                Bundle bundle =
f.getBundleContext().installBundle("file:///home/chi/workspace/profile/target/profile-0.0.1-SNAPSHOT-package.jar");
                bundle.start();
                BundleActivator activator = 
FelixHelper.getBundleActivator(bundle);
                System.out.println(activator.getClass().getClassLoader());
                Assert.assertTrue(0 != 
activator.getClass().getAnnotations().length);
        }
}

and the profile bundle's activator definition.
@App("profile")
public class Activator implements BundleActivator{...}

i checked the class file of Activator, and there is this runtime visible
@App annotation. why the annotation is missing?



Reply via email to