Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6331821

When annotation class is not available, javac fails compiling a class that uses the annotated class

    Details

    • Subcomponent:
    • CPU:
      generic
    • OS:
      generic

      Description

      I have following directory structure:

      .
      ./Main.java
      ./sahoo/Sless.class
      ./sahoo/Sless.java
      ./sahoo/SlessBean.class
      ./sahoo/SlessBean.java
      ./lib/javax/ejb/Local.class
      ./lib/javax/ejb/Local.java

      ./Main.java
      -----------
      class Main{
       public static void main(String... args){
         sahoo.SlessBean sless;
       }
      }

      ./sahoo/SlessBean.java
      ----------------------
      package sahoo;
      @javax.ejb.Local(sahoo.Sless.class)
      public class SlessBean implements Sless {
       public void bar() {}
      }

      ./sahoo/Sless.java
      ------------------
      package sahoo;
      public interface Sless {
       void bar();
      }

      When I try compiling:
      javac Main.java

      I get the following error:

      Main.java:3: cannot find symbol
      symbol : class SlessBean
      location: package sahoo
         sahoo.SlessBean sless;
              ^
      1 error

      But when I compile with lib in classpath, i.e.
      javac -classpath .:lib Main.java
      it compiles fine.

      So I don't understand why I need javax.ejb.Local to be in my compilation class path. More over, even if I needed that class, I would expect a better error message from compiler.
      javax.ejb.Local.class is defined as follows:
      lib/javax/ejb/Local.java
      ------------------------
      package javax.ejb;
       
      public @interface Local{
       Class[] value() default {};
      }

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                sanjsaho Sanjeeb Sahoo
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Imported:
                  Indexed: