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 268132 - Nondeterministic list of hints on hovering over a method name only
Summary: Nondeterministic list of hints on hovering over a method name only
Status: NEW
Alias: None
Product: java
Classification: Unclassified
Component: Hints (show other bugs)
Version: 8.1
Hardware: PC Windows 7
: P3 normal (vote)
Assignee: Svata Dedic
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-09-21 10:21 UTC by johannes.geiger
Modified: 2016-09-21 10:21 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 johannes.geiger 2016-09-21 10:21:31 UTC
Recently using Java 8 and Netbeans I discovered a phenomenon producing a nondeterministic endless list of hints when hovering over a method name only. Consider the following minimal example:


    import java.util.function.Consumer;
    import java.util.stream.Stream;

    public class Main {

        public static void main(String[] args) {
            Stream.of("Hello", "Netbeans")
                    .forEach(new Consumer<String>() {
                        @Override
                        public void accept(String t) {
                            System.out.println(t);
                        }
                    });
        }
    }

Now, Netbeans is correctly warning me, that the anonymous inner class can be turned into a lambda expression which yields to

    import java.util.stream.Stream;

    public class Main {

        public static void main(String[] args) {
            Stream.of("Hello", "Netbeans")
                    .forEach((String t) -> {
                        System.out.println(t);
                    });
        }
    }

Now, the indicator in the upper right corner is green - as long as I don't hover "println", then it suddenly turns yellow and two hints "Use anonymous inner class" (go back to the initial example) and "Member reference can be used". When activating the second option, the code yields to


    import java.util.stream.Stream;

    public class Main {

        public static void main(String[] args) {
            Stream.of("Hello", "Netbeans")
                    .forEach(System.out::println);
        }
    }

where the indicator is green again until I hover "println" (then it's turning yellow again) and "Use lambda expression" will be given as hint, which would lead to:

    import java.util.stream.Stream;

    public class Main {

        public static void main(String[] args) {
            Stream.of("Hello", "Netbeans")
                    .forEach((x) -> System.out.println(x));
        }
    }

And so on and so on, followed by the already mentioned hints turning into a nondeterministic endless list of hints. I would expect to either be able to configure which form of method call is prefered (or get a default value for this) or that the indicator should not turn yellow.