< prev index next >

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

Print this page
*** 55,19 ***
   */
  public sealed interface ClassDesc
          extends ConstantDesc,
                  TypeDescriptor.OfField<ClassDesc>
          permits PrimitiveClassDescImpl,
!                 ReferenceClassDescImpl {
  
      /**
       * Returns a {@linkplain ClassDesc} for a class or interface type,
       * given the name of the class or interface, such as {@code "java.lang.String"}.
       * (To create a descriptor for an array type, either use {@link #ofDescriptor(String)}
       * or {@link #arrayType()}; to create a descriptor for a primitive type, use
       * {@link #ofDescriptor(String)} or use the predefined constants in
!      * {@link ConstantDescs}).
       *
       * @param name the fully qualified (dot-separated) binary class name
       * @return a {@linkplain ClassDesc} describing the desired class
       * @throws NullPointerException if the argument is {@code null}
       * @throws IllegalArgumentException if the name string is not in the
--- 55,20 ---
   */
  public sealed interface ClassDesc
          extends ConstantDesc,
                  TypeDescriptor.OfField<ClassDesc>
          permits PrimitiveClassDescImpl,
!                 ClassDescImpl {
  
      /**
       * Returns a {@linkplain ClassDesc} for a class or interface type,
       * given the name of the class or interface, such as {@code "java.lang.String"}.
       * (To create a descriptor for an array type, either use {@link #ofDescriptor(String)}
       * or {@link #arrayType()}; to create a descriptor for a primitive type, use
       * {@link #ofDescriptor(String)} or use the predefined constants in
!      * {@link ConstantDescs}; to create a descriptor for a primitive value type,
+      * use {@link #ofDescriptor(String)}).
       *
       * @param name the fully qualified (dot-separated) binary class name
       * @return a {@linkplain ClassDesc} describing the desired class
       * @throws NullPointerException if the argument is {@code null}
       * @throws IllegalArgumentException if the name string is not in the

*** 108,16 ***
       *
       * @apiNote
       *
       * A field type descriptor string for a non-array type is either
       * a one-letter code corresponding to a primitive type
!      * ({@code "J", "I", "C", "S", "B", "D", "F", "Z", "V"}), or the letter {@code "L"}, followed
       * by the fully qualified binary name of a class, followed by {@code ";"}.
       * A field type descriptor for an array type is the character {@code "["}
       * followed by the field descriptor for the component type.  Examples of
!      * valid type descriptor strings include {@code "Ljava/lang/String;"}, {@code "I"},
!      * {@code "[I"}, {@code "V"}, {@code "[Ljava/lang/String;"}, etc.
       * See JVMS 4.3.2 ("Field Descriptors") for more detail.
       *
       * @param descriptor a field descriptor string
       * @return a {@linkplain ClassDesc} describing the desired class
       * @throws NullPointerException if the argument is {@code null}
--- 109,18 ---
       *
       * @apiNote
       *
       * A field type descriptor string for a non-array type is either
       * a one-letter code corresponding to a primitive type
!      * ({@code "J", "I", "C", "S", "B", "D", "F", "Z", "V"}),
+      * or the letter {@code "L"} or {@code "Q"} followed
       * by the fully qualified binary name of a class, followed by {@code ";"}.
       * A field type descriptor for an array type is the character {@code "["}
       * followed by the field descriptor for the component type.  Examples of
!      * valid type descriptor strings include {@code "Ljava/lang/String;"},
!      * {@code "QPoint;}, {@code "I"}, {@code "[I"}, {@code "V"},
+      * {@code "[Ljava/lang/String;"}, {@code "[LPoint;"}, {@code "[[QPoint;} etc.
       * See JVMS 4.3.2 ("Field Descriptors") for more detail.
       *
       * @param descriptor a field descriptor string
       * @return a {@linkplain ClassDesc} describing the desired class
       * @throws NullPointerException if the argument is {@code null}

*** 138,11 ***
                      "Cannot create an array type descriptor with more than " +
                      ConstantUtils.MAX_ARRAY_TYPE_DESC_DIMENSIONS + " dimensions");
          }
          return (descriptor.length() == 1)
                 ? new PrimitiveClassDescImpl(descriptor)
!                : new ReferenceClassDescImpl(descriptor);
      }
  
      /**
       * Returns a {@linkplain ClassDesc} for an array type whose component type
       * is described by this {@linkplain ClassDesc}.
--- 141,11 ---
                      "Cannot create an array type descriptor with more than " +
                      ConstantUtils.MAX_ARRAY_TYPE_DESC_DIMENSIONS + " dimensions");
          }
          return (descriptor.length() == 1)
                 ? new PrimitiveClassDescImpl(descriptor)
!                : new ClassDescImpl(descriptor);
      }
  
      /**
       * Returns a {@linkplain ClassDesc} for an array type whose component type
       * is described by this {@linkplain ClassDesc}.

*** 250,11 ***
       * Returns whether this {@linkplain ClassDesc} describes a class or interface type.
       *
       * @return whether this {@linkplain ClassDesc} describes a class or interface type
       */
      default boolean isClassOrInterface() {
!         return descriptorString().startsWith("L");
      }
  
      /**
       * Returns the component type of this {@linkplain ClassDesc}, if it describes
       * an array type, or {@code null} otherwise.
--- 253,22 ---
       * Returns whether this {@linkplain ClassDesc} describes a class or interface type.
       *
       * @return whether this {@linkplain ClassDesc} describes a class or interface type
       */
      default boolean isClassOrInterface() {
!         return descriptorString().startsWith("L") || descriptorString().startsWith("Q");
+     }
+ 
+     /**
+      * Returns whether this {@linkplain ClassDesc} describes a
+      * {@linkplain Class#isValueType() primitive value type}.
+      *
+      * @return whether this {@linkplain ClassDesc} describes a primitive value type.
+      * @since Valhalla
+      */
+     default boolean isValueType() {
+         return descriptorString().startsWith("Q");
      }
  
      /**
       * Returns the component type of this {@linkplain ClassDesc}, if it describes
       * an array type, or {@code null} otherwise.
< prev index next >