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

compiler allows illegal type void[]

    XMLWordPrintable

    Details

    • Subcomponent:
    • CPU:
      sparc
    • OS:
      solaris_2.5.1

      Description



      Name: dkC59003 Date: 03/09/98



      The section "8.3 Field Declarations" of JLS says:
      "The variables of a class type are introduced by field declarations:
           FieldDeclaration:
                   FieldModifiers(opt) Type VariableDeclarators ;"
      The section "8.4.1 Formal Parameters" of JLS says:
      "Each parameter specifier consists of a type and an identifier (optionally followed by brackets) that specifies
      the name of the parameter:
      ...
           FormalParameter:
                   Type VariableDeclaratorId"

      Two tests below use void[] in the place of Type in FieldDeclaration and
      FormalParameter.
      JDK 1.1.1 through 1.1.6 compilers do not detect any errors
      whereas JDK 1.2beta3K compiler correctly reports compile-time error
      in each case:
      -------------------------------------------------------
      public class clss02109 {

      void[] x; // compile-time error

      }
      -----------------------------------------
      clss02109.java:3: Instance variables can't be void: x
      void[] x; // compile-time error
      ^
      1 error
      -------------------------------------------------------
      public class clss02707 {

      Object m( void[] ob ) { // compile time error
      return ob ;
      }
      }
      -----------------------------------------
      clss02707.java:3: Argument can't have type void: ob
      Object m( void[] ob ) { // compile time error
      ^
      1 error
      -------------------------------------------------------

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

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              tturnidgsunw Todd Turnidge (Inactive)
              Reporter:
              dkhukhrosunw Dmitry Khukhro (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: