8342466: Improve API documentation for java.lang.classfile.attribute

Reviewed-by: darcy, asotona
This commit is contained in:
Chen Liang 2025-01-15 02:04:01 +00:00
parent 9782bfdd27
commit 973c630777
70 changed files with 2443 additions and 967 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -26,19 +26,21 @@
package java.lang.classfile.attribute;
import java.lang.classfile.Attribute;
import java.lang.classfile.AttributeMapper;
import java.lang.classfile.AttributeMapper.AttributeStability;
import java.lang.classfile.Attributes;
import java.lang.classfile.ClassElement;
import java.lang.classfile.ClassModel;
import jdk.internal.classfile.impl.BoundAttribute;
import jdk.internal.classfile.impl.UnboundAttribute;
/**
* Models the {@code ModuleResolution} attribute, which can
* appear on classes that represent module descriptors. This is a JDK-specific
* * attribute, which captures resolution metadata for modules.
* Delivered as a {@link java.lang.classfile.ClassElement} when
* traversing the elements of a {@link java.lang.classfile.ClassModel}.
*
* <p>The specification of the {@code ModuleResolution} attribute is:
* Models the {@link Attributes#moduleResolution() ModuleResolution} attribute,
* which can appear on classes that {@linkplain ClassModel#isModuleInfo()
* represent} module descriptors, to capture resolution metadata for modules.
* <p>
* The specification of the {@code ModuleResolution} attribute is:
* <pre> {@code
* ModuleResolution_attribute {
* u2 attribute_name_index; // "ModuleResolution"
@ -58,19 +60,29 @@ import jdk.internal.classfile.impl.UnboundAttribute;
* }
* } </pre>
* <p>
* The attribute does not permit multiple instances in a given location.
* Subsequent occurrence of the attribute takes precedence during the attributed
* element build or transformation.
* This attribute only appears on classes, and does not permit {@linkplain
* AttributeMapper#allowMultiple multiple instances} in a class. It has
* {@linkplain AttributeStability#STATELESS no data dependency}.
* <p>
* This attribute is not predefined in the Java SE Platform. This is a
* JDK-specific nonstandard attribute produced by the {@linkplain jdk.jlink/
* jlink and jmod tools} and used by the implementation.
*
* @see Attributes#moduleResolution()
* @see ModuleHashesAttribute
* @see ModuleTargetAttribute
* @since 24
*/
@SuppressWarnings("doclint:reference")
public sealed interface ModuleResolutionAttribute
extends Attribute<ModuleResolutionAttribute>, ClassElement
permits BoundAttribute.BoundModuleResolutionAttribute, UnboundAttribute.UnboundModuleResolutionAttribute {
/**
* The value of the resolution_flags item is a mask of flags used to denote
* properties of module resolution. The flags are as follows:
* {@return the module resolution flags}
* <p>
* The value of the resolution_flags item is a mask of flags used to denote
* properties of module resolution. The flags are as follows:
* <pre> {@code
* // Optional
* 0x0001 (DO_NOT_RESOLVE_BY_DEFAULT)
@ -80,12 +92,12 @@ public sealed interface ModuleResolutionAttribute
* 0x0004 (WARN_DEPRECATED_FOR_REMOVAL)
* 0x0008 (WARN_INCUBATING)
* } </pre>
* @return the module resolution flags
*/
int resolutionFlags();
/**
* {@return a {@code ModuleResolution} attribute}
*
* @param resolutionFlags the resolution flags
*/
static ModuleResolutionAttribute of(int resolutionFlags) {