Hi devs,
Since this is about breaking backward compatibility I need to send a vote. Basically in order to fix SonarQube rule java:S1118 (utility classes should not be instantiable), I’ve introduced a private constructor. Doing so removes the implicit public constructor, hence the breakage.
Now, utility classes contain only static methods and are not meant to be instantiated so while it’s technically a breakage, and some code could have instantiated the classes, it’s a “small” breakage. Also, we should probably not make utility classes public in the first place IMO so we could also consider that these classes were not meant to be public.
<revapi.differences>
<justification>
These utility classes (only static members) had their implicit public constructor made private to
follow SonarQube rule java:S1118 (utility classes should not be instantiable). Instantiating them was
never useful, but this is technically a real breakage since existing code calling the constructor will
fail at runtime.
</justification>
<criticality>highlight</criticality>
<differences>
<item>
<ignore>true</ignore>
<code>java.method.visibilityReduced</code>
<old>method void com.xpn.xwiki.XWikiConstant::<init>()</old>
<new>method void com.xpn.xwiki.XWikiConstant::<init>()</new>
<oldVisibility>public</oldVisibility>
<newVisibility>private</newVisibility>
</item>
<item>
<ignore>true</ignore>
<code>java.method.visibilityReduced</code>
<old>method void com.xpn.xwiki.i18n.i18n::<init>()</old>
<new>method void com.xpn.xwiki.i18n.i18n::<init>()</new>
<oldVisibility>public</oldVisibility>
<newVisibility>private</newVisibility>
</item>
<item>
<ignore>true</ignore>
<code>java.method.visibilityReduced</code>
<old>method void com.xpn.xwiki.util.TOCGenerator::<init>()</old>
<new>method void com.xpn.xwiki.util.TOCGenerator::<init>()</new>
<oldVisibility>public</oldVisibility>
<newVisibility>private</newVisibility>
</item>
<item>
<ignore>true</ignore>
<code>java.method.visibilityReduced</code>
<old>method void com.xpn.xwiki.web.Utils::<init>()</old>
<new>method void com.xpn.xwiki.web.Utils::<init>()</new>
<oldVisibility>public</oldVisibility>
<newVisibility>private</newVisibility>
</item>
</differences>
</revapi.differences>
Note that the VOTE is not just about these classes but about the idea of fixing java:S1118 issues by introducing private constructors for utility classes.
WDYT?
Here’s my +1
Thanks