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

javac compiles .java files on the classpath unexpectedly

    XMLWordPrintable

Details

    • Bug
    • Resolution: Not an Issue
    • P4
    • None
    • None
    • tools
    • None
    • JDK 8 b83

    • x86
    • os_x

    Description

      This is a situation which comes up in the JavaFX Build. It is a weird issue that I can attempt some workarounds for. Heck, I don't even know if this is expected or not (I've never run into this situation previously). The essence of the problem is this: I have a couple Java files (A & B). I build B and put the resulting class file into lib/. I then want to compile A.java such that B.class AND B.java are both on the class path (A.java could be looking for and reading B.java to print out the contents or search for a string or text or whatnot).

      If I simply compile A.java, it works fine. However if I first modify B.java such that it is no longer compilable, then when I attempt to compile A, the compilation fails as it is attempting to compile B.java (!!). Perhaps it is not really compiling B.java but just parsing it and getting stuck?

      a/A.java:
      public class A {
          public static void main(String[] args) {
              new B().doIt();
          }
      }

      b/B.java:
      public class B {
          public void doIt() {
              System.out.println("Did it.");
          }
      }

      $ javac -d lib b/B.java

      changed b/B.java to:

      public class B {
          public void doIt() {
              Garbage!
          }
      }


      $ javac -cp lib/:b/ -d out a/A.java
      b/B.java:3: error: not a statement
              Garbage!
              ^
      b/B.java:3: error: ';' expected
              Garbage!
                     ^
      2 errors

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              rbair Richard Bair (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: