From c989cba9637ae3963c8187171c737b3df13528a9 Mon Sep 17 00:00:00 2001 From: Sam Brannen <104798+sbrannen@users.noreply.github.com> Date: Thu, 1 Feb 2024 12:44:57 +0100 Subject: [PATCH] Add Checkstyle rule to enforce use of class literals for primitives & void This commit introduces a globally applied Checkstyle rule which enforces the use of class literals for primitive types and void by forbidding the use of the TYPE constants in Boolean, Character, Byte, Short, Integer, Long, Float, Double, and Void. For example, if MyClass uses one of the TYPE constants, the build will now fail with a message similar to the following. [ERROR] <...>/MyClass.java:39: Please use class literals for primitives and void -- for example, int.class instead of Integer.TYPE. --- src/checkstyle/checkstyle.xml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/checkstyle/checkstyle.xml b/src/checkstyle/checkstyle.xml index 63ab4d1ae5..7ae6fa6c0a 100644 --- a/src/checkstyle/checkstyle.xml +++ b/src/checkstyle/checkstyle.xml @@ -213,6 +213,13 @@ + + + + + + +