Skip to content

Commit 3ac91b0

Browse files
committed
8293003: Review running time of Warn5 regression test
Reviewed-by: vromero
1 parent e0168a0 commit 3ac91b0

File tree

2 files changed

+27
-19
lines changed

2 files changed

+27
-19
lines changed

test/langtools/tools/javac/varargs/warning/Warn4.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -217,11 +217,13 @@ boolean badTestFilter() {
217217
return sigs[0].isApplicableTo(sigs[1]);
218218
}
219219

220-
final String template = "import java.util.List;\n" +
221-
"class Test {\n" +
222-
" #{TRUSTME} #{SUPPRESS[0]} #{MOD} #{MTH[0].VARARG}\n" +
223-
" #{SUPPRESS[1]} #{MTH[1].CLIENT}\n" +
224-
"}";
220+
final String template = """
221+
import java.util.List;
222+
class Test {
223+
#{TRUSTME} #{SUPPRESS[0]} #{MOD} #{MTH[0].VARARG}
224+
#{SUPPRESS[1]} #{MTH[1].CLIENT}
225+
}
226+
""";
225227

226228
@Override
227229
public void doWork() throws IOException {

test/langtools/tools/javac/varargs/warning/Warn5.java

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,10 @@ public String expand(String optParameter) {
125125
}
126126
}
127127

128+
// Handling of varargs warnings changed in JDK 9 compared to JDK 8
129+
// and then remained consistent; test 8 and then current release.
128130
enum SourceLevel {
129131
JDK_8("8"),
130-
JDK_9("9"),
131132
LATEST(Integer.toString(javax.lang.model.SourceVersion.latest().runtimeVersion().feature()));
132133

133134
String sourceKey;
@@ -159,12 +160,15 @@ public String expand(String optParameter) {
159160
}
160161
}
161162

163+
// javac does not currently perform analysis of the method body
164+
// with respect to the validity of the @SafeVargs annotation. If
165+
// that changes, the body tests should be expanded.
162166
enum BodyKind implements ComboParameter {
163-
ASSIGN("Object o = x;", true),
164-
CAST("Object o = (Object)x;", true),
167+
// ASSIGN("Object o = x;", true),
168+
// CAST("Object o = (Object)x;", true),
165169
METH("test(x);", true),
166170
PRINT("System.out.println(x.toString());", false),
167-
ARRAY_ASSIGN("Object[] o = x;", true),
171+
// ARRAY_ASSIGN("Object[] o = x;", true),
168172
ARRAY_CAST("Object[] o = (Object[])x;", true),
169173
ARRAY_METH("testArr(x);", true);
170174

@@ -222,13 +226,15 @@ boolean badTestFilter() {
222226
return (methKind != MethodKind.CONSTRUCTOR || modKind == ModifierKind.NONE);
223227
}
224228

225-
String template = "import com.sun.tools.javac.api.*;\n" +
226-
"import java.util.List;\n" +
227-
"class Test {\n" +
228-
" static void test(Object o) {}\n" +
229-
" static void testArr(Object[] o) {}\n" +
230-
" #{TRUSTME} #{SUPPRESS} #{MOD} #{SIG} { #{BODY} }\n" +
231-
"}\n";
229+
String template = """
230+
import com.sun.tols.javac.api.*;
231+
import java.util.List;
232+
class Test {
233+
static void test(Object o) {}
234+
static void testArr(Object[] o) {}
235+
#{TRUSTME} #{SUPPRESS} #{MOD} #{SIG} { #{BODY} }
236+
}
237+
""";
232238

233239
@Override
234240
public void doWork() throws IOException {
@@ -265,7 +271,7 @@ void check(Result<?> res) {
265271
(methKind == MethodKind.CONSTRUCTOR ||
266272
(methKind == MethodKind.METHOD &&
267273
modKind == ModifierKind.FINAL || modKind == ModifierKind.STATIC ||
268-
(modKind == ModifierKind.PRIVATE && sourceLevel.compareTo(SourceLevel.JDK_9) >= 0)))) {
274+
(modKind == ModifierKind.PRIVATE && sourceLevel.compareTo(SourceLevel.JDK_8) > 0)))) {
269275
expectedWarnings.add(WarningKind.UNSAFE_BODY);
270276
}
271277

@@ -279,7 +285,7 @@ void check(Result<?> res) {
279285
if (trustMe == TrustMe.TRUST &&
280286
(!sig.isVarargs ||
281287
((modKind == ModifierKind.NONE ||
282-
modKind == ModifierKind.PRIVATE && sourceLevel.compareTo(SourceLevel.JDK_9) < 0 ) &&
288+
modKind == ModifierKind.PRIVATE && sourceLevel.compareTo(SourceLevel.JDK_8) <= 0 ) &&
283289
methKind == MethodKind.METHOD))) {
284290
expectedWarnings.add(WarningKind.MALFORMED_SAFEVARARGS);
285291
}
@@ -288,7 +294,7 @@ void check(Result<?> res) {
288294
xlint != XlintOption.NONE &&
289295
suppressLevel != SuppressLevel.VARARGS &&
290296
(modKind == ModifierKind.FINAL || modKind == ModifierKind.STATIC ||
291-
(modKind == ModifierKind.PRIVATE && sourceLevel.compareTo(SourceLevel.JDK_9) >= 0) ||
297+
(modKind == ModifierKind.PRIVATE && sourceLevel.compareTo(SourceLevel.JDK_8) > 0) ||
292298
methKind == MethodKind.CONSTRUCTOR) &&
293299
sig.isVarargs &&
294300
sig.isReifiableArg) {

0 commit comments

Comments
 (0)