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 139354 - java editor shows an error when using nested generics
Summary: java editor shows an error when using nested generics
Status: RESOLVED DUPLICATE of bug 129581
Alias: None
Product: java
Classification: Unclassified
Component: Editor (show other bugs)
Version: 6.x
Hardware: All Windows XP
: P3 blocker (vote)
Assignee: Jan Lahoda
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-07-09 09:16 UTC by genericsparser
Modified: 2008-07-09 09:43 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 genericsparser 2008-07-09 09:16:39 UTC
The following code confuses java editor but compiles just fine:

---- CODE BEGIN ----
package generics.bug;

abstract class AbstractResponse { }

abstract class AbstractRequest<T extends AbstractResponse> { }

interface Handler {
    <R extends AbstractResponse, Q extends AbstractRequest<R>>
        R execute(Q request);
}

class Response extends AbstractResponse {
    private int number;

    public Response(int number) { this.number = number; }

    public int getNumber() { return number; }

}

class Request extends AbstractRequest<Response> {
    private int data;

    public Request(int data) { this.data = data; }

    public int getData() { return data; }

}
public class TestCase implements Handler {

    public static void main(String... args) {
        TestCase test = new TestCase();
        Response response = test.execute(new Request(1));
        response.getNumber(); // gets through the IDE built-in parser just fine

        // \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
        test.execute(new Request(1)).getNumber(); // DOES NOT WORK
        // shows popup with "cannot find symbol AbstractResponse.getNumber()
        // \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
    }

    public
        <R extends AbstractResponse, Q extends AbstractRequest<R>>
        R execute(Q request)
    {
        System.out.printf("execute DONE, request class %s%n",
            request.getClass().getName());
        return null;
    }

}
---- CODE END ----


Observed for 6.1 and 6.5 m1 on Windows XP, JDK 1.6.0_05:

Product Version: NetBeans IDE 6.1 (Build 200804211638)
Java: 1.6.0_05; Java HotSpot(TM) Client VM 10.0-b19
System: Windows XP version 5.1 running on x86; Cp1251; ru_RU (nb)

Product Version: NetBeans IDE Dev (Build 200807040101)
Java: 1.6.0_05; Java HotSpot(TM) Client VM 10.0-b19
System: Windows XP version 5.1 running on x86; Cp1251; ru_RU (nb)

The same code causes no issues in Eclipse 3.2 and above.

Thank you.
Comment 1 Jiri Prox 2008-07-09 09:34:17 UTC
reproducible

workaround:
test.<Response,Request>execute(new Request(1)).getNumber();
Comment 2 Jan Lahoda 2008-07-09 09:43:28 UTC
Seems like a duplicate of issue #129581. See also:
http://bugs.sun.com/view_bug.do?bug_id=6650759

*** This issue has been marked as a duplicate of 129581 ***