@Incubating
class PurityChecker
extends TypeCheckingDSL
A compile-time checker that verifies @Pure methods have no side effects.
By default, strict purity is enforced: no field mutations, no I/O, no logging,
no non-deterministic calls. The allows option declares which effect
categories are tolerated:
// Strict: no side effects at all
@TypeChecked(extensions = 'groovy.typecheckers.PurityChecker')
// Tolerate logging and metrics
@TypeChecked(extensions = 'groovy.typecheckers.PurityChecker(allows: "LOGGING|METRICS")')
Effect categories:
LOGGING — calls to logging frameworks (SLF4J, JUL, etc.) and printlnMETRICS — calls to metrics instruments (Micrometer, OpenTelemetry, etc.)IO — file, network, database, and console I/ONONDETERMINISM — time-dependent, random, and environment-dependent callsAlso recognises:
@SideEffectFree (Checker Framework) — treated as @Pure with implicit NONDETERMINISM allowed@Contract(pure = true) (JetBrains) — treated as @Pure@Memoized — treated as effectively pure| Constructor and description |
|---|
PurityChecker() |
Copyright © 2003-2026 The Apache Software Foundation. All rights reserved.