title: How can I name my OSGi component by using the class name?
body: <p>My project uses a convention to use the <code>class.getName()</code> as the name for the OSGi container. Most existing components have a <code>public static final String</code> constant that contains the name like this:</p>
  
  <pre><code>package mypackage;
  @Component(name = MyClass.COMPONENT_NAME)
  public class MyClass {
      public static final String COMPONENT_NAME = "mypackage" + ".MyClass";
      ...
  }
  </code></pre>
  
  <p>When creating my first component in the project I tried this:</p>
  
  <pre><code>package mypackage;
  @Component(name = MyClass.COMPONENT_NAME)
  public class MyClass {
      public static final String COMPONENT_NAME = MyClass.class.getName();
      ...
  }
  </code></pre>
  
  <p>However, the compiler complains in the annotation that the <code>name</code> should be a constant. </p>
  
  <p>Why doesn't this work?</p>