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

javac, generates erroneous LVT for a test case with lambda code

    XMLWordPrintable

Details

    • b105
    • Verified

    Description

      Javac generates a wrong LVT for this test case:

      import java.util.List;
      import java.util.Arrays;
      import java.util.stream.Collectors;

      public class LambdaDemo {
         public static void main(String... args) {
           final List<Integer> numbers = Arrays.asList(1, 2, 3);
           final List<Integer> numbersPlusOne =
               numbers.stream().map(number -> number / 0).collect(Collectors.toList());
         }
      }

      Exception in thread "main" java.lang.ArithmeticException: / by zero
           at LambdaDemo.lambda$0(LambdaDemo.java:1) <-- oops
           at LambdaDemo$$Lambda$1.apply(Unknown Source)
           at
      java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:188)
           at
      java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948)
           at
      java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:467)
           at
      java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:457)
           at
      java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:710)
           at
      java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:231)
           at
      java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:474)
           at LambdaDemo.main(LambdaDemo.java:10)

      Attachments

        Activity

          People

            vromero Vicente Arturo Romero Zaldivar
            vromero Vicente Arturo Romero Zaldivar
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: