---
spec: JVMS
title: "The Java Virtual Machine Specification"
edition: "Java SE 10 Edition"
java_version: 10
chapter: "Chapter 5. Loading, Linking, and Initializing"
section: "5.4.4"
heading: "5.4.4. Access Control"
parent: "5.4. Linking"
source: https://docs.oracle.com/javase/specs/jvms/se10/html/jvms-5.html#jvms-5.4.4
id: "5.4.4"
url: https://jvm.obfuscated.software/jvms/se10/5.4.4.html
raw: https://jvm.obfuscated.software/jvms/se10/5.4.4.md
---

# 5.4.4. Access Control

A class or interface C is *accessible* to a class or interface D if and only if one of the following is true:

- C is `public`, and a member of the same run-time module as D ([§5.3.6](5.3.6.md)).
- C is `public`, and a member of a different run-time module than D, and C's run-time module is read by D's run-time module, and C's run-time module exports C's run-time package to D's run-time module.
- C is not `public`, and C and D are members of the same run-time package.

A field or method R is accessible to a class or interface D if and only if any of the following is true:

- R is `public`.
- R is `protected` and is declared in a class C, and D is either a subclass of C or C itself. Furthermore, if R is not `static`, then the symbolic reference to R must contain a symbolic reference to a class T, such that T is either a subclass of D, a superclass of D, or D itself.
- R is either `protected` or has default access (that is, neither `public` nor `protected` nor `private`), and is declared by a class in the same run-time package as D.
- R is `private` and is declared in D.

This discussion of access control omits a related restriction on the target of a `protected` field access or method invocation (the target must be of class D or a subtype of D). That requirement is checked as part of the verification process ([§4.10.1.8](4.10.1.8.md)); it is not part of link-time access control.
