This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 256349 - Netbeans compiles lambda incorrectly (vs. javac)
Summary: Netbeans compiles lambda incorrectly (vs. javac)
Status: NEW
Alias: None
Product: java
Classification: Unclassified
Component: Compiler (show other bugs)
Version: 8.0.2
Hardware: PC Windows 8.1
: P3 normal (vote)
Assignee: Dusan Balek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-11-04 07:41 UTC by assylias
Modified: 2016-01-18 10:58 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description assylias 2015-11-04 07:41:00 UTC
1. Create a new Project > Java > Java Application
2. Copy the code below in a "Test" class in the default package:

    import java.util.stream.Stream;
    public class Test {
      public static void main(String[] args) {
        A<Integer> a = new A<> ();
        a.max();
      }

      static class A<T extends Number & Comparable<? super T>> {
        public T max() { return s().max(T::compareTo).orElse(null); }
        public Stream<T> s() { return Stream.empty(); }
      }
    }

3. Right click > Run file

The output shows an exception:

Exception in thread "main" java.lang.BootstrapMethodError: call site initialization exception
....
Caused by: java.lang.invoke.LambdaConversionException: Invalid receiver type class java.lang.Number; not a subtype of implementation type interface java.lang.Comparable

4. Clean & Build and run again: no output as expected
5. Insert a space in the file and run again: exception
6. From the command line, in the directory where the Test.java file is located:

    javac -d . Test.java
    java -cp . Test

outputs nothing as expected.
Comment 1 assylias 2016-01-18 10:58:03 UTC
Fixed in 8.1