Yes, trespass law is pretty well defined.
If you walk past a "no trespassing" sign, or cross a fence clearly designed to keep people out, then you have "been warned" already. There doesn't need to be a re-enter.
The question is - if you came from the air, in an emergency, there is no sign or fence in the sky? What would the judge infer? I think they would let it slide. Maybe I am wrong?
If it's a commercial pilot familiar with dealing with sensitive areas, I don't think they could just claim ignorance that "it looked like a safe place to land". Even general aviation pilots are supposed to know how to read maps that state where military bases and restricted areas are.