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

Type variable information is not always maintained for anonymous classes

    XMLWordPrintable

    Details

      Description

      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


        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                vromero Vicente Arturo Romero Zaldivar
                Reporter:
                webbuggrp Webbug Group
              • Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated: