Find a String version of a GroovyConsole Script in a Heap Dump
I've accidentally ran a script with an infinite loop in GroovyConsole. :-\
For the sake of Murphy's L开发者_如何学Goaw, I haven't save my work during 3 or 4 hours. So, before killing the GroovyConsole Process, I've dumped the heap, with the hope to find a String version of the Script that was running at this moment
Do you have a hint in which Class it can hide, or if it is possible ?
So, it happens that my guess was right. The groovy.ui.Console
Object keeps an history of changes of the script. I give you the OQL query that gave me my script back for my greatest pleasure. I ran it in VisualVM with the OQL plugin, but I could have used jhat :
select x.history.elementData[x.history.elementData.length-2].allText.toString() from groovy.ui.Console x
Despaired groovy developers who've lost their code once might be releaved now :-) For sure I am
The string version of the script may exists in another object. I'd love to hear other solutions
精彩评论