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

Type variable information is not always maintained for anonymous classes

XMLWordPrintable

      A DESCRIPTION OF THE PROBLEM :
      Type variable information is not always maintained for anonymous classes

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run the source code

      ACTUAL -
      T
      null

      ---------- BEGIN SOURCE ----------
      public class Xx<S> {

          public static <T> void main(String[] args) {
              printIt(new Xx<T>() {}.getClass());

              Runnable r = () -> printIt(new Xx<T>() {}.getClass());
              r.run();
          }

          static void printIt(Class<?> cl) {
              ParameterizedType pt = (ParameterizedType) cl.getGenericSuperclass();
              System.out.println(pt.getActualTypeArguments()[0]);
          }
      }

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

      FREQUENCY : always


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

              Created:
              Updated:
              Resolved: