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

Extraneous access checks implemented by javac

XMLWordPrintable

    • b86
    • generic
    • generic
    • Verified

        The following program should compile, but does not with 9 dev tip not with 8u40:

        // ------ 8< --------
        public class X {
        public static void main(String[] args) {
        new Neg19_01<Object>(null) {}; // OK.
        }
        }

        class Neg19_01<T> {
        private class Private {}
        Neg19_01(Private p) {
        System.out.println("Neg19_01");
        }
        }
        // ------ 8< --------

        The last para of 15.9.5.1 "Anonymous constructor reads":

        "Note that it is possible for the signature of the anonymous constructor to refer
        to an inaccessible type (for example, if such a type occurred in the signature of
        the superclass constructor cs ). This does not, in itself, cause any errors at either
        compile-time or run-time."

        Thus this access check implemented by javac has no sanction in JLS.

        ECJ compiles and run the code fine.

          1. expr62601m121.jtr
            5 kB
          2. expr63102m1031.jtr
            3 kB
          3. expr79301m000001.jtr
            3 kB
          4. failedtestCaseList.txt
            0.7 kB
          5. failedtestCaseList.txt
            0.7 kB
          6. JDK-8075799
            5 kB
          7. JDK-8075799
            5 kB

              sadayapalam Srikanth Adayapalam (Inactive)
              sadayapalam Srikanth Adayapalam (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

                Created:
                Updated:
                Resolved: