@Retention(value=RUNTIME) @Target(value=TYPE) public @interface TargetMajorVersion
@TargetMajorVersion specifies which Java major version a type targets.
It is useful for library maintainers managing backwards compatibility.
Retention and effect: Retained at runtime but has no behaviour unless tooling inspects it.
@TargetMajorVersion(11)
class ModernOnly { }
Major version 0 means any version. Common values are 8, 11, 17
and 21.
Class<?> impl = ImplementationPicker.pick(TargetInterface.class);
When multiple classes match, includeOlder and
includeNewer determine precedence.
Java9,
ChronicleFeature| Modifier and Type | Fields and Description |
|---|---|
static int |
ANY_VERSION
Constant to represent compatibility with any version.
|
| Modifier and Type | Optional Element and Description |
|---|---|
boolean |
includeNewer
If set to true, indicates that the annotated type should be compatible
with versions newer than the specified major version.
|
boolean |
includeOlder
If set to true, indicates that the annotated type should be compatible
with versions older than the specified major version.
|
int |
majorVersion
Specifies the major version number that the annotated type targets.
|
public static final int ANY_VERSION
public abstract int majorVersion
Copyright © 2026 Chronicle Software Ltd. All rights reserved.