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

Spurious/misleading errors when package declaration and sourcefile path disagree

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P5 P5
    • None
    • 1.1, 1.1.1
    • tools
    • sparc
    • solaris_2.5.1



      Name: mc57594 Date: 02/13/97


      You can reproduce the problem with the script included below.
      It will create a few files and directories and then run javac.
      When I do this, I get the following error messages:

      ./java/lang/reflect/Method.java:3: Class milk.java.lang.reflect.Method already defined in java/lang/reflect/Method.java.
      public class Method
                   ^
      SillyMethod.java:3: Class java.lang.reflect.Method not found in import.
      import java.lang.reflect.Method;
             ^
      2 errors

      Here's the script:

      #!/bin/csh -f
      #
      # Bug in javac 1.1b3: The compiler gets confused about file/class
      # names that partially mirror the java name hierarchy.
      #
      # Reported by Dan Bornstein, ###@###.###
      #
      rm -f SillyMethod.java
      cat >SillyMethod.java << EOF
      package milk;

      import java.lang.reflect.Method;

      public class SillyMethod
      {
          SillyMethod (Method target)
          {
          }
      }
      EOF
      rm -rf java
      mkdir java
      mkdir java/lang
      mkdir java/lang/reflect
      cat >java/lang/reflect/Method.java << EOF
      package milk.java.lang.reflect;

      public class Method
      {
      }
      EOF
      rm -rf out
      mkdir out
      javac -d out SillyMethod.java java/lang/reflect/Method.java

      company - Electric Communities , email - ###@###.###
      ======================================================================

            wmaddoxsunw William Maddox (Inactive)
            mchamnessunw Mark Chamness (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: