< prev index next >

src/java.base/share/classes/java/lang/String.java

Print this page
rev 52865 : [mq]: 8210031

*** 26,42 **** --- 26,46 ---- package java.lang; import java.io.ObjectStreamField; import java.io.UnsupportedEncodingException; import java.lang.annotation.Native; + import java.lang.invoke.MethodHandles; + import java.lang.constant.Constable; + import java.lang.constant.ConstantDesc; import java.nio.charset.Charset; import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.Formatter; import java.util.Locale; import java.util.Objects; + import java.util.Optional; import java.util.Spliterator; import java.util.StringJoiner; import java.util.function.Function; import java.util.regex.Matcher; import java.util.regex.Pattern;
*** 125,135 **** * @since 1.0 * @jls 15.18.1 String Concatenation Operator + */ public final class String ! implements java.io.Serializable, Comparable<String>, CharSequence { /** * The value is used for character storage. * * @implNote This field is trusted by the VM, and is a subject to --- 129,140 ---- * @since 1.0 * @jls 15.18.1 String Concatenation Operator + */ public final class String ! implements java.io.Serializable, Comparable<String>, CharSequence, ! ConstantDesc, Constable { /** * The value is used for character storage. * * @implNote This field is trusted by the VM, and is a subject to
*** 3536,3541 **** --- 3541,3572 ---- } throw new IllegalArgumentException( format("Not a valid Unicode code point: 0x%X", codePoint)); } + + /** + * Returns a nominal descriptor for this instance, which is the instance + * itself. + * + * @return an {@link Optional} describing the {@linkplain String} instance + * @since 12 + */ + @Override + public Optional<String> describeConstable() { + return Optional.of(this); + } + + /** + * Resolves this instance as a {@link ConstantDesc}, the result of which is + * the instance itself. + * + * @param lookup ignored + * @return the {@linkplain String} instance + * @since 12 + */ + @Override + public String resolveConstantDesc(MethodHandles.Lookup lookup) { + return this; + } + }
< prev index next >