8220625: tools/javac/classreader/8171132/BadConstantValue.java failed with "did not see expected error"
authormdoerr
Mon, 15 Apr 2019 10:16:04 +0200
changeset 54530 00c0906bf4d1
parent 54529 d2c2622995e2
child 54531 edf1b4c6b936
child 57327 8b01c7bfb36f
8220625: tools/javac/classreader/8171132/BadConstantValue.java failed with "did not see expected error" Reviewed-by: clanger
test/langtools/tools/javac/classreader/8171132/BadConstantValue.java
--- a/test/langtools/tools/javac/classreader/8171132/BadConstantValue.java	Sun Apr 14 21:40:07 2019 +0000
+++ b/test/langtools/tools/javac/classreader/8171132/BadConstantValue.java	Mon Apr 15 10:16:04 2019 +0200
@@ -134,6 +134,8 @@
                 "class Lib { static final int A = %s; static final %s B = %s; }",
                 value, type, (type.equals("boolean") ? "false" : "0")));
         compile("-d", classesdir.getPath(), lib.getPath());
+        // Lib.class may possibly not get a newer timestamp. Make sure .java file won't get used.
+        lib.delete();
         File libClass = new File(classesdir, "Lib.class");
         // Rewrite the class to only have field B of type "type" and with "value" (potentially
         // out of range).
@@ -147,6 +149,8 @@
                 "class Lib { static final String A = \"hello\"; static final %s CONST = %s; }",
                 type, type.equals("boolean") ? "false" : "0"));
         compile("-d", classesdir.getPath(), lib.getPath());
+        // Lib.class may possibly not get a newer timestamp. Make sure .java file won't get used.
+        lib.delete();
         File libClass = new File(classesdir, "Lib.class");
         swapConstantValues(libClass);