src/java.base/share/classes/java/lang/constant/ClassDesc.java
changeset 54720 c48f141e7c5b
parent 54637 b71940f7fa96
equal deleted inserted replaced
54719:4f2fd02922b1 54720:c48f141e7c5b
   211      *
   211      *
   212      * @param firstNestedName the unqualified name of the first level of nested class
   212      * @param firstNestedName the unqualified name of the first level of nested class
   213      * @param moreNestedNames the unqualified name(s) of the remaining levels of
   213      * @param moreNestedNames the unqualified name(s) of the remaining levels of
   214      *                       nested class
   214      *                       nested class
   215      * @return a {@linkplain ClassDesc} describing the nested class
   215      * @return a {@linkplain ClassDesc} describing the nested class
   216      * @throws NullPointerException if any argument is {@code null}
   216      * @throws NullPointerException if any argument or its contents is {@code null}
   217      * @throws IllegalStateException if this {@linkplain ClassDesc} does not
   217      * @throws IllegalStateException if this {@linkplain ClassDesc} does not
   218      * describe a class or interface type
   218      * describe a class or interface type
   219      * @throws IllegalArgumentException if the nested class name is invalid
   219      * @throws IllegalArgumentException if the nested class name is invalid
   220      */
   220      */
   221     default ClassDesc nested(String firstNestedName, String... moreNestedNames) {
   221     default ClassDesc nested(String firstNestedName, String... moreNestedNames) {
   222         if (!isClassOrInterface())
   222         if (!isClassOrInterface())
   223             throw new IllegalStateException("Outer class is not a class or interface type");
   223             throw new IllegalStateException("Outer class is not a class or interface type");
       
   224         validateMemberName(firstNestedName, false);
       
   225         requireNonNull(moreNestedNames);
       
   226         for (String addNestedNames : moreNestedNames) {
       
   227             validateMemberName(addNestedNames, false);
       
   228         }
   224         return moreNestedNames.length == 0
   229         return moreNestedNames.length == 0
   225                ? nested(firstNestedName)
   230                ? nested(firstNestedName)
   226                : nested(firstNestedName + Stream.of(moreNestedNames).collect(joining("$", "$", "")));
   231                : nested(firstNestedName + Stream.of(moreNestedNames).collect(joining("$", "$", "")));
   227     }
   232     }
   228 
   233