81 public boolean canRecordTo(Assumptions target) {
82 /*
83 * We can use the result if it is either assumption free, or if we have a valid
84 * Assumptions object where we can record assumptions.
85 */
86 return assumptions.length == 0 || target != null;
87 }
88
89 public void recordTo(Assumptions target) {
90 assert canRecordTo(target);
91
92 if (assumptions.length > 0) {
93 for (Assumption assumption : assumptions) {
94 target.record(assumption);
95 }
96 }
97 }
98 }
99
100 /**
101 * An assumption that a given class has no subclasses implementing {@code Object#finalize()}).
102 */
103 public static final class NoFinalizableSubclass extends Assumption {
104
105 private ResolvedJavaType receiverType;
106
107 public NoFinalizableSubclass(ResolvedJavaType receiverType) {
108 this.receiverType = receiverType;
109 }
110
111 @Override
112 public int hashCode() {
113 return 31 + receiverType.hashCode();
114 }
115
116 @Override
117 public boolean equals(Object obj) {
118 if (obj instanceof NoFinalizableSubclass) {
119 NoFinalizableSubclass other = (NoFinalizableSubclass) obj;
120 return other.receiverType.equals(receiverType);
121 }
|
81 public boolean canRecordTo(Assumptions target) {
82 /*
83 * We can use the result if it is either assumption free, or if we have a valid
84 * Assumptions object where we can record assumptions.
85 */
86 return assumptions.length == 0 || target != null;
87 }
88
89 public void recordTo(Assumptions target) {
90 assert canRecordTo(target);
91
92 if (assumptions.length > 0) {
93 for (Assumption assumption : assumptions) {
94 target.record(assumption);
95 }
96 }
97 }
98 }
99
100 /**
101 * An assumption that a given class has no subclasses implementing {@link Object#finalize()}).
102 */
103 public static final class NoFinalizableSubclass extends Assumption {
104
105 private ResolvedJavaType receiverType;
106
107 public NoFinalizableSubclass(ResolvedJavaType receiverType) {
108 this.receiverType = receiverType;
109 }
110
111 @Override
112 public int hashCode() {
113 return 31 + receiverType.hashCode();
114 }
115
116 @Override
117 public boolean equals(Object obj) {
118 if (obj instanceof NoFinalizableSubclass) {
119 NoFinalizableSubclass other = (NoFinalizableSubclass) obj;
120 return other.receiverType.equals(receiverType);
121 }
|