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 267399 - Wrong hint to declare CloneNotSupportedException
Summary: Wrong hint to declare CloneNotSupportedException
Status: RESOLVED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Hints (show other bugs)
Version: 8.2
Hardware: PC Other
: P3 normal (vote)
Assignee: Svata Dedic
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-08-02 09:32 UTC by cezariusz
Modified: 2016-08-11 01:56 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Error (7.20 KB, image/png)
2016-08-02 09:32 UTC, cezariusz
Details

Note You need to log in before you can comment on or make changes to this bug.
Description cezariusz 2016-08-02 09:32:12 UTC
Created attachment 161530 [details]
Error

Product Version: NetBeans IDE Dev (Build 201606280002)
Java: 1.8.0_60; Java HotSpot(TM) 64-Bit Server VM 25.60-b23
Runtime: Java(TM) SE Runtime Environment 1.8.0_60-b27
System: Windows 10 version 10.0 running on amd64; Cp1250; pl_PL (nb)

1. Create a class which extends java.util.Date:

public class NewClass1 extends Date {

    private static final long serialVersionUID = 1L;

}

2. On the class name you will have a hint to implement clone() - do it:

public class NewClass1 extends Date {

    private static final long serialVersionUID = 1L;

    @Override
    public Object clone() {
        return super.clone();
    }

}

3. On the clone() method you will see a hint to declare CloneNotSupportedException - do it:

public class NewClass1 extends Date {

    private static final long serialVersionUID = 1L;

    @Override
    public Object clone() throws CloneNotSupportedException {
        return super.clone();
    }

}

4. You end up with an error, because the overridden method does not throw CloneNotSupportedException.
Comment 1 Svata Dedic 2016-08-05 08:30:45 UTC
I'll make the hint not appear if the overriden clone does not declare CNSE.

fixed in jet-main#16564a9df1c1
Comment 2 Quality Engineering 2016-08-11 01:56:28 UTC
Integrated into 'main-silver', will be available in build *201608110002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/16564a9df1c1
User: Svata Dedic <sdedic@netbeans.org>
Log: #267399: do not suggest to and CNSE if superclass' clone() does not declare it