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 222487 - Incorrect hint for "no suitable constructor found"
Summary: Incorrect hint for "no suitable constructor found"
Alias: None
Product: java
Classification: Unclassified
Component: Hints (show other bugs)
Version: 7.3
Hardware: PC Windows 7
: P3 normal with 1 vote (vote)
Assignee: Svata Dedic
Depends on:
Reported: 2012-11-20 18:02 UTC by _ gtzabari
Modified: 2017-11-24 20:53 UTC (History)
1 user (show)

See Also:
Exception Reporter:


Note You need to log in before you can comment on or make changes to this bug.
Description _ gtzabari 2012-11-20 18:02:44 UTC
Product Version: NetBeans IDE Dev (Build 201211150001)
Java: 1.7.0_09; Java HotSpot(TM) 64-Bit Server VM 23.5-b02
Runtime: Java(TM) SE Runtime Environment 1.7.0_09-b05
System: Windows 7 version 6.1 running on amd64; Cp1252; en_CA (nb)
User directory: C:\Users\Gili\AppData\Roaming\NetBeans\dev
Cache directory: C:\Users\Gili\AppData\Local\NetBeans\Cache\dev

1. Create an empty class that extends Jersey's WebResource.
2. Netbeans flags the following compiler error:

no suitable constructor found for WebResource()
    constructor WebResource.WebResource(WebResource,UriBuilder) is not applicable
      (actual and formal argument lists differ in length)
    constructor WebResource.WebResource(ClientHandler,CopyOnWriteHashMap<String,Object>,URI) is not applicable
      (actual and formal argument lists differ in length)
(Alt-Enter shows hints)

3. I hit ALT+Enter but the only hint I am given is "create subclass"

Expected behavior: Provide a hint to create the required constructor(s).
Comment 1 _ gtzabari 2012-11-20 18:03:08 UTC
I'm not sure whether this is a bug or enhancement. Please judge for yourself.
Comment 2 _ gtzabari 2012-11-20 18:08:48 UTC
Ah! It turns out this use-case has a twist.

com.sun.jersey.api.client.WebResource only has two constructors. One is private. The other is package-private.

In other words, users aren't meant to subclass it. So the expected behavior changes to:

1. Netbeans shouldn't provide a hint to create a subclass.
2. Improve error message to indicate a subclass cannot be created at all from the current package (or all at for some classes). The current message encourages the user to fix the constructor, which isn't actually possible.
Comment 3 Martin Balin 2016-07-07 07:26:23 UTC
This old bug may not be relevant anymore. If you can still reproduce it in 8.2 development builds please reopen this issue.

Thanks for your cooperation,
NetBeans IDE 8.2 Release Boss
Comment 4 _ gtzabari 2016-07-07 19:38:14 UTC
Issue still exists in dev build 201607060002.

Here is a simple testcase:

package parent;

public class Parent {

    private Parent() {

    Parent(String value) {

package child;

import parent.Parent;

public class Child extends Parent {

Comment 5 dtrebbien 2017-11-24 20:53:17 UTC
I created a Pull Request to address the first part of Comment #2:

For the second part, this error message comes from javac. I agree with you that the error message is misleading, so I posted to the OpenJDK compiler-dev mailing list: