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 123962 - Add a "Directly instantiable utility class" hint
Summary: Add a "Directly instantiable utility class" hint
Status: NEW
Alias: None
Product: java
Classification: Unclassified
Component: Source (show other bugs)
Version: 6.x
Hardware: PC Windows XP
: P3 blocker (vote)
Assignee: Rastislav Komara
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-12-13 15:38 UTC by matthies
Modified: 2009-02-03 10:53 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 matthies 2007-12-13 15:38:43 UTC
Under Options -> Java Code -> Hints -> APIs there are the two hints "Utility class with visible 
constructor" and "Utility class without constructor". These don't quite match my policy for utility classes. To allow 
client code to extend my utility classes with additional members, I make utility classes abstract and/or add protected 
constructor that always throws. This prevents direct instantiation of the class while still allowing it to be extended. 
(Unfortunately Java doesn't allow "static" subclassing, therefore there needs to exist a constructor that is accessible 
by the subclass.)

So it would be nice to have a hint for utility classes that are not abstract and have a public or package constructor. 
Or in other words: for classes containing only static members where code other than the class itself can directly 
create an (exact-type) instance of the class.
Comment 1 Rastislav Komara 2009-02-03 10:53:50 UTC
Overtake.