< prev index next >

test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadStartEvent/thread/thread001.java

Print this page
@@ -1,7 +1,7 @@
  /*
-  * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
+  * Copyright (c) 2001, 2021, 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
   * under the terms of the GNU General Public License version 2 only, as
   * published by the Free Software Foundation.

@@ -240,14 +240,25 @@
  
                          // Check that all expected debuggee's thread create ThreadStartEvent only once
                          for (int i = 0; i < checkedThreads.length; i++) {
                               if (threadName.equals(checkedThreads[i][0])) {
                                    if (checkedThreads[i][1].equals("0")) {
-                                        checkedThreads[i][1] = "1";
+                                       checkedThreads[i][1] = "1";
                                    } else {
-                                        log.complain("FAILURE 5: ThreadStartEvent for " + threadName + " is received more that once");
-                                        testFailed = true;
+                                       // When using the Virtual wrapper, the main thread is renamed to old-m-a-i-n,
+                                       // and a new "main" vthread is created. However, the rename happens after
+                                       // the debug agent has already generated the THREAD_START event for the
+                                       // original "main", so we end up with two THREAD_START events for "main".
+                                       // We need to allow for this.
+                                       if ("Virtual".equals(System.getProperty("main.wrapper")) &&
+                                               checkedThreads[i][0].equals("main") &&
+                                               checkedThreads[i][1].equals("1")) {
+                                           checkedThreads[i][1] = "2";
+                                       } else {
+                                           log.complain("FAILURE 5: ThreadStartEvent for " + threadName + " is received more that once");
+                                           testFailed = true;
+                              }
                                    }
                               }
                          }
  
                          // Check whether all expected events received
< prev index next >