---
spec: JVMS
title: "The Java Virtual Machine Specification"
edition: "Java SE 12 Edition"
java_version: 12
chapter: "Chapter 3. Compiling for the Java Virtual Machine"
section: "3.15"
heading: "3.15. Annotations"
parent: "Chapter 3. Compiling for the Java Virtual Machine"
source: https://docs.oracle.com/javase/specs/jvms/se12/html/jvms-3.html#jvms-3.15
id: "3.15"
url: https://jvm.obfuscated.software/jvms/se12/3.15.html
raw: https://jvm.obfuscated.software/jvms/se12/3.15.md
---

# 3.15. Annotations

The representation of annotations in `class` files is described in [§4.7.16](4.7.16.md)-[§4.7.22](4.7.22.md). These sections make it clear how to represent annotations on declarations of classes, interfaces, fields, methods, method parameters, and type parameters, as well as annotations on types used in those declarations. Annotations on package declarations require additional rules, given here.

When the compiler encounters an annotated package declaration that must be made available at run time, it emits a `class` file with the following properties:

- The `class` file represents an interface, that is, the `ACC_INTERFACE` and `ACC_ABSTRACT` flags of the `ClassFile` structure are set ([§4.1](4.1.md)).
- If the `class` file version number is less than 50.0, then the `ACC_SYNTHETIC` flag is unset; if the `class` file version number is 50.0 or above, then the `ACC_SYNTHETIC` flag is set.
- The interface has package access (JLS §6.6.1).
- The interface's name is the internal form ([§4.2.1](4.2.1.md)) of `package-name.package-info`.
- The interface has no superinterfaces.
- The interface's only members are those implied by *The Java Language Specification, Java SE 12 Edition* (JLS §9.2).
- The annotations on the package declaration are stored as `RuntimeVisibleAnnotations` and `RuntimeInvisibleAnnotations` attributes in the `attributes` table of the `ClassFile` structure.
