Challenge: find ways to crash your Java VirtualMachine..!!
?? Saral Saxena ??????
?11K+ Followers | Linkedin Top Voice || Associate Director || 15+ Years in Java, Microservices, Kafka, Spring Boot, Cloud Technologies (AWS, GCP) | Agile , K8s ,DevOps & CI/CD Expert
1. Try to allocate as much memory as you can. RAM is not endless—if no more RAM can be allocated, your allocation will fail.
2. Try to write data to your hard disk until it is full. Same problem as with RAM: though bigger than RAM, disk space is not endless either.
3. Try to open as many files as you can. Do you know the maximum number of file descriptors for your environment?
4. Try to create as many threads as you can. On a Linux system, you can look at /proc/sys/kernel/pid_max and you will see how many processes may be running on your system. How many threads are you allowed to create on your system?
5. Try to modify your own .class files in the filesystem the current run of your application will be its last!
6. Try to find your own process ID, and then try to kill it by using Runtime.exec (e.g., by calling kill -9 on your process ID).
7. Try to create a class at runtime that only calls System.exit, load that class dynamically via the class loader, then call it.
8. Try to open as many socket connections as possible. On a Unix system, the maximum number of possible socket connections equals the maximum number of file descriptors (often 2,048). How many are available where your application is running?
9. Try to hack your system. Download an exploit via code or by using wget. Execute the exploit, and then call shutdown -h as root on a Unix system or shutdown /s as administrator on a Windows system.
10. Try jumping without a safety net. Part of Java’s safety comes from its language design and part from the bytecode verification in your JVM. Run your JVM with -noverify or -Xverify:none, which disables all bytecode verification, and write something that would otherwise not be allowed to run.
11. Try using Unsafe. This backdoor class is used to get access to low-level facilities such as memory management. All the syntax of Java, all the safety of C!
12. Try going native. Write some native code. All the syntax of C, all the safety of C!