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

compiler should provide more helpful diagnostic for long as array index type

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P5 P5
    • None
    • 1.0.2
    • tools
    • sparc
    • generic



      Name: ###@###.### Date: 08/16/96

      It will be better if compiler will provide more accurate error
                   message and indication of the error for the following illegal
                   array creation expression:
                   long[] ia = new long[5L]
       
      Test:
      -----

      package javasoft.sqe.tests.lang.lex000.lex00001;
      import java.io.PrintStream;

      class lex00001 {
      public static void main (String args []) {
      System.exit(run(args,System.out));
      }

      public static int run(String args[],PrintStream out) {
        long[] ia = new long[5L];
        ia[5L] = 5L;
        return 0;
      }}

      Now compiler issues the following error messages:

      ----------ref:compile.java(7/393)----------
      /net/novo33/export/ld32/spn/java_tests/tests/lang/LEX/lex029/lex02901/lex02901.java:13: Incompatible type for new. Explicit cast needed to convert long to int.
        long[] ia = new long[5L];
                    ^
      /net/novo33/export/ld32/spn/java_tests/tests/lang/LEX/lex029/lex02901/lex02901.java:14: Incompatible type for []. Explicit cast needed to convert long to int.
        ia[5L] = 5L;
          ^
      2 errors

      Second error message is good, but first message and indication of the first error
      are not accurate. It may be difficult for user to understand this diagnostics.

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

            gafter Neal Gafter (Inactive)
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: