Could someone, please, take a look at this? Thanks,
-JB- On 9.7.2015 18:45, Jaroslav Bachorik wrote:
Please, review the following test change Issue : https://bugs.openjdk.java.net/browse/JDK-8129976 Webrev: http://cr.openjdk.java.net/~jbachorik/8129976/webrev.00 The test, as it is now, most of the times does not test the desired functionality (that invoking GC.run_finalization DCMD actually runs finalization) because the preceding call to System.gc() will finalize the test object sooner. But without calling System.gc() it is non predictable when the test object will be eligible for finalization so we have to call System.gc(). In the rare occasions when System.gc() induced finalization does not finish before invoking GC.run_finalization the test deadlocks because its locking logic is flawed. In order to make this test work I had to: a\ Switch from '@run testng' to '@run main/othervm' b\ Run the finalization testing code in shutdown handler - this seems to prevent the finalization happening prematurely after calling System.gc() while still making the test object eligible for finalization c\ Switch from ReentrantLock to a Phaser for synchronization d\ Make sure that the finalization is not carried out on the default "Finalizer" thread to rule out finalization due to System.gc() After these changes the test seems to be rather stable (ran 1000 iterations in a tight loop without single failure). Thanks, -JB-
