Movatterモバイル変換


[0]ホーム

URL:


JEP 104: Type Annotations

AuthorsMichael Ernst, Alex Buckley
OwnerMichael Ernst
TypeFeature
ScopeSE
StatusClosed / Delivered
Release8
Componentspecification / language
JSR308
Discussiontype dash annotations dash dev at openjdk dot java dot net
EffortL
DurationXL
BlocksJEP 120: Repeating Annotations
Reviewed byBrian Goetz
Endorsed byBrian Goetz, Mikael Vidstedt
Created2011/09/09 20:00
Updated2020/06/01 17:38
Issue8046094

Summary

Extend the set of annotatable locations in the syntax of the Javaprogramming language to include names which indicate the use of a typeas well as (per Java SE 5.0) the declaration of a type.

Goals

Allow development of useful pluggable type checkers that refine Java'sbuilt-in type system.

Non-Goals

Standardization of pluggable type checkers.

Success Metrics

Motivation

Java's annotation system has been an unquestioned success. Programmerscan write annotations on type names which appear in the declaration ofvariables, methods, and classes, which are then read by enterpriseframeworks for configuration purposes and by compilers/IDEs forsoftware quality purposes. Annotations allow boilerplate to be removedfrom code, and enable basic errors to be detected at compile-time.

Annotations on type uses, not just type declarations, enable errordetection by "pluggable type checkers" which strengthen and refineJava's built-in type system. The strengthened type system prevents, atcompile-time, the kind of software quality errors which wouldotherwise manifest themselves at run time. Examples include nullpointer errors, side effects on immutable data, race conditions,information leakage, and non-internationalized strings.

Description

JSR 308 makes targeted, low-level changes to the grammar of the Javalanguage to allow annotations on the names of types in most placesthose names can be used. This includes the names of types occurring inJava SE 7 language constructs like try-with-resources and multi-catch.

JSR 308 defines new attributes for the JVM class file format to storethese annotations on type names. Finally, it makes targeted changes tothe java.lang.reflect and javax.lang.model API so that annotations onspecific instances of type names can be retrieved.

Alternatives

Testing

Risks and Assumptions

Impact

OpenJDK logo
Installing
Contributing
Sponsoring
Developers' Guide
Vulnerabilities
JDK GA/EA Builds
Mailing lists
Wiki ·IRC
Mastodon
Bluesky
Bylaws ·Census
Legal
Workshop
JEP Process
Source code
GitHub
Mercurial
Tools
Git
jtreg harness
Groups
(overview)
Adoption
Build
Client Libraries
Compatibility & Specification Review
Compiler
Conformance
Core Libraries
Governing Board
HotSpot
IDE Tooling & Support
Internationalization
JMX
Members
Networking
Porters
Quality
Security
Serviceability
Vulnerability
Web
Projects
(overview,archive)
Amber
Babylon
CRaC
Code Tools
Coin
Common VM Interface
Developers' Guide
Device I/O
Duke
Galahad
Graal
IcedTea
JDK 8 Updates
JDK 9
JDK (…,24,25,26)
JDK Updates
JMC
Jigsaw
Kona
Lanai
Leyden
Lilliput
Locale Enhancement
Loom
Memory Model Update
Metropolis
Multi-Language VM
Nashorn
New I/O
OpenJFX
Panama
Penrose
Port: AArch32
Port: AArch64
Port: BSD
Port: Haiku
Port: Mac OS X
Port: MIPS
Port: Mobile
Port: PowerPC/AIX
Port: RISC-V
Port: s390x
SCTP
Shenandoah
Skara
Sumatra
Tsan
Valhalla
Verona
VisualVM
Wakefield
Zero
ZGC
Oracle logo
© 2025 Oracle Corporation and/or its affiliates
Terms of Use · License:GPLv2 ·Privacy ·Trademarks

[8]ページ先頭

©2009-2025 Movatter.jp