java - Is invocation of exception.fillInStacktrace useful? -


i found explicit invocation of e.fillinstacktrace() directly after creation of exception exception e = new exception().

i think redundant, because constructor of throwable invoke fillinstacktrace().

but maybe overlooked , lines useful:

exception e = new exception(); e.fillinstacktrace(); creationinfo = new creationinfo(e.getstacktrace()); 

(public creationinfo(stacktraceelement[] astacktrace){...})

i think

  1. the additional invocation of e.fillinstacktrace(); directly after creation exception redundant , wast lot of resource, because method expensive.

  2. it seams construct needed obtain current stacktrace, therefore:

    creationinfo = thread.currentthread().getstacktrace(); 

    is better way.

before filling issue report want ask if have overlooked something?

you correct on both counts: biggest reason why fillinstacktrace available let override in own exceptions you'd save costs of providing stack trace information, or need hide information location exception may have been thrown. see this answer more details.


Comments

Popular posts from this blog

android - Why am I getting the message 'Youractivity.java is not an activity subclass or alias' -

python - How do I create a list index that loops through integers in another list -

c# - “System.Security.Cryptography.CryptographicException: Keyset does not exist” when reading private key from remote machine -