Class ImmutableTypes
This is the single owner of the type set that IntentionallyStatic's javadoc
defines in prose. Everything asking "is this static field provably immutable?" resolves
here — GuardrailEngine's build-time gate today, StaticSweep's worklist report when
it lands — because two readers of one rule is a rule that drifts
(M1D_static_sweep_tool § Q_one_rule_engine).
The predicate is split from the reading of it on purpose: isImmutable(String, boolean, boolean, boolean) takes plain
facts about a field's type, not a parsed representation of one, so a caller that reads class files
some other way still gets the same verdict.
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleanisImmutable(String typeName, boolean primitive, boolean isEnum, boolean isRecord) Whether a field of this type has an immutable referent.The named half of the rule, for a caller that wants to print or diff it.
-
Method Details
-
isImmutable
public static boolean isImmutable(String typeName, boolean primitive, boolean isEnum, boolean isRecord) Whether a field of this type has an immutable referent. Says nothing aboutfinal— the gate needs both, sincefinalgoverns whether the reference can change and this governs whether the thing it points at can.A record's components are not checked: a record of mutable parts passes. Accepted — the alternative is a transitive walk the gate deliberately drops, and a holder that reaches a component is already flagged for being of a mutable type.
- Parameters:
typeName- fully-qualified, e.g."java.awt.Color"
-
namedTypes
-