Details

    • Subcomponent:
    • CPU:
      generic
    • OS:
      generic

      Description

      FULL PRODUCT VERSION :


      A DESCRIPTION OF THE PROBLEM :
      Please check the code I submit.
      Runtime generic cast should throw an exception.
      And there should be a way to get the actual generic parameter type.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      We know that the future of the execution should be Future<Boolean>.
      But runtime cast doesn't throw any exception.
      And we are not able to know the actual generic parameter type anymore.
      ACTUAL -
      V
      V
      XXXXXXXXfalse
      V
      YYYYYYYYfalse

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
                      Future<?> aaa = Executors.newCachedThreadPool().submit(new Callable<Boolean>() {
                          @Override
                          public Boolean call()
                          {
                              return false;
                          }
                      });
                      System.out.println(((ParameterizedType)aaa.getClass().getGenericInterfaces()[0]).getActualTypeArguments()[0]);
                      Future<Boolean> temp = (Future<Boolean>) aaa;
                      System.out.println(((ParameterizedType)temp.getClass().getGenericInterfaces()[0]).getActualTypeArguments()[0]);
                      System.out.println("XXXXXXXX" + (temp == null));
                      Future<Integer> temp1 = (Future<Integer>) aaa;
                      System.out.println(((ParameterizedType)temp1.getClass().getGenericInterfaces()[0]).getActualTypeArguments()[0]);
                      System.out.println("YYYYYYYY" + (temp1 == null));
      ---------- END SOURCE ----------

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                mcimadamore Maurizio Cimadamore
                Reporter:
                webbuggrp Webbug Group
              • Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: