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 253834 - Hint interaction: ConvertAnonymousToMember produces warning about public constructor
Summary: Hint interaction: ConvertAnonymousToMember produces warning about public cons...
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
Depends on:
Blocks: 253817
  Show dependency tree
Reported: 2015-07-27 07:41 UTC by cezariusz
Modified: 2015-08-04 08:39 UTC (History)
0 users

See Also:
Exception Reporter:


Note You need to log in before you can comment on or make changes to this bug.
Description cezariusz 2015-07-27 07:41:53 UTC

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)

Invoke the hint "Convert Anonymous To Member" on the following code:

    private Object foo = new Object() // HINT: Convert anonymous to member

It will generate:

    private Object foo = new ObjectImpl();

    private static class ObjectImpl extends Object { // HINT: Convert anonymous to member

        public ObjectImpl() {

The ObjectImpl constructor is public, so it leads to the warning "Constructor is declared public in non-public class". I think it should be private.
Comment 1 Svata Dedic 2015-07-30 08:27:21 UTC
the public constructor in non-public class is a 'code style' hint; it's off by default and whether it is on or not depends on the coding conventions the team adheres to.

The solution would be to check whether this hint is enabled and generate modifiers automatically, but potentially there can be many such hints checking the exact coding style - so the best approach would be probably to allow the code to undergo a SERIES of automatic transformation; the user should control which transformations are enabled or not.

making enhancement, as an example of hint interaction which should be solved.