Error Prone 2.1.3 Release

278 views
Skip to first unread message

Nicholas Glorioso

unread,
Dec 11, 2017, 2:36:36 PM12/11/17
to error-prone-announce

Error Prone 2.1.3 is now available for download from Maven Central.


New checks:

  • [SwitchDefault, disabled by default] - Will warn if a switch statement's default case is not the last condition:

switch (someInt):

 // This would be flagged

 default:

 case 1: return true;

 case 2: return false;

  • [ReachabilityFenceUsage, warning enabled by default] - If one uses Java 9's Reference.reachabilityFence, one should use it in a finally block to ensure that the reachability fence is triggered.

  • [ThreeLetterTimeZoneID, warning enabled by default] - Flags usage of DateTime.getTimeZone where the argument is a 3-letter time zone ID. Due to issues described on our bugpattern page, these time zone ID's probably don't do what you expect.

  • [UnsafeFinalization, warning enabled by default] - Detects risky calls to native methods from objects with finalizers.

  • [FloatCast, warning enabled by default] - Detects expression chains where floating point binary multiplications are chained with integral casts without parentheses:

// This truncates 1.5 to 1L before multiplying

long SIZE = (long) 1.5 * 1024 * 1024 * 1024;

// This does what you intend

long ACCURATE_SIZE = (long) (1.5 * 1024 * 1024 * 1024);


  • [MissingSuperCall, error enabled by default] - Checks for missing calls to super when overriding a method with certain annotations that declare that those overriders should call the super method.

  • [PrivateSecurityContractProtoAccess, error enabled by default] - Checks for calls to private proto data in Safe HTML Types, a Google project that helps developers avoid XSS while generating HTML data in Java.

  • [JUnit4ClassAnnotationNonStatic, error enabled by default] - fail when JUnit's @BeforeClass or @AfterClass is used on a non-static method.

  • [InexactVarargsConditional, error enabled by default] - Fail when a ternary expression that has array and non-array sub-expressions is used in last position of a varargs method invocation, as either side will be wrapped into an array.


New features

  • Add a new -XepExcludedPaths flag to Error Prone to allow developers to exclude checking on directories or individual source files. (#599)

  • Added new annotations to Error Prone with the same semantics as those in JSR-305. The new annotations avoid split-package issues with javax.annotation under JDK 9 (see guava#2960).

    • @GuardedBy

    • @OverridingMethodsMustInvokeSuper

    • @CheckReturnValue


Other changes:

  • OvershadowingSubclassFields is renamed to HidingField

  • FallThrough and MissingCasesInEnumSwitch are warning-level by default.

    • These checks enforce rules in the Google Java Style guide, and they point out potential problems, but are not always bugs.

  • Add disableable and suppressionAnnotations as annotation properties in @BugPattern to replace the suppressibility and customSuppressionAnnotation properties.

    • Note: This allows checks to be disabled via command line flags independently of the suppressibility via suppression annotations.

  • Recognize Java 9's javax.annotation.processing.Generated as a marker of generated code. (#811)

  • Improve diagnostics for Immutable-related checks

  • Improvements to JdkObsolete's behavior to ignore more contexts where the deprecated classes are necessary.

Reply all
Reply to author
Forward
0 new messages