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

compiler allows illegal type void[]

XMLWordPrintable

    • sparc
    • solaris_2.5.1



      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
      -------------------------------------------------------

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

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

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: