Is it possible to programmatically clear all all transient arrays?
When handling an unexpected situation, I'd like to clear all internal arrays (something like calling .deselect()) without having to manually fill them.
I have not seen anything like this in the API-s, but maybe I've missed something or there is some neat trick.
Transient array contents are wiped automatically when an applet deselect event OR a card tear (reset) event occurs. This is configured when creating the transient array. This is the only way of automatically clearing all transient arrays of a particular type (deselect/reset).
Programatically, the only way to clear an array is by using Util.arrayFillNonAtomic(...). You can't trigger a fake deselect/reset event from within an applet.
However, you might find want to consider using transactions... Have a look at the JCSystem package.
If you are concerned about data being cleared, you could leave it in the APDU buffer (or copy it there to work on) as this will be cleared at the end of the APDU (or before the next APDU is received).