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

Missing import can cause unpredictable errors in other files.

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Won't Fix
    • Affects Version/s: 1.2.0
    • Fix Version/s: None
    • Component/s: tools
    • Subcomponent:
    • CPU:
      generic, x86
    • OS:
      generic, windows_nt

      Description



      Name: wm38563 Date: 10/28/98


      Missing an import statement from a java file
      can cause other java files to have unpredictable
      errors raised on them.
      These errors are reported before the errors
      regarding the missing import and sometimes the
      error about the missing import doesn't get
      reported at all.

      This makes finding the problem almost impossible
      when dealing with a large project.

      Here is a small example to demonstrate this.

      Save this text to TProp.java:
      ========start=======
      import java.util.*;

      public class TProp extends Properties
      {
        public TProp(InputStream in) throws IOException
        {
          load(in);
        }
      }
      =======end========

      and this text to Test.java:
      ========start=======
      import java.io.*;

      public class Test
      {
        public Test(InputStream in)
        {
          TProp test=new TProp(in);
          try {
            throw new IOException();
          } catch(IOException e) {
          }
        }
      }
      ========end=========

      Then run "javac Test.java".
      This should come up with the following output:
      Test.java:7: Class InputStream not found in new.
          TProp test=new TProp(in);
                     ^
      Test.java:9: Class IOException not found.
            throw new IOException();
                      ^
      Test.java:10: Class IOException not found.
          } catch(IOException e) {
                  ^
      .\.\TProp.java:5: Class InputStream not found.
        public TProp(InputStream in) throws IOException
               ^
      .\.\TProp.java:5: Class IOException not found in throws.
        public TProp(InputStream in) throws IOException
                                            ^
      .\.\TProp.java:7: Class InputStream not found in TProp(InputStream).
          load(in);
              ^
      6 errors

      Notice how errors are reported in Test.java first
      even though there is no problem in this file.
      The actual error is in TProp.java.

      In the case that I found in my own project the
      actual error was never reported. Instead the
      equivalent to the errors in Test.java were raised
      without any reference to the actual errors.
      (Review ID: 37716)
      ======================================================================

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              wmaddoxsunw William Maddox (Inactive)
              Reporter:
              wmaddoxsunw William Maddox (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: