I've seen OutOfMemoryError with no stack trace - I think also StackOverflowError, on some systems anyway. Other than that, seems like the stack trace is most always present. It's possible some details get screwed up by compiler optimizations in some cases, but I can't recall ever noticing that effect.
As for "...compiled code..." messages - is it possible you're remembering the output from your
IDE rather than a raw stack trace? IDE's will look at the stack trace and try to find source code that goes with it, and if you don't have the source (or the IDE doesn't know where it is), then you get a "compiled code" message. But usually that's still accompanied by a method and line number - it's just that the IDE can't
show you the source. Maybe that's not always the case though.
Barb - another issue you might want to beware of is that creating a new Throwable may be a fairly heavy-weight operation (performance-wise) compared to most other things you might be doing. It's pretty minor compared to, say, accessing a database. But it could be huge compared to, say, multiplying two numbers. So in some contexts (like inside a short loop with many repetitions), you might want to avoid using this method. As with most performance issues, you won't really know how big an effect it is unless you measure it. Don't let performance paranoia prevent you from even trying this technique. But be prepared to limit its use if performance turns out to be an issue.