334
335 private static ConstantDesc canonicalizeArrayVarHandle(DynamicConstantDesc<?> desc) {
336 if (desc.bootstrapArgs.length != 1
337 || !desc.constantType().equals(CD_VarHandle))
338 return desc;
339 return VarHandleDesc.ofArray((ClassDesc) desc.bootstrapArgs[0]);
340 }
341
342 // @@@ To eventually support in canonicalization: DCR with BSM=MHR_METHODHANDLEDESC_ASTYPE becomes AsTypeMHDesc
343
344 /**
345 * Compares the specified object with this descriptor for equality. Returns
346 * {@code true} if and only if the specified object is also a
347 * {@linkplain DynamicConstantDesc}, and both descriptors have equal
348 * bootstrap methods, bootstrap argument lists, constant name, and
349 * constant type.
350 *
351 * @param o the {@code DynamicConstantDesc} to compare to this
352 * {@code DynamicConstantDesc}
353 * @return {@code true} if the specified {@code DynamicConstantDesc} is
354 * equals to this {@code DynamicConstantDesc}.
355 *
356 */
357 @Override
358 public final boolean equals(Object o) {
359 if (this == o) return true;
360 if (!(o instanceof DynamicConstantDesc)) return false;
361 DynamicConstantDesc<?> desc = (DynamicConstantDesc<?>) o;
362 return Objects.equals(bootstrapMethod, desc.bootstrapMethod) &&
363 Arrays.equals(bootstrapArgs, desc.bootstrapArgs) &&
364 Objects.equals(constantName, desc.constantName) &&
365 Objects.equals(constantType, desc.constantType);
366 }
367
368 @Override
369 public final int hashCode() {
370 int result = Objects.hash(bootstrapMethod, constantName, constantType);
371 result = 31 * result + Arrays.hashCode(bootstrapArgs);
372 return result;
373 }
374
|
334
335 private static ConstantDesc canonicalizeArrayVarHandle(DynamicConstantDesc<?> desc) {
336 if (desc.bootstrapArgs.length != 1
337 || !desc.constantType().equals(CD_VarHandle))
338 return desc;
339 return VarHandleDesc.ofArray((ClassDesc) desc.bootstrapArgs[0]);
340 }
341
342 // @@@ To eventually support in canonicalization: DCR with BSM=MHR_METHODHANDLEDESC_ASTYPE becomes AsTypeMHDesc
343
344 /**
345 * Compares the specified object with this descriptor for equality. Returns
346 * {@code true} if and only if the specified object is also a
347 * {@linkplain DynamicConstantDesc}, and both descriptors have equal
348 * bootstrap methods, bootstrap argument lists, constant name, and
349 * constant type.
350 *
351 * @param o the {@code DynamicConstantDesc} to compare to this
352 * {@code DynamicConstantDesc}
353 * @return {@code true} if the specified {@code DynamicConstantDesc} is
354 * equal to this {@code DynamicConstantDesc}.
355 *
356 */
357 @Override
358 public final boolean equals(Object o) {
359 if (this == o) return true;
360 if (!(o instanceof DynamicConstantDesc)) return false;
361 DynamicConstantDesc<?> desc = (DynamicConstantDesc<?>) o;
362 return Objects.equals(bootstrapMethod, desc.bootstrapMethod) &&
363 Arrays.equals(bootstrapArgs, desc.bootstrapArgs) &&
364 Objects.equals(constantName, desc.constantName) &&
365 Objects.equals(constantType, desc.constantType);
366 }
367
368 @Override
369 public final int hashCode() {
370 int result = Objects.hash(bootstrapMethod, constantName, constantType);
371 result = 31 * result + Arrays.hashCode(bootstrapArgs);
372 return result;
373 }
374
|