That's correct. You can declare and use static
variables in a trigger, but you cannot use static
initializer blocks. See Static and Instance Methods, Variables, and Initialization Code, which notes another critical caveat about declaring statics within the body of a trigger:
A static variable defined in a trigger doesn’t retain its value between different trigger contexts within the same transaction, such as between before insert
and after insert
invocations. Instead, define the static variables in a class so that the trigger can access these class member variables and check their static values.
Although it's legal to declare statics in a trigger body, generally, it's better to place these statics in a trigger handler class. You're also able to use static initializer blocks in that context.