The Java Tutorials have been written for JDK 8. Examples and practices described in this page don't take advantage of improvements introduced in later releases and might use technology no longer available.
See Java Language Changes for a summary of updated language features in Java SE 9 and subsequent releases.
See JDK Release Notes for information about new features, enhancements, and removed or deprecated options for all JDK releases.
This lesson demonstrates how to write a class that defines its own special permission. The basic components in this lesson include:
ExampleGame
to store a user's latest high score.ExampleGame
to update his/her high score.The basic scenario is as follows:
ExampleGame
.ExampleGame
uses the HighScore
class to save this new value.HighScore
class looks into the user's security policy to check if ExampleGame
has permission to update the user's high score value.ExampleGame
has permission to update the high score, then the HighScore class updates that value.We describe the key points of each of the basic components and then show a sample run: