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

javac accepts an illegal name as a receiver parameter name

XMLWordPrintable

    • b19
    • generic
    • generic
    • Verified

        A DESCRIPTION OF THE PROBLEM :
        javac compiles the code below instead of rejecting it. I've tested all major versions starting from 1.8 up to 11-ea-14. The problem starts at http://hg.openjdk.java.net/jdk/jdk/file/7a7285477153/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java#l3119 , and later checks don't reject such qualified identifiers if they refer to an entity having the expected type ("C.c" field in my example).

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        javac C.java

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        A compilation error, e.g.:

        C.java:3: error: ')' expected
            void foo(C c.c) {
                        ^

        ACTUAL -
        Compilation succeeds.

        ---------- BEGIN SOURCE ----------
        class C {
            C c;
            void foo(C c.c) {
            }
        }

        ---------- END SOURCE ----------

          1. C.java
            0.1 kB
            Fairoz Matte

              bsrbnd Bernard Blaser
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved: