HexLiteralCase

Since Checkstyle 12.1.0

Description

Checks that hexadecimal literals are defined using uppercase letters (A-F) rather than lowercase (a-f). This convention follows the OpenJDK Style Guide.

Examples

To configure the check:


<module name="Checker">
  <module name="TreeWalker">
    <module name="HexLiteralCase"/>
  </module>
</module>

Example:


class Example1 {
  byte b1  = 0x1b;          // violation  'Should use uppercase hexadecimal letters.'
  byte b2  = 0x1B;

  short s1 = 0xF5f;         // violation  'Should use uppercase hexadecimal letters.'
  short s2 = 0xF5F;

  int i1 = 0x11 + 0xabc;    // violation  'Should use uppercase hexadecimal letters.'
  int i2 = 0x11 + 0xABC;
  int i3 = 0X123 + 0Xabc;   // violation  'Should use uppercase hexadecimal letters.'
  int i4 = 0X123 + 0XABC;
  int i5 = 0xdeadbeef;      // violation  'Should use uppercase hexadecimal letters.'
  int i6 = 0xDEADBEEF;

  long l1 = 0x7fff_ffff_ffff_ffffL;
  // violation above 'Should use uppercase hexadecimal letters.'
  long l2 = 0x7FFF_FFFF_FFFF_FFFFL;

  long l3 = 0x7FFF_AAA_bBB_DDDL;
  // violation  above 'Should use uppercase hexadecimal letters.'
  long l4 = 0x7FFF_AAA_BBB_DDDL;

}

Example of Usage

Violation Messages

All messages can be customized if the default message doesn't suit you. Please see the documentation to learn how to.

Package

com.puppycrawl.tools.checkstyle.checks

Parent Module

TreeWalker