200 * 201 * @return an {@link AssumptionResult} containing the leaf concrete subclass for this type as 202 * described above 203 */ 204 AssumptionResult<ResolvedJavaType> findLeafConcreteSubtype(); 205 206 ResolvedJavaType getComponentType(); 207 208 default ResolvedJavaType getElementalType() { 209 ResolvedJavaType t = this; 210 while (t.isArray()) { 211 t = t.getComponentType(); 212 } 213 return t; 214 } 215 216 ResolvedJavaType getArrayClass(); 217 218 /** 219 * Resolves the method implementation for virtual dispatches on objects of this dynamic type. 220 * This resolution process only searches "up" the class hierarchy of this type. 221 * 222 * @param method the method to select the implementation of 223 * @param callerType the caller or context type used to perform access checks 224 * @return the link-time resolved method (might be abstract) or {@code null} if it can not be 225 * linked 226 */ 227 ResolvedJavaMethod resolveMethod(ResolvedJavaMethod method, ResolvedJavaType callerType); 228 229 /** 230 * Resolves the method implementation for virtual dispatches on objects of this dynamic type. 231 * This resolution process only searches "up" the class hierarchy of this type. A broader search 232 * that also walks "down" the hierarchy is implemented by 233 * {@link #findUniqueConcreteMethod(ResolvedJavaMethod)}. 234 * 235 * @param method the method to select the implementation of 236 * @param callerType the caller or context type used to perform access checks 237 * @return the concrete method that would be selected at runtime, or {@code null} if there is no 238 * concrete implementation of {@code method} in this type or any of its superclasses 239 */ 240 ResolvedJavaMethod resolveConcreteMethod(ResolvedJavaMethod method, ResolvedJavaType callerType); 241 242 /** 243 * Given a {@link ResolvedJavaMethod} A, returns a concrete {@link ResolvedJavaMethod} B that is 244 * the only possible unique target for a virtual call on A(). Returns {@code null} if either no 245 * such concrete method or more than one such method exists. Returns the method A if A is a 246 * concrete method that is not overridden. 247 * <p> 248 * If the compiler uses the result of this method for its compilation, it must register an 249 * assumption because dynamic class loading can invalidate the result of this method. 250 * 251 * @param method the method A for which a unique concrete target is searched 252 * @return the unique concrete target or {@code null} if no such target exists or assumptions 253 * are not supported by this runtime 254 */ 255 AssumptionResult<ResolvedJavaMethod> findUniqueConcreteMethod(ResolvedJavaMethod method); 256 257 /** 258 * Returns the instance fields of this class, including 259 * {@linkplain ResolvedJavaField#isInternal() internal} fields. A zero-length array is returned 260 * for array and primitive types. The order of fields returned by this method is stable. That | 200 * 201 * @return an {@link AssumptionResult} containing the leaf concrete subclass for this type as 202 * described above 203 */ 204 AssumptionResult<ResolvedJavaType> findLeafConcreteSubtype(); 205 206 ResolvedJavaType getComponentType(); 207 208 default ResolvedJavaType getElementalType() { 209 ResolvedJavaType t = this; 210 while (t.isArray()) { 211 t = t.getComponentType(); 212 } 213 return t; 214 } 215 216 ResolvedJavaType getArrayClass(); 217 218 /** 219 * Resolves the method implementation for virtual dispatches on objects of this dynamic type. 220 * This resolution process only searches "up" the class hierarchy of this type. A broader search 221 * that also walks "down" the hierarchy is implemented by 222 * {@link #findUniqueConcreteMethod(ResolvedJavaMethod)}. For interface types it returns null 223 * since no concrete object can be an interface. 224 * 225 * @param method the method to select the implementation of 226 * @param callerType the caller or context type used to perform access checks 227 * @return the method that would be selected at runtime (might be abstract) or {@code null} if 228 * it can not be resolved 229 */ 230 ResolvedJavaMethod resolveMethod(ResolvedJavaMethod method, ResolvedJavaType callerType); 231 232 /** 233 * A convenience wrapper for {@link #resolveMethod(ResolvedJavaMethod, ResolvedJavaType)} that 234 * only returns non-abstract methods. 235 * 236 * @param method the method to select the implementation of 237 * @param callerType the caller or context type used to perform access checks 238 * @return the concrete method that would be selected at runtime, or {@code null} if there is no 239 * concrete implementation of {@code method} in this type or any of its superclasses 240 */ 241 default ResolvedJavaMethod resolveConcreteMethod(ResolvedJavaMethod method, ResolvedJavaType callerType) { 242 ResolvedJavaMethod resolvedMethod = resolveMethod(method, callerType); 243 if (resolvedMethod == null || resolvedMethod.isAbstract()) { 244 return null; 245 } 246 return resolvedMethod; 247 } 248 249 /** 250 * Given a {@link ResolvedJavaMethod} A, returns a concrete {@link ResolvedJavaMethod} B that is 251 * the only possible unique target for a virtual call on A(). Returns {@code null} if either no 252 * such concrete method or more than one such method exists. Returns the method A if A is a 253 * concrete method that is not overridden. 254 * <p> 255 * If the compiler uses the result of this method for its compilation, it must register an 256 * assumption because dynamic class loading can invalidate the result of this method. 257 * 258 * @param method the method A for which a unique concrete target is searched 259 * @return the unique concrete target or {@code null} if no such target exists or assumptions 260 * are not supported by this runtime 261 */ 262 AssumptionResult<ResolvedJavaMethod> findUniqueConcreteMethod(ResolvedJavaMethod method); 263 264 /** 265 * Returns the instance fields of this class, including 266 * {@linkplain ResolvedJavaField#isInternal() internal} fields. A zero-length array is returned 267 * for array and primitive types. The order of fields returned by this method is stable. That |