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

Unhelpful error message for array declarations lacking the length

    XMLWordPrintable

Details

    • mantis
    • x86
    • windows_2000

    Description



      Name: jl125535 Date: 03/15/2002


      FULL PRODUCT VERSION :
      java version "1.4.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92)
      Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)

      FULL OPERATING SYSTEM VERSION :
      Microsoft Windows 2000 [Version 5.00.2195]


      A DESCRIPTION OF THE PROBLEM :
      When an array is declared without a length, the compiler gives an
      unhelpful error message.

      REGRESSION. Last worked in version 1.2.2

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1.Declare a empty array e.g byte[] bdata = new byte[];
      2.Compile in both jdk 1.2.2 & 1.4

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      Expected: (last seen in 1.2.2)

      % use122
      java version "1.2.2"
      Classic VM (build JDK-1.2.2-W, green threads, sunwjit)
      % javac ArrayTest.java
      ArrayTest.java:5: Array dimension missing.
              byte[] bdata = new byte[];
                             ^
      1 error

      Actual: (seen in 1.3.0 and 1.4.0)
      % use14
      java version "1.4.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92)
      Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)
      % javac ArrayTest.java
      ArrayTest.java:5: '{' expected
              byte[] bdata = new byte[];
                                       ^
      1 error



      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      public class ArrayTest
      {
          public static void main(String[] args)
          {
              byte[] bdata = new byte[];
          }
      }

      ---------- END SOURCE ----------
      (Review ID: 144142)
      ======================================================================

      Attachments

        Activity

          People

            gafter Neal Gafter
            jleesunw Jon Lee (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: