Lines 76-230
import java.util.regex.Pattern;
Link Here
|
76 |
|
76 |
|
77 |
public abstract class AbstractRegressionTest extends AbstractCompilerTest implements StopableTestCase { |
77 |
public abstract class AbstractRegressionTest extends AbstractCompilerTest implements StopableTestCase { |
78 |
|
78 |
|
79 |
// for compiling against JRE 8: |
|
|
80 |
static final boolean IS_JRE_8; |
81 |
static final String COMPARATOR_IMPL_JRE8; |
82 |
static final String COMPARATOR_RAW_IMPL_JRE8; |
83 |
static final String COLLECTION_IMPL_JRE8; |
84 |
static final String COLLECTION_RAW_IMPL_JRE8; |
85 |
static final String LIST_IMPL_JRE8; |
86 |
static final String COLLECTION_AND_LIST_IMPL_JRE8; |
87 |
static final String COLLECTION_AND_LIST_RAW_IMPL_JRE8; |
88 |
static final String LIST_RAW_IMPL_JRE8; |
89 |
static final String ITERABLE_IMPL_JRE8; |
90 |
static final String ITERABLE_RAW_IMPL_JRE8; |
91 |
static final String ITERATOR_IMPL_JRE8; |
92 |
static final String ITERATOR_RAW_IMPL_JRE8; |
93 |
static final String MAP_IMPL_JRE8; |
94 |
static final String MAP_RAW_IMPL_JRE8; |
95 |
|
96 |
static { |
97 |
String javaVersion = System.getProperty("java.specification.version"); |
98 |
IS_JRE_8 = "1.8".equals(javaVersion); |
99 |
if (IS_JRE_8) { // TODO(stephan) accommodate future versions ... |
100 |
COMPARATOR_IMPL_JRE8 = // replace '*' with T, '%' with U, $ with S |
101 |
" public java.util.Comparator<*> reverseOrder() { return null;}\n" + |
102 |
" public java.util.Comparator<*> reversed() { return null;}\n" + |
103 |
" public java.util.Comparator<*> thenComparing(java.util.Comparator<? super *> other) { return null;}\n" + |
104 |
" public <%> java.util.Comparator<*> thenComparing(java.util.function.Function<? super *, ? extends %> keyExtractor, java.util.Comparator<? super %> keyComparator) { return null;}\n" + |
105 |
" public <% extends java.lang.Comparable<? super %>> java.util.Comparator<*> thenComparing(java.util.function.Function<? super *, ? extends %> keyExtractor) { return null;}\n" + |
106 |
" public java.util.Comparator<*> thenComparingInt(java.util.function.ToIntFunction<? super *> keyExtractor) { return null;}\n" + |
107 |
" public java.util.Comparator<*> thenComparingLong(java.util.function.ToLongFunction<? super *> keyExtractor) { return null;}\n" + |
108 |
" public java.util.Comparator<*> thenComparingDouble(java.util.function.ToDoubleFunction<? super *> keyExtractor) { return null;}\n"; |
109 |
COMPARATOR_RAW_IMPL_JRE8 = |
110 |
" public java.util.Comparator reverseOrder() { return null;}\n" + |
111 |
" public java.util.Comparator reversed() { return null;}\n" + |
112 |
" public java.util.Comparator thenComparing(java.util.Comparator other) { return null;}\n" + |
113 |
" public java.util.Comparator thenComparing(java.util.function.Function keyExtractor, java.util.Comparator keyComparator) { return null;}\n" + |
114 |
" public java.util.Comparator thenComparing(java.util.function.Function keyExtractor) { return null;}\n" + |
115 |
" public java.util.Comparator thenComparingInt(java.util.function.ToIntFunction keyExtractor) { return null;}\n" + |
116 |
" public java.util.Comparator thenComparingLong(java.util.function.ToLongFunction keyExtractor) { return null;}\n" + |
117 |
" public java.util.Comparator thenComparingDouble(java.util.function.ToDoubleFunction keyExtractor) { return null;}\n"; |
118 |
COLLECTION_IMPL_JRE8 = |
119 |
" public boolean removeAll(java.util.function.Predicate<? super *> filter) { return false;}\n" + |
120 |
" public boolean removeIf(java.util.function.Predicate<? super *> filter) { return false;}\n" + |
121 |
" public java.util.stream.Stream<*> stream() { return null;}\n" + |
122 |
" public java.util.stream.Stream<*> parallelStream() { return null;}\n"; |
123 |
COLLECTION_AND_LIST_IMPL_JRE8 = |
124 |
" public boolean removeAll(java.util.function.Predicate<? super *> filter) { return false;}\n" + |
125 |
" public boolean removeIf(java.util.function.Predicate<? super *> filter) { return false;}\n" + |
126 |
" public java.util.stream.Stream<*> stream() { return null;}\n" + |
127 |
" public java.util.stream.Stream<*> parallelStream() { return null;}\n" + |
128 |
" public void sort(java.util.Comparator<? super *> comparator) {}\n" + |
129 |
" public void parallelSort(java.util.Comparator<? super *> comparator) {}\n" + |
130 |
" public void replaceAll(java.util.function.UnaryOperator<*> operator) {}\n"; |
131 |
COLLECTION_RAW_IMPL_JRE8 = |
132 |
" public @SuppressWarnings(\"rawtypes\") boolean removeAll(java.util.function.Predicate filter) { return false;}\n" + |
133 |
" public @SuppressWarnings(\"rawtypes\") boolean removeIf(java.util.function.Predicate filter) { return false;}\n" + |
134 |
" public @SuppressWarnings(\"rawtypes\") java.util.stream.Stream stream() { return null;}\n" + |
135 |
" public @SuppressWarnings(\"rawtypes\") java.util.stream.Stream parallelStream() { return null;}\n"; |
136 |
LIST_IMPL_JRE8 = // replace '*' with your concrete type argument |
137 |
" public void sort(java.util.Comparator<? super *> comparator) {}\n" + |
138 |
" public void parallelSort(java.util.Comparator<? super *> comparator) {}\n" + |
139 |
" public void replaceAll(java.util.function.UnaryOperator<*> operator) {}\n"; |
140 |
LIST_RAW_IMPL_JRE8 = |
141 |
" public @SuppressWarnings(\"rawtypes\") void sort(java.util.Comparator comparator) {}\n" + |
142 |
" public @SuppressWarnings(\"rawtypes\") void parallelSort(java.util.Comparator comparator) {}\n" + |
143 |
" public @SuppressWarnings(\"rawtypes\") void replaceAll(java.util.function.UnaryOperator operator) {}\n"; |
144 |
COLLECTION_AND_LIST_RAW_IMPL_JRE8 = |
145 |
" public @SuppressWarnings(\"rawtypes\") boolean removeAll(java.util.function.Predicate filter) { return false;}\n" + |
146 |
" public @SuppressWarnings(\"rawtypes\") boolean removeIf(java.util.function.Predicate filter) { return false;}\n" + |
147 |
" public @SuppressWarnings(\"rawtypes\") java.util.stream.Stream stream() { return null;}\n" + |
148 |
" public @SuppressWarnings(\"rawtypes\") java.util.stream.Stream parallelStream() { return null;}\n" + |
149 |
" public @SuppressWarnings(\"rawtypes\") void sort(java.util.Comparator comparator) {}\n" + |
150 |
" public @SuppressWarnings(\"rawtypes\") void parallelSort(java.util.Comparator comparator) {}\n" + |
151 |
" public @SuppressWarnings(\"rawtypes\") void replaceAll(java.util.function.UnaryOperator operator) {}\n"; |
152 |
ITERABLE_IMPL_JRE8 = // replace '*' with your concrete type argument |
153 |
" public void forEach(java.util.function.Consumer<? super *> block){}\n" + |
154 |
" public void forEachRemaining(java.util.function.Consumer<? super *> action) {}\n" + |
155 |
" public java.util.Spliterator<*> spliterator() {return null;}\n"; |
156 |
ITERABLE_RAW_IMPL_JRE8 = |
157 |
" public @SuppressWarnings(\"rawtypes\") void forEach(java.util.function.Consumer action) {}\n" + |
158 |
" public @SuppressWarnings(\"rawtypes\") void forEachRemaining(java.util.function.Consumer action) {}\n" + |
159 |
" public @SuppressWarnings(\"rawtypes\") java.util.Spliterator spliterator() {return null;}\n"; |
160 |
ITERATOR_IMPL_JRE8 = // replace '*' with your concrete type argument |
161 |
"public void forEach(java.util.function.Consumer<? super *> action) {}\n" + |
162 |
"public void forEachRemaining(java.util.function.Consumer<? super *> action) {}\n"; |
163 |
ITERATOR_RAW_IMPL_JRE8 = |
164 |
" public @SuppressWarnings(\"rawtypes\") void forEach(java.util.function.Consumer block) {}\n" + |
165 |
" public @SuppressWarnings(\"rawtypes\") void forEachRemaining(java.util.function.Consumer action) {}\n"; |
166 |
MAP_IMPL_JRE8 = // '*' for 'K', '%' for 'V' |
167 |
" public boolean remove(Object key, Object value) { return false;}\n" + |
168 |
" public % getOrDefault(Object key, % defaultValue) {return defaultValue;}\n" + |
169 |
" public void forEach(java.util.function.BiConsumer<? super *, ? super %> block) {}\n" + |
170 |
" public void replaceAll(java.util.function.BiFunction<? super *, ? super %, ? extends %> function) {}\n" + |
171 |
" public % putIfAbsent(* key, % value) { return null;}\n" + |
172 |
" public boolean replace(* key, % oldValue, % newValue) { return false;}\n" + |
173 |
" public % replace(* key, % value) { return null;}\n" + |
174 |
" public % computeIfAbsent(* key, java.util.function.Function<? super *, ? extends %> mappingFunction) { return null;}\n" + |
175 |
" public % computeIfPresent(* key, java.util.function.BiFunction<? super *, ? super %, ? extends %> remappingFunction) { return null;}\n" + |
176 |
" public % compute(* key, java.util.function.BiFunction<? super *, ? super %, ? extends %> remappingFunction) { return null;}\n" + |
177 |
" public % merge(* key, % value, java.util.function.BiFunction<? super %, ? super %, ? extends %> remappingFunction) { return null;}\n"; |
178 |
MAP_RAW_IMPL_JRE8 = |
179 |
" public boolean remove(Object key, Object value) { return false;}\n" + |
180 |
" public @SuppressWarnings(\"rawtypes\") Object getOrDefault(Object key, Object defaultValue) { return defaultValue;}\n" + |
181 |
" public @SuppressWarnings(\"rawtypes\") void forEach(java.util.function.BiConsumer block) {}\n" + |
182 |
" public @SuppressWarnings(\"rawtypes\") void replaceAll(java.util.function.BiFunction function) {}\n" + |
183 |
" public Object putIfAbsent(Object key, Object value) { return null;}\n" + |
184 |
" public boolean replace(Object key, Object oldValue, Object newValue) { return false;}\n" + |
185 |
" public Object replace(Object key, Object value) { return null;}\n" + |
186 |
" public @SuppressWarnings(\"rawtypes\") Object computeIfAbsent(Object key, java.util.function.Function mappingFunction) { return null;}\n" + |
187 |
" public @SuppressWarnings(\"rawtypes\") Object computeIfPresent(Object key, java.util.function.BiFunction remappingFunction) { return null;}\n" + |
188 |
" public @SuppressWarnings(\"rawtypes\") Object compute(Object key, java.util.function.BiFunction remappingFunction) { return null;}\n" + |
189 |
" public @SuppressWarnings(\"rawtypes\") Object merge(Object key, Object value, java.util.function.BiFunction remappingFunction) { return null;}\n"; |
190 |
} else { |
191 |
COMPARATOR_IMPL_JRE8 = ""; |
192 |
COMPARATOR_RAW_IMPL_JRE8 = ""; |
193 |
COLLECTION_IMPL_JRE8 = ""; |
194 |
COLLECTION_RAW_IMPL_JRE8 = ""; |
195 |
LIST_IMPL_JRE8 = ""; |
196 |
COLLECTION_AND_LIST_IMPL_JRE8 = ""; |
197 |
COLLECTION_AND_LIST_RAW_IMPL_JRE8 = ""; |
198 |
LIST_RAW_IMPL_JRE8 = ""; |
199 |
ITERABLE_IMPL_JRE8 = ""; |
200 |
ITERABLE_RAW_IMPL_JRE8 = ""; |
201 |
ITERATOR_IMPL_JRE8 = "\n\n"; |
202 |
ITERATOR_RAW_IMPL_JRE8 = "\n\n"; |
203 |
MAP_IMPL_JRE8 = ""; |
204 |
MAP_RAW_IMPL_JRE8 = ""; |
205 |
} |
206 |
} |
207 |
String getCollectionAndListRawImplJRE8() { |
208 |
if (this.complianceLevel < ClassFileConstants.JDK1_5) |
209 |
return COLLECTION_AND_LIST_RAW_IMPL_JRE8.replaceAll("@SuppressWarnings\\(\"rawtypes\"\\)", ""); |
210 |
return COLLECTION_AND_LIST_RAW_IMPL_JRE8; |
211 |
} |
212 |
String getListRawImplJRE8() { |
213 |
if (this.complianceLevel < ClassFileConstants.JDK1_5) |
214 |
return LIST_RAW_IMPL_JRE8.replaceAll("@SuppressWarnings\\(\"rawtypes\"\\)", ""); |
215 |
return LIST_RAW_IMPL_JRE8; |
216 |
} |
217 |
String getIterableRawImplJRE8() { |
218 |
if (this.complianceLevel < ClassFileConstants.JDK1_5) |
219 |
return ITERABLE_RAW_IMPL_JRE8.replaceAll("@SuppressWarnings\\(\"rawtypes\"\\)", ""); |
220 |
return ITERABLE_RAW_IMPL_JRE8; |
221 |
} |
222 |
String getCollectionRawImplJRE8() { |
223 |
if (this.complianceLevel < ClassFileConstants.JDK1_5) |
224 |
return COLLECTION_RAW_IMPL_JRE8.replaceAll("@SuppressWarnings\\(\"rawtypes\"\\)", ""); |
225 |
return COLLECTION_RAW_IMPL_JRE8; |
226 |
} |
227 |
|
228 |
// javac comparison related types, fields and methods - see runJavac for |
79 |
// javac comparison related types, fields and methods - see runJavac for |
229 |
// details |
80 |
// details |
230 |
static class JavacCompiler { |
81 |
static class JavacCompiler { |