forked from checkstyle/checkstyle
-
Notifications
You must be signed in to change notification settings - Fork 2
/
IllegalInstantiationCheck.xml
39 lines (39 loc) · 1.54 KB
/
IllegalInstantiationCheck.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?xml version="1.0" encoding="UTF-8"?>
<checkstyle-metadata>
<module>
<check fully-qualified-name="com.puppycrawl.tools.checkstyle.checks.coding.IllegalInstantiationCheck"
name="IllegalInstantiation"
parent="com.puppycrawl.tools.checkstyle.TreeWalker">
<description><p>
Checks for illegal instantiations where a factory method is preferred.
</p>
<p>
Rationale: Depending on the project, for some classes it might be
preferable to create instances through factory methods rather than
calling the constructor.
</p>
<p>
A simple example is the {@code java.lang.Boolean} class.
For performance reasons, it is preferable to use the predefined constants
{@code } and {@code }.
Constructor invocations should be replaced by calls to {@code Boolean.valueOf()}.
</p>
<p>
Some extremely performance sensitive projects may require the use of factory
methods for other classes as well, to enforce the usage of number caches or
object pools.
</p>
<p>
There is a limitation that it is currently not possible to specify array classes.
</p></description>
<properties>
<property default-value="" name="classes" type="java.lang.String[]">
<description>Specify fully qualified class names that should not be instantiated.</description>
</property>
</properties>
<message-keys>
<message-key key="instantiation.avoid"/>
</message-keys>
</check>
</module>
</checkstyle-metadata>