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 253844 - [81cat] Java hint: CreateSubclass missing test case for a non-static subclass
Summary: [81cat] Java hint: CreateSubclass missing test case for a non-static subclass
Status: NEW
Alias: None
Product: java
Classification: Unclassified
Component: Hints (show other bugs)
Version: 8.1
Hardware: PC Windows 8 x64
: P3 normal (vote)
Assignee: Svata Dedic
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-07-27 09:05 UTC by cezariusz
Modified: 2015-10-02 14:28 UTC (History)
0 users

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description cezariusz 2015-07-27 09:05:34 UTC
Link: http://services.netbeans.org/synergy/client/app/#/case/4989/suite/1691

Product Version: NetBeans IDE Dev (Build 201507240001)
Java: 1.8.0_51; Java HotSpot(TM) 64-Bit Server VM 25.51-b03
Runtime: Java(TM) SE Runtime Environment 1.8.0_51-b16
System: Windows 8 version 6.2 running on amd64; UTF-8; pl_PL (nb)

The following case is not covered with the test case, and it leads to an error:

public class CreateSubclass // HINT: Create subclass
{

    public class NonStaticSubClass // "Create subclass" hint should NOT appear here, as the subclass is not static.
    {

        public NonStaticSubClass() {
        }
    }

}

After invoking the hint the following class is created:

public class NonStaticSubClassImpl extends CreateSubclass.NonStaticSubClass {

}

But it doesn't compile because of the error "an enclosing instance that contains CreateSubclass.NonStaticSubClass is required".
Comment 1 Svata Dedic 2015-07-30 09:27:54 UTC
Well, partially. The hint can generate a constructor which takes the outer class' instance and invokes outer.super().

I block the hint in case of a non-static member and turn this issue into an enhancement:
* generate outer.super() for non-static member classes
* generate nested subclass (not top-level class)

Create subclass suppressed in jet-main#4891cee42d1a