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

Hiding of methods from parent classes when nested anonymous classes are compiled

XMLWordPrintable

    • x86_64
    • windows_7

      FULL PRODUCT VERSION :
      1.8.0_20

      ADDITIONAL OS VERSION INFORMATION :
      Windws 7

      A DESCRIPTION OF THE PROBLEM :
      public class Java8Bug {

          public Java8Bug() {
              new JPanel() {
                  {
                      new Runnable() {
                          @Override
                          public void run() {
                              show("test");
                          }
                      }.run();
                  }
              };
          }

          public void show(String string) {

          }
      }

      This compiled in java 7, in java 8 show(String) gets hidden, with the compiler error

      error: incompatible types: String cannot be converted to boolean

      REGRESSION. Last worked in version 7u10

      ADDITIONAL REGRESSION INFORMATION:
      1.7_09

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      compile the code

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      code compiles
      ACTUAL -
      compile gives error error: incompatible types: String cannot be converted to boolean

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      error: incompatible types: String cannot be converted to boolean

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      public class Java8Bug {

          public Java8Bug() {
              new JPanel() {
                  {
                      new Runnable() {
                          @Override
                          public void run() {
                              show("test");
                          }
                      }.run();
                  }
              };
          }

          public void show(String string) {

          }
      }

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

            vromero Vicente Arturo Romero Zaldivar
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: