"this.value" allowed as case label.

XMLWordPrintable

    • Type: Bug
    • Resolution: Duplicate
    • Priority: P4
    • None
    • Affects Version/s: 1.1.4
    • Component/s: tools
    • None
    • generic
    • solaris_2.5.1

      The JLS says that a case label needs to be a ConstantExpression. The yield of ConstantExpression does not include expressions of the form "this.value". Nevertheless, javac compiles the following program without complaint:

      public
      class Case {
          static final int value = 100;

          void method(int i) {
      switch (i) {

      case this.value :
      System.out.println("hi");
      break;

      }

          }
      }

      This error allows some incorrect code to compile.

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

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: