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

Unsafe typecast in java.util.stream.Streams.Nodes

XMLWordPrintable

    • b112
    • Not verified

      Unsafe typecast long to int:

      public static <T> Node<T> flatten(Node<T> node, IntFunction<T[]> generator) {
          if (node.getChildCount() > 0) {
              T[] array = generator.apply((int) node.count());
          ..........
      Same for:
      public static Node.OfInt flattenInt(Node.OfInt node)
      public static Node.OfLong flattenLong(Node.OfLong node)
      public static Node.OfDouble flattenDouble(Node.OfDouble node)

      static final class ConcNode<T>
          public void copyInto(T[] array, int offset) {
              .............
              right.copyInto(array, offset + (int) left.count());
          }
          private abstract static class OfPrimitive<E, T_CONS, T_ARR,
              .............
              public void copyInto(T_ARR array, int offset) {
                  .............
                  right.copyInto(array, offset + (int) left.count());
              }
              public T_ARR asPrimitiveArray() {
                  T_ARR array = newArray((int) count());
                  .............

            psandoz Paul Sandoz
            ogb Oleg Barbashov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: