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

javac crashes when compiling against an annotated class

    XMLWordPrintable

Details

    • b71
    • x86
    • linux
    • Verified

    Description

      FULL PRODUCT VERSION :
      java version "1.5.0_05"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_05-b05)
      Java HotSpot(TM) Client VM (build 1.5.0_05-b05, mixed mode, sharing)


      ADDITIONAL OS VERSION INFORMATION :
      Linux cannonball 2.6.10 #1 Wed Mar 2 22:37:07 PST 2005 i686 GNU/Linux

      A DESCRIPTION OF THE PROBLEM :
      javac crashes when compiling against a class that uses annotations if the class defining those annotations is not available on the build path. Thus:
      class A is an annotation class
      class B uses an annotation from A
      class C uses B
      Compiling class C should require that class B be on the build path, but not class A. However, leaving out class A causes a javac crash.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      The following classes can be used to reproduce this bug:
      import static java.lang.annotation.RetentionPolicy.RUNTIME;

      TestAnnotation.java:
      package test.annotation;
      import java.lang.annotation.*;

      @Retention(RetentionPolicy.RUNTIME)
      public @interface TestAnnotation {
              int test();
      }


      TestCore.java:
      package test.core;

      import test.annotation.TestAnnotation;

      public class TestCore
      {
          @TestAnnotation(test = 1)
          public static void main( String[] args ) { }

          public void test()
          {
              System.out.println("test");
          }
      }

      TestUi.java
      package test.ui;

      import test.core.TestCore;

      /**
       * Hello world!
       *
       */
      public class TestUi
      {
          public static void main( String[] args )
          {
              TestCore tc = new TestCore();
              System.out.println(tc.toString());
          }
      }


      Put these in appropriate package directories, create target directories (annotation, core, ui) and compile using:
      javac -d annotation test/annotation/TestAnnotation.java
      javac -d core -cp annotation test/core/TestCore.java
      javac -d ui -cp core test/ui/TestUi.java

      The third command will cause javac to crash

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The third command should correct compile TestUi.java. Specifically, TestUi.java should not require a binary dependency on TestAnnotation.class (nor does it in other javac implementations, such as that used by Eclipse).
      ACTUAL -
      The third command crashes with the error.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      An exception has occurred in the compiler (1.5.0_05). Please file a bug at the Java Developer Connection (http://java.sun.com/webapps/bugreport) after checking the Bug Parade for duplicates. Include your program and the following diagnostic in your report. Thank you.
      com.sun.tools.javac.code.Symbol$CompletionFailure: file test/annotation/TestAnnotation.class not found

      An exception has occurred in the compiler (1.6.0-rc). Please file a bug at the Java Developer Connection (http://java.sun.com/webapps/bugreport) after checking the Bug Parade for duplicates. Include your program and the following diagnostic in your report. Thank you.
      com.sun.tools.javac.code.Symbol$CompletionFailure: class file for test.annotation.TestAnnotation not found

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      See "steps to reproduce".
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Use a different javac compiler. Not tenable for distributable builds.

      Attachments

        Issue Links

          Activity

            People

              ahe Peter Ahe
              ndcosta Nelson Dcosta (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: