8293003: Review running time of Warn5 regression test
Reviewed-by: vromero
This commit is contained in:
parent
e0168a0eb0
commit
3ac91b08cb
@ -217,11 +217,13 @@ public class Warn4 extends ComboInstance<Warn4> {
|
|||||||
return sigs[0].isApplicableTo(sigs[1]);
|
return sigs[0].isApplicableTo(sigs[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
final String template = "import java.util.List;\n" +
|
final String template = """
|
||||||
"class Test {\n" +
|
import java.util.List;
|
||||||
" #{TRUSTME} #{SUPPRESS[0]} #{MOD} #{MTH[0].VARARG}\n" +
|
class Test {
|
||||||
" #{SUPPRESS[1]} #{MTH[1].CLIENT}\n" +
|
#{TRUSTME} #{SUPPRESS[0]} #{MOD} #{MTH[0].VARARG}
|
||||||
"}";
|
#{SUPPRESS[1]} #{MTH[1].CLIENT}
|
||||||
|
}
|
||||||
|
""";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void doWork() throws IOException {
|
public void doWork() throws IOException {
|
||||||
|
@ -125,9 +125,10 @@ public class Warn5 extends ComboInstance<Warn5> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Handling of varargs warnings changed in JDK 9 compared to JDK 8
|
||||||
|
// and then remained consistent; test 8 and then current release.
|
||||||
enum SourceLevel {
|
enum SourceLevel {
|
||||||
JDK_8("8"),
|
JDK_8("8"),
|
||||||
JDK_9("9"),
|
|
||||||
LATEST(Integer.toString(javax.lang.model.SourceVersion.latest().runtimeVersion().feature()));
|
LATEST(Integer.toString(javax.lang.model.SourceVersion.latest().runtimeVersion().feature()));
|
||||||
|
|
||||||
String sourceKey;
|
String sourceKey;
|
||||||
@ -159,12 +160,15 @@ public class Warn5 extends ComboInstance<Warn5> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// javac does not currently perform analysis of the method body
|
||||||
|
// with respect to the validity of the @SafeVargs annotation. If
|
||||||
|
// that changes, the body tests should be expanded.
|
||||||
enum BodyKind implements ComboParameter {
|
enum BodyKind implements ComboParameter {
|
||||||
ASSIGN("Object o = x;", true),
|
// ASSIGN("Object o = x;", true),
|
||||||
CAST("Object o = (Object)x;", true),
|
// CAST("Object o = (Object)x;", true),
|
||||||
METH("test(x);", true),
|
METH("test(x);", true),
|
||||||
PRINT("System.out.println(x.toString());", false),
|
PRINT("System.out.println(x.toString());", false),
|
||||||
ARRAY_ASSIGN("Object[] o = x;", true),
|
// ARRAY_ASSIGN("Object[] o = x;", true),
|
||||||
ARRAY_CAST("Object[] o = (Object[])x;", true),
|
ARRAY_CAST("Object[] o = (Object[])x;", true),
|
||||||
ARRAY_METH("testArr(x);", true);
|
ARRAY_METH("testArr(x);", true);
|
||||||
|
|
||||||
@ -222,13 +226,15 @@ public class Warn5 extends ComboInstance<Warn5> {
|
|||||||
return (methKind != MethodKind.CONSTRUCTOR || modKind == ModifierKind.NONE);
|
return (methKind != MethodKind.CONSTRUCTOR || modKind == ModifierKind.NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
String template = "import com.sun.tools.javac.api.*;\n" +
|
String template = """
|
||||||
"import java.util.List;\n" +
|
import com.sun.tols.javac.api.*;
|
||||||
"class Test {\n" +
|
import java.util.List;
|
||||||
" static void test(Object o) {}\n" +
|
class Test {
|
||||||
" static void testArr(Object[] o) {}\n" +
|
static void test(Object o) {}
|
||||||
" #{TRUSTME} #{SUPPRESS} #{MOD} #{SIG} { #{BODY} }\n" +
|
static void testArr(Object[] o) {}
|
||||||
"}\n";
|
#{TRUSTME} #{SUPPRESS} #{MOD} #{SIG} { #{BODY} }
|
||||||
|
}
|
||||||
|
""";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void doWork() throws IOException {
|
public void doWork() throws IOException {
|
||||||
@ -265,7 +271,7 @@ public class Warn5 extends ComboInstance<Warn5> {
|
|||||||
(methKind == MethodKind.CONSTRUCTOR ||
|
(methKind == MethodKind.CONSTRUCTOR ||
|
||||||
(methKind == MethodKind.METHOD &&
|
(methKind == MethodKind.METHOD &&
|
||||||
modKind == ModifierKind.FINAL || modKind == ModifierKind.STATIC ||
|
modKind == ModifierKind.FINAL || modKind == ModifierKind.STATIC ||
|
||||||
(modKind == ModifierKind.PRIVATE && sourceLevel.compareTo(SourceLevel.JDK_9) >= 0)))) {
|
(modKind == ModifierKind.PRIVATE && sourceLevel.compareTo(SourceLevel.JDK_8) > 0)))) {
|
||||||
expectedWarnings.add(WarningKind.UNSAFE_BODY);
|
expectedWarnings.add(WarningKind.UNSAFE_BODY);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -279,7 +285,7 @@ public class Warn5 extends ComboInstance<Warn5> {
|
|||||||
if (trustMe == TrustMe.TRUST &&
|
if (trustMe == TrustMe.TRUST &&
|
||||||
(!sig.isVarargs ||
|
(!sig.isVarargs ||
|
||||||
((modKind == ModifierKind.NONE ||
|
((modKind == ModifierKind.NONE ||
|
||||||
modKind == ModifierKind.PRIVATE && sourceLevel.compareTo(SourceLevel.JDK_9) < 0 ) &&
|
modKind == ModifierKind.PRIVATE && sourceLevel.compareTo(SourceLevel.JDK_8) <= 0 ) &&
|
||||||
methKind == MethodKind.METHOD))) {
|
methKind == MethodKind.METHOD))) {
|
||||||
expectedWarnings.add(WarningKind.MALFORMED_SAFEVARARGS);
|
expectedWarnings.add(WarningKind.MALFORMED_SAFEVARARGS);
|
||||||
}
|
}
|
||||||
@ -288,7 +294,7 @@ public class Warn5 extends ComboInstance<Warn5> {
|
|||||||
xlint != XlintOption.NONE &&
|
xlint != XlintOption.NONE &&
|
||||||
suppressLevel != SuppressLevel.VARARGS &&
|
suppressLevel != SuppressLevel.VARARGS &&
|
||||||
(modKind == ModifierKind.FINAL || modKind == ModifierKind.STATIC ||
|
(modKind == ModifierKind.FINAL || modKind == ModifierKind.STATIC ||
|
||||||
(modKind == ModifierKind.PRIVATE && sourceLevel.compareTo(SourceLevel.JDK_9) >= 0) ||
|
(modKind == ModifierKind.PRIVATE && sourceLevel.compareTo(SourceLevel.JDK_8) > 0) ||
|
||||||
methKind == MethodKind.CONSTRUCTOR) &&
|
methKind == MethodKind.CONSTRUCTOR) &&
|
||||||
sig.isVarargs &&
|
sig.isVarargs &&
|
||||||
sig.isReifiableArg) {
|
sig.isReifiableArg) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user