forked from natanfudge/Not-Enough-Crashes
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
845869b
commit 41f05d7
Showing
13 changed files
with
103 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
common/src/main/java/fudge/notenoughcrashes/utils/SystemExitBlock.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package fudge.notenoughcrashes.utils; | ||
|
||
import java.security.Permission; | ||
|
||
public class SystemExitBlock { | ||
|
||
public static void forbidSystemExitCall() { | ||
final SecurityManager securityManager = new SecurityManager() { | ||
public void checkPermission( Permission permission ) { | ||
if( permission.getName().startsWith("exitVM") ) { | ||
throw new SystemExitBlockedException("An attempt was made to forcefully close the game with no stack trace (see stack trace)." + | ||
" Not Enough Crashes made the game simply crash instead since the forceCrashScreen option is enabled.") ; | ||
} | ||
} | ||
} ; | ||
System.setSecurityManager( securityManager ) ; | ||
} | ||
|
||
private static void enableSystemExitCall() { | ||
System.setSecurityManager( null ) ; | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
common/src/main/java/fudge/notenoughcrashes/utils/SystemExitBlockedException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package fudge.notenoughcrashes.utils; | ||
|
||
class SystemExitBlockedException extends SecurityException { | ||
public SystemExitBlockedException(String s) { | ||
super(s); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters