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 268334 - Error (red curlies) for many generics usage
Summary: Error (red curlies) for many generics usage
Status: NEW
Alias: None
Product: java
Classification: Unclassified
Component: Editor (show other bugs)
Version: 8.2
Hardware: PC Windows 7
: P3 normal (vote)
Assignee: Dusan Balek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-10-04 09:38 UTC by attila.kelemen
Modified: 2017-06-10 18:01 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
no-red-marks-at-all (66.30 KB, image/png)
2017-06-10 17:21 UTC, Geertjan Wielenga
Details
red-line-1.png (42.83 KB, image/png)
2017-06-10 17:30 UTC, Geertjan Wielenga
Details
red-line-2.png (38.82 KB, image/png)
2017-06-10 17:30 UTC, Geertjan Wielenga
Details

Note You need to log in before you can comment on or make changes to this bug.
Description attila.kelemen 2016-10-04 09:38:03 UTC
When I open my project (https://github.com/kelemen/netbeans-gradle-project), NetBeans shows compiler error in a lot of places. The error seems to be related to inferring generic argument. Everything is fine in 8.1.
Comment 1 attila.kelemen 2016-10-25 19:47:04 UTC
After a discussion with Wade Chandler, we came to the conclusion that the issue happens when using JDK 7 (maybe even 6, did not check this). It cannot be reproduced when the opened project is set to use JDK 8.
Comment 2 attila.kelemen 2016-11-14 21:46:44 UTC
The issue can be simply reproduced by putting a class like this into a project (I have tried it with Maven and Gradle) after setting the project to use JDK 7 (and source level 7).

<pre>
package org.netbeans.fewgrdnfntf;

import java.util.*;

public final class NewClass {
    public static void main(String[] args) {
       Collection<? extends Runnable> src = null;
       Collection<Runnable> dest = new ArrayList<>(src);
    }
}
</pre>
Comment 3 attila.kelemen 2017-06-10 16:19:03 UTC
This issue still exists if I build NB from the sources and it blocks me from upgrading NB from 8.1 and as it stands it will still block me in NB 9.

Altough the previously mentioned example works if I build NB from the sources, however there are still various (more complex) examples where it fails (despite that the code compiles fine). For example:

    import java.util.Collection;
    import java.util.List;
    import java.util.function.Supplier;
    import java.util.stream.Collectors;

    public final class NewClass {
        private static <E extends Throwable> List<TestFactory<E>> test(
                Collection<? extends Supplier<? extends E>> factory) {
            return factory.stream()
                    .map(NewClass::testMap)
                    .collect(Collectors.toList());
        }

        private static <E extends Throwable> TestFactory<E> testMap(Supplier<? extends E> factory) {
            return null;
        }

        private static interface TestFactory<E extends Throwable> {
        }
    }
Comment 4 Geertjan Wielenga 2017-06-10 17:21:15 UTC
Created attachment 164502 [details]
no-red-marks-at-all
Comment 5 Geertjan Wielenga 2017-06-10 17:22:01 UTC
See the pic in the attachment above. No red marks at all. In a Maven project. My environment:


Product Version: NetBeans IDE 8.2 (Build 201705191307)
Updates: NetBeans IDE is updated to version NetBeans 8.2 Patch 2
Java: 1.8.0_121; Java HotSpot(TM) 64-Bit Server VM 25.121-b13
Runtime: Java(TM) SE Runtime Environment 1.8.0_121-b13
System: Windows 7 version 6.1 running on amd64; Cp1252; en_US (nb)
User directory: C:\Users\gwieleng\AppData\Roaming\NetBeans\8.2
Cache directory: C:\Users\gwieleng\AppData\Local\NetBeans\Cache\8.2
Comment 6 Geertjan Wielenga 2017-06-10 17:30:32 UTC
Created attachment 164503 [details]
red-line-1.png
Comment 7 Geertjan Wielenga 2017-06-10 17:30:54 UTC
Created attachment 164504 [details]
red-line-2.png
Comment 8 attila.kelemen 2017-06-10 17:41:17 UTC
The issue is exactly what is shown in Geertjan's screenshot. The code compiles fine but NB still flags it as an error.
Comment 9 Geertjan Wielenga 2017-06-10 18:01:04 UTC
Yes, I can reproduce this.

A related issue is that we need to figure out in the context of Apache, since nb-javac will not be donated to Apache, how we can work on code in nb-javac, i.e., where it will be hosted, where we can file issues, and how/if we can work on it together.