< prev index next >

src/java.base/share/classes/java/lang/invoke/VarHandle.java

Print this page
rev 53560 : 8218022: Repeated words typos in java.base
Reviewed-by: alanb, lancea
Contributed-by: Andrey Turbanov <turbanoff@gmail.com>


2143                 switch (this) {
2144                     case FIELD:
2145                     case STATIC_FIELD:
2146                         return new ConstantDesc[] {declaringClass, varType };
2147                     case ARRAY:
2148                         return new ConstantDesc[] {declaringClass };
2149                     default:
2150                         throw new InternalError("Cannot reach here");
2151                 }
2152             }
2153         }
2154 
2155         private final Kind kind;
2156         private final ClassDesc declaringClass;
2157         private final ClassDesc varType;
2158 
2159         /**
2160          * Construct a {@linkplain VarHandleDesc} given a kind, name, and declaring
2161          * class.
2162          *
2163          * @param kind the kind of of the var handle
2164          * @param name the unqualified name of the field, for field var handles; otherwise ignored
2165          * @param declaringClass a {@link ClassDesc} describing the declaring class,
2166          *                       for field var handles
2167          * @param varType a {@link ClassDesc} describing the type of the variable
2168          * @throws NullPointerException if any required argument is null
2169          * @jvms 4.2.2 Unqualified Names
2170          */
2171         private VarHandleDesc(Kind kind, String name, ClassDesc declaringClass, ClassDesc varType) {
2172             super(kind.bootstrapMethod, name,
2173                   ConstantDescs.CD_VarHandle,
2174                   kind.toBSMArgs(declaringClass, varType));
2175             this.kind = kind;
2176             this.declaringClass = declaringClass;
2177             this.varType = varType;
2178         }
2179 
2180         /**
2181          * Returns a {@linkplain VarHandleDesc} corresponding to a {@link VarHandle}
2182          * for an instance field.
2183          *


2200          * Returns a {@linkplain VarHandleDesc} corresponding to a {@link VarHandle}
2201          * for a static field.
2202          *
2203          * @param name the unqualified name of the field
2204          * @param declaringClass a {@link ClassDesc} describing the declaring class,
2205          *                       for field var handles
2206          * @param fieldType a {@link ClassDesc} describing the type of the field
2207          * @return the {@linkplain VarHandleDesc}
2208          * @throws NullPointerException if any of the arguments are null
2209          * @jvms 4.2.2 Unqualified Names
2210          */
2211         public static VarHandleDesc ofStaticField(ClassDesc declaringClass, String name, ClassDesc fieldType) {
2212             Objects.requireNonNull(declaringClass);
2213             Objects.requireNonNull(name);
2214             Objects.requireNonNull(fieldType);
2215             return new VarHandleDesc(Kind.STATIC_FIELD, name, declaringClass, fieldType);
2216         }
2217 
2218         /**
2219          * Returns a {@linkplain VarHandleDesc} corresponding to a {@link VarHandle}
2220          * for for an array type.
2221          *
2222          * @param arrayClass a {@link ClassDesc} describing the type of the array
2223          * @return the {@linkplain VarHandleDesc}
2224          * @throws NullPointerException if any of the arguments are null
2225          */
2226         public static VarHandleDesc ofArray(ClassDesc arrayClass) {
2227             Objects.requireNonNull(arrayClass);
2228             if (!arrayClass.isArray())
2229                 throw new IllegalArgumentException("Array class argument not an array: " + arrayClass);
2230             return new VarHandleDesc(Kind.ARRAY, ConstantDescs.DEFAULT_NAME, arrayClass, arrayClass.componentType());
2231         }
2232 
2233         /**
2234          * Returns a {@link ClassDesc} describing the type of the variable described
2235          * by this descriptor.
2236          *
2237          * @return the variable type
2238          */
2239         public ClassDesc varType() {
2240             return varType;




2143                 switch (this) {
2144                     case FIELD:
2145                     case STATIC_FIELD:
2146                         return new ConstantDesc[] {declaringClass, varType };
2147                     case ARRAY:
2148                         return new ConstantDesc[] {declaringClass };
2149                     default:
2150                         throw new InternalError("Cannot reach here");
2151                 }
2152             }
2153         }
2154 
2155         private final Kind kind;
2156         private final ClassDesc declaringClass;
2157         private final ClassDesc varType;
2158 
2159         /**
2160          * Construct a {@linkplain VarHandleDesc} given a kind, name, and declaring
2161          * class.
2162          *
2163          * @param kind the kind of the var handle
2164          * @param name the unqualified name of the field, for field var handles; otherwise ignored
2165          * @param declaringClass a {@link ClassDesc} describing the declaring class,
2166          *                       for field var handles
2167          * @param varType a {@link ClassDesc} describing the type of the variable
2168          * @throws NullPointerException if any required argument is null
2169          * @jvms 4.2.2 Unqualified Names
2170          */
2171         private VarHandleDesc(Kind kind, String name, ClassDesc declaringClass, ClassDesc varType) {
2172             super(kind.bootstrapMethod, name,
2173                   ConstantDescs.CD_VarHandle,
2174                   kind.toBSMArgs(declaringClass, varType));
2175             this.kind = kind;
2176             this.declaringClass = declaringClass;
2177             this.varType = varType;
2178         }
2179 
2180         /**
2181          * Returns a {@linkplain VarHandleDesc} corresponding to a {@link VarHandle}
2182          * for an instance field.
2183          *


2200          * Returns a {@linkplain VarHandleDesc} corresponding to a {@link VarHandle}
2201          * for a static field.
2202          *
2203          * @param name the unqualified name of the field
2204          * @param declaringClass a {@link ClassDesc} describing the declaring class,
2205          *                       for field var handles
2206          * @param fieldType a {@link ClassDesc} describing the type of the field
2207          * @return the {@linkplain VarHandleDesc}
2208          * @throws NullPointerException if any of the arguments are null
2209          * @jvms 4.2.2 Unqualified Names
2210          */
2211         public static VarHandleDesc ofStaticField(ClassDesc declaringClass, String name, ClassDesc fieldType) {
2212             Objects.requireNonNull(declaringClass);
2213             Objects.requireNonNull(name);
2214             Objects.requireNonNull(fieldType);
2215             return new VarHandleDesc(Kind.STATIC_FIELD, name, declaringClass, fieldType);
2216         }
2217 
2218         /**
2219          * Returns a {@linkplain VarHandleDesc} corresponding to a {@link VarHandle}
2220          * for an array type.
2221          *
2222          * @param arrayClass a {@link ClassDesc} describing the type of the array
2223          * @return the {@linkplain VarHandleDesc}
2224          * @throws NullPointerException if any of the arguments are null
2225          */
2226         public static VarHandleDesc ofArray(ClassDesc arrayClass) {
2227             Objects.requireNonNull(arrayClass);
2228             if (!arrayClass.isArray())
2229                 throw new IllegalArgumentException("Array class argument not an array: " + arrayClass);
2230             return new VarHandleDesc(Kind.ARRAY, ConstantDescs.DEFAULT_NAME, arrayClass, arrayClass.componentType());
2231         }
2232 
2233         /**
2234          * Returns a {@link ClassDesc} describing the type of the variable described
2235          * by this descriptor.
2236          *
2237          * @return the variable type
2238          */
2239         public ClassDesc varType() {
2240             return varType;


< prev index next >