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

message "class ... it should be defined in a file ..." is broken

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      1.0fcs
    • CPU:
      sparc
    • OS:
      solaris_2.5
    • Verification:
      Not verified

      Description



      Name: laC46010 Date: 01/20/97


      jdk1.1beta3 Java compiler reports incorrect message for the following JCK1.1 tests:
      lang/CLSS/clss005/clss00503/clss00503.html
      lang/CLSS/clss005/clss00508/clss00508.html
      lang/CLSS/clss005/clss00513/clss00513.html

      Instead of reporting

      tests/lang/CLSS/clss005/clss00503/clss00503.java:8: class javasoft.sqe.tests.lang.clss005.clss00503.points.Point is defined in clss00503_a.java. Because it is used outside of its source file, it should be defined in a file called "Point.java".

      compiler suggests

      tests/lang/CLSS/clss005/clss00503/clss00503.java:8: class javasoft.sqe.tests.lang.clss005.clss00503.points.Point is defined in clss00503_a.java. Because it is used outside of its source file, it should be defined in a file called "class javasoft.sqe.tests.lang.clss005.clss00503.points.Point".

      It's really funny :)

      See full source of clss00503 test case below.
      ------------------------------------------------------------------
      // Ident: @(#)clss00503_a.java 1.2 96/08/20
      // Copyright 08/20/96 Sun Microsystems, Inc. All Rights Reserved

      package javasoft.sqe.tests.lang.clss005.clss00503.points;

      class Point {
              int x, y; // coordinates
              PointColor color; // color of this point
              Point next; // next point with this color
              static int nPoints;
      }

      ------------------------------------------------------------------
      // Ident: @(#)clss00503.java 1.3 96/09/02
      // Copyright 09/02/96 Sun Microsystems, Inc. All Rights Reserved

      package javasoft.sqe.tests.lang.clss005.clss00503.points;
      import java.io.PrintStream;

      class PointColor {
              Point first; // first point with this color
              PointColor(int color) { this.color = color; }
              private int color; // color components
      }

      class Funny {
              int Point;
              void get() {
                      Point = Point.nPoints; // compile-time error
              }
      }

      public class clss00503 {
        public static void main(String argv[])
        {
           System.exit(run(argv, System.out) + 95/*STATUS_TEMP*/);
        }
        public static int run(String argv[], PrintStream out) {
              Point p = new Point();
              PointColor pc = new PointColor(1);
              p.color = pc;
              pc.first = p;
              Funny f = new Funny();
              f.get();
              out.println("Error: there should be compile-time errors.");
              return 1;
        }
      }
      ------------------------------------------------------------------

      Output:

      /export/ld32/dest/jdk1.1beta3/solaris/bin/javac -d /export/ld12/java/leo/res/dev-jdk1.1-f/classes tests/lang/CLSS/clss005/clss00503/clss00503_a.java tests/lang/CLSS/clss005/clss00503/clss00503.java
      tests/lang/CLSS/clss005/clss00503/clss00503.java:8: class javasoft.sqe.tests.lang.clss005.clss00503.points.Point is defined in clss00503_a.java. Because it is used outside of its source file, it should be defined in a file called "class javasoft.sqe.tests.lang.clss005.clss00503.points.Point".
              Point first; // first point with this color
                         ^
      tests/lang/CLSS/clss005/clss00503/clss00503.java:16: Attempt to reference field nPoints in a int.
      Point = Point.nPoints; // compile-time error
      ^
      tests/lang/CLSS/clss005/clss00503/clss00503_a.java:8: class javasoft.sqe.tests.lang.clss005.clss00503.points.PointColor is defined in clss00503.java. Because it is used outside of its source file, it should be defined in a file called "class javasoft.sqe.tests.lang.clss005.clss00503.points.PointColor".
              PointColor color; // color of this point
                              ^
      1 error, 2 warnings

      ======================================================================

        Attachments

          Activity

            People

            Assignee:
            tlindholsunw Timothy Lindholm (Inactive)
            Reporter:
            leosunw Leo Leo (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: