Cache access

A Java™ virtual machine can access a shared class cache with either read/write or read-only access. Read/write access is the default and gives all users equal rights to update the cache. Use the -Xshareclasses:readonly option for read-only access.

Opening a cache as read-only makes it easier to administer operating system permissions. Users can reduce startup time by opening the cache as read-only, which avoids any contention that might be experienced when users access the cache in read/write mode. Opening a cache as read-only also prevents corruption of the cache. This option can be useful on production systems where one instance of an application corrupting the cache might affect the performance of all other instances.

To enable read-only access of persistent caches by users outside the group of the cache creator, you must specify a directory with appropriate permissions when you create the cache. Specify this directory by using the -Xshareclasses:cacheDir option. If you do not use the -Xshareclasses:cacheDir option, the cache is created with default permissions. The default permissions deny access for users that are not in the same group as the cache creator. For more information, see Class data sharing command-line options.

When a cache is opened read-only, class files of the application that are modified or moved cannot be updated in the cache. Sharing is disabled for the modified or moved containers for that JVM.