8204521: compiler/jsr292/RedefineMethodUsedByMultipleMethodHandles.java fails trying to delete temp file
authordlong
Mon, 05 Nov 2018 22:22:49 -0800
changeset 52422 481e3b24a58c
parent 52421 3021c1ad958b
child 52423 00db205006c9
8204521: compiler/jsr292/RedefineMethodUsedByMultipleMethodHandles.java fails trying to delete temp file Reviewed-by: kvn
test/hotspot/jtreg/ProblemList-graal.txt
test/hotspot/jtreg/compiler/jsr292/RedefineMethodUsedByMultipleMethodHandles.java
--- a/test/hotspot/jtreg/ProblemList-graal.txt	Mon Nov 05 18:27:14 2018 -0500
+++ b/test/hotspot/jtreg/ProblemList-graal.txt	Mon Nov 05 22:22:49 2018 -0800
@@ -43,8 +43,6 @@
 
 compiler/jvmci/SecurityRestrictionsTest.java                    8181837   generic-all
 
-compiler/jsr292/RedefineMethodUsedByMultipleMethodHandles.java  8204521   windows-all
-
 compiler/unsafe/UnsafeGetConstantField.java                     8181833   generic-all
 compiler/unsafe/UnsafeGetStableArrayElement.java                8181833   generic-all
 compiler/unsafe/UnsafeOffHeapBooleanTest.java                   8181833   generic-all
--- a/test/hotspot/jtreg/compiler/jsr292/RedefineMethodUsedByMultipleMethodHandles.java	Mon Nov 05 18:27:14 2018 -0500
+++ b/test/hotspot/jtreg/compiler/jsr292/RedefineMethodUsedByMultipleMethodHandles.java	Mon Nov 05 22:22:49 2018 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -115,16 +115,15 @@
         mainAttrs.putValue("Can-Redefine-Classes", "true");
         mainAttrs.putValue("Can-Retransform-Classes", "true");
 
-        Path jar = Files.createTempFile("myagent", ".jar");
-        try {
-            JarOutputStream jarStream = new JarOutputStream(new FileOutputStream(jar.toFile()), manifest);
-            add(jarStream, FooAgent.class);
-            add(jarStream, FooTransformer.class);
-            jarStream.close();
-            runAgent(jar);
-        } finally {
-            Files.deleteIfExists(jar);
-        }
+        // The jar file will be added to the system classloader search path.  It is not safe
+        // to delete it while the JVM is running, so make sure to create it in the test
+        // directory so it will be cleaned up by the test harness.
+        Path jar = Files.createTempFile(Path.of(""), "myagent", ".jar");
+        JarOutputStream jarStream = new JarOutputStream(new FileOutputStream(jar.toFile()), manifest);
+        add(jarStream, FooAgent.class);
+        add(jarStream, FooTransformer.class);
+        jarStream.close();
+        runAgent(jar);
     }
 
     public static void runAgent(Path agent) throws Exception {