< prev index next >

src/java.base/share/classes/java/lang/constant/DynamicConstantDesc.java

Print this page

        

*** 31,43 **** --- 31,46 ---- import java.lang.invoke.VarHandle.VarHandleDesc; import java.util.Arrays; import java.util.List; import java.util.Map; import java.util.Objects; + import java.util.Optional; import java.util.function.Function; import java.util.stream.Stream; + import jdk.internal.lang.annotation.Foldable; + import static java.lang.constant.ConstantDescs.CD_Class; import static java.lang.constant.ConstantDescs.CD_VarHandle; import static java.lang.constant.ConstantDescs.DEFAULT_NAME; import static java.lang.constant.ConstantUtils.EMPTY_CONSTANTDESC; import static java.lang.constant.ConstantUtils.validateMemberName;
*** 55,65 **** * @param <T> the type of the dynamic constant * * @since 12 */ public abstract class DynamicConstantDesc<T> ! implements ConstantDesc { private final DirectMethodHandleDesc bootstrapMethod; private final ConstantDesc[] bootstrapArgs; private final String constantName; private final ClassDesc constantType; --- 58,68 ---- * @param <T> the type of the dynamic constant * * @since 12 */ public abstract class DynamicConstantDesc<T> ! implements ConstantDesc, Constable { private final DirectMethodHandleDesc bootstrapMethod; private final ConstantDesc[] bootstrapArgs; private final String constantName; private final ClassDesc constantType;
*** 135,144 **** --- 138,148 ---- * @throws NullPointerException if any argument is null * @throws IllegalArgumentException if the {@code name} has the incorrect * format * @jvms 4.2.2 Unqualified Names */ + @Foldable public static<T> ConstantDesc ofCanonical(DirectMethodHandleDesc bootstrapMethod, String constantName, ClassDesc constantType, ConstantDesc[] bootstrapArgs) { return DynamicConstantDesc.<T>ofNamed(bootstrapMethod, constantName, constantType, bootstrapArgs)
*** 163,173 **** * @throws NullPointerException if any argument is null * @throws IllegalArgumentException if the {@code name} has the incorrect * format * @jvms 4.2.2 Unqualified Names */ ! public static<T> DynamicConstantDesc<T> ofNamed(DirectMethodHandleDesc bootstrapMethod, String constantName, ClassDesc constantType, ConstantDesc... bootstrapArgs) { return new AnonymousDynamicConstantDesc<>(bootstrapMethod, constantName, constantType, bootstrapArgs); --- 167,177 ---- * @throws NullPointerException if any argument is null * @throws IllegalArgumentException if the {@code name} has the incorrect * format * @jvms 4.2.2 Unqualified Names */ ! @Foldable public static<T> DynamicConstantDesc<T> ofNamed(DirectMethodHandleDesc bootstrapMethod, String constantName, ClassDesc constantType, ConstantDesc... bootstrapArgs) { return new AnonymousDynamicConstantDesc<>(bootstrapMethod, constantName, constantType, bootstrapArgs);
*** 186,195 **** --- 190,200 ---- * {@code BootstrapMethods} attribute * @return the nominal descriptor * @throws NullPointerException if any argument is null * @jvms 4.2.2 Unqualified Names */ + @Foldable public static<T> DynamicConstantDesc<T> of(DirectMethodHandleDesc bootstrapMethod, ConstantDesc... bootstrapArgs) { return ofNamed(bootstrapMethod, DEFAULT_NAME, bootstrapMethod.invocationType().returnType(), bootstrapArgs); }
*** 202,241 **** --- 207,250 ---- * @param bootstrapMethod a {@link DirectMethodHandleDesc} describing the * bootstrap method for the constant * @return the nominal descriptor * @throws NullPointerException if any argument is null */ + @Foldable public static<T> DynamicConstantDesc<T> of(DirectMethodHandleDesc bootstrapMethod) { return of(bootstrapMethod, EMPTY_CONSTANTDESC); } /** * Returns the name that would appear in the {@code NameAndType} operand * of the {@code LDC} for this constant. * * @return the constant name */ + @Foldable public String constantName() { return constantName; } /** * Returns a {@link ClassDesc} describing the type that would appear in the * {@code NameAndType} operand of the {@code LDC} for this constant. * * @return the constant type */ + @Foldable public ClassDesc constantType() { return constantType; } /** * Returns a {@link MethodHandleDesc} describing the bootstrap method for * this constant. * * @return the bootstrap method */ + @Foldable public DirectMethodHandleDesc bootstrapMethod() { return bootstrapMethod; } /**
*** 391,397 **** --- 400,411 ---- private static class AnonymousDynamicConstantDesc<T> extends DynamicConstantDesc<T> { AnonymousDynamicConstantDesc(DirectMethodHandleDesc bootstrapMethod, String constantName, ClassDesc constantType, ConstantDesc... bootstrapArgs) { super(bootstrapMethod, constantName, constantType, bootstrapArgs); } + + @Override + public Optional<? extends ConstantDesc> describeConstable() { + return Optional.empty(); + } } }
< prev index next >