How do you crash a JVM?

前端 未结 27 1473
故里飘歌
故里飘歌 2020-11-28 00:22

I was reading a book on programming skills wherein the author asks the interviewee, \"How do you crash a JVM?\" I thought that you could do so by writing an infinite for-loo

27条回答
  •  悲&欢浪女
    2020-11-28 01:17

    A perfect JVM implementation will never crash.

    To crash a JVM, aside from JNI, you need to find a bug in the VM itself. An infinite loop just consumes CPU. Infinitely allocating memory should just cause OutOfMemoryError's in a well built JVM. This would probably cause problems for other threads, but a good JVM still should not crash.

    If you can find a bug in the source code of the VM, and for example cause a segmentation fault in the memory usage of the implementation of the VM, then you can actually crash it.

提交回复
热议问题