Please use the Apache issue tracking system for new NetBeans issues ( !!
Bug 241120 - Too many return values.
Too many return values.
Product: java
Classification: Unclassified
Component: Hints
PC Windows XP
: P2 (vote)
: 8.0
Assigned To: Svata Dedic
Depends on:
  Show dependency treegraph
Reported: 2014-01-29 13:46 UTC by kimsp
Modified: 2014-02-14 02:55 UTC (History)
0 users

See Also:
Issue Type: DEFECT

IDE log (102.96 KB, text/plain)
2014-01-29 13:46 UTC, kimsp

Note You need to log in before you can comment on or make changes to this bug.
Description kimsp 2014-01-29 13:46:24 UTC
Product Version = NetBeans IDE Dev (Build 201401290001)
Operating System = Windows XP version 5.1 running on x86
Java; VM; Vendor = 1.7.0_45
Runtime = Java HotSpot(TM) Client VM 24.45-b08

I have this code in a method in a class (using Google Guava):

List<SomeObject> objects = .... ;

       Iterable<String> strings = Iterables.transform(objects, new Function<SomeObject, String>() {
            public String apply(SomeObject f) {
                return f.getAString();

I want do extract it to its own method. However, Netbeans tells me that there is "Too many return values.".

The method it should make should look like this:

   private   Iterable<String> getEnvelopeIds(List<SomeObject> objects)  {
           Iterable<String> strings = Iterables.transform(objects, new Function<SomeObject, String>() {
            public String apply(SomeObject f) {
                return f.getAString();
Comment 1 kimsp 2014-01-29 13:46:30 UTC
Created attachment 144540 [details]
IDE log
Comment 2 Svata Dedic 2014-01-31 18:45:44 UTC
Please give a complete sample. When I created a testcase using the provided code, everything worked OK.

public abstract class ClassA {
    public void test() {
        List<ClassA> objects = new ArrayList<>();

       Iterable<String> strings = Iterables.transform(objects, new Function<ClassA, String>() {
            public String apply(ClassA f) {
                return f.toString();

... selected whole lines from "Iterable<String>" to "});" inclusive, Alt-enter, Introduce method.

The message may indicate that your code modifies some local variable whose value is used later in the original function.
Comment 3 kimsp 2014-02-03 11:27:56 UTC
Hi Svata

In your example try to include this line 

after the:

That is, you print out the contents of strings.

Then you cannot select the lines you say without getting a Too Many return values.

I have example code here:

// all below is inside an existing method 

List<String> objects = new ArrayList<String>();

Iterable<String> strings = Iterables.transform(objects, new Function<String, String>() {

   public String apply(String f) {
      return f.toString();

//Above code I can't refactor if I have this system err commented in.

List<String> stringsTwo = new ArrayList<String>();

//The above lines (stringsTwo declaration + insertions) I can refactor to a method. Even though I have this system err commented in. 
Comment 4 Svata Dedic 2014-02-03 16:01:09 UTC
Great; return was counted as an exit point from the method although it was actually a return from a nested class. The same issue would happen for returns from lambda code blocks or break-continue in nested classes/lambdas.

Fixed in jet-main#9e2ea831f168
Comment 5 Quality Engineering 2014-02-14 02:55:44 UTC
Integrated into 'main-silver', will be available in build *201402140001* on (upload may still be in progress)

User: Svata Dedic <>
Log: #241120: do not count exit points of nested classes and lambdas

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo