JavaModelingLanguage / RefMan

4 stars 0 forks source link

Annotation on Package- and Module-Level #60

Open wadoon opened 6 months ago

wadoon commented 6 months ago

Background

I just looked into Appendix A of the current draft and recognize, that modifiers are only considered for classes, interfaces, methods, fields and variables.

Starting with Java 5, the package-info.java was introduced, which supersedes the package.html documentation and also allows to set information for the package. For example, JSpecif allows the user to specify the nullness semantics for a complete package.

@NullMarked
package com.ace;

import org.jspecify.NullMarked;

This is also valid for the module-info.java.

Proposal

We should allow some JML modifiers on the package and module. The semantics are their inheritance on all classes in the module or package. This means nearly every class-level modifier is also valid for packages.