Add MemorySafeUndeclaredThrowableStrategy

Port the latest unreleased UndeclaredThrowableStrategy implementation
from cglib to fix a memory-leak present in v3.

Issue: SPR-10709
(cherry picked from 587877c)