JDK-6808920 : Defer instantiation of Permission objects unless SecurityManager is used
  • Type: Enhancement
  • Component: core-libs
  • Affected Version: 7
  • Priority: P4
  • Status: Closed
  • Resolution: Won't Fix
  • OS: generic
  • CPU: generic
  • Submitted: 2009-02-23
  • Updated: 2024-04-12
  • Resolved: 2013-10-24
Related Reports
Relates :  
Description
Permission check is only needed when there is a security manager.
We can delay instantiating the Permission object for performing permission check until there is a security manager.

The following are few examples.

src/share/classes/java/util/logging/LogManager.java
src/share/classes/java/util/prefs/Preferences.java
src/solaris/classes/sun/net/www/protocol/jar/JarFileFactory.java
src/windows/classes/sun/net/www/protocol/jar/JarFileFactory.java
When a ProtectionDomain is being created, the permission collection will be set up even though no permission check will need to be performed if no security manager is installed.

Initializing the permission collection can be deferred until permission check is needed.

Comments
The performance gain of a couple classes fewer loaded in startup doesn't justify the change.
24-10-2013

EVALUATION Lazily initialize the static variable storing the permission object for permission check.
23-02-2009