< prev index next >

test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/bcinstr/BI04/bi04t002/newclass02/java.base/java/lang/Object.java

Print this page
*** 1,7 ***
  /*
!  * Copyright (c) 2004, 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
   * under the terms of the GNU General Public License version 2 only, as
   * published by the Free Software Foundation.
--- 1,7 ---
  /*
!  * Copyright (c) 2004, 2019, 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.

*** 21,10 ***
--- 21,11 ---
   * questions.
   */
  
  package java.lang;
  
+ import jdk.internal.misc.Blocker;
  import nsk.jvmti.scenarios.bcinstr.BI04.bi04t002a;
  
  /**
   * Class <code>Object</code> is the root of the class hierarchy.
   * Every class has <code>Object</code> as a superclass. All objects,

*** 364,11 ***
       *             status</i> of the current thread is cleared when
       *             this exception is thrown.
       * @see        java.lang.Object#notify()
       * @see        java.lang.Object#notifyAll()
       */
!     public final native void wait(long timeout) throws InterruptedException;
  
      /**
       * Causes current thread to wait until another thread invokes the
       * {@link java.lang.Object#notify()} method or the
       * {@link java.lang.Object#notifyAll()} method for this object, or
--- 365,24 ---
       *             status</i> of the current thread is cleared when
       *             this exception is thrown.
       * @see        java.lang.Object#notify()
       * @see        java.lang.Object#notifyAll()
       */
!     public final void wait(long timeoutMillis) throws InterruptedException {
+         Thread thread = Thread.currentThread();
+         if (thread.isVirtual()) {
+             try {
+                 Blocker.managedBlock(() -> wait0(timeoutMillis));
+             } catch (Exception e) {
+                 if (e instanceof InterruptedException)
+                     thread.getAndClearInterrupt();
+                 throw e;
+             }
+         } else {
+             wait0(timeoutMillis);
+         }
+     }
  
      /**
       * Causes current thread to wait until another thread invokes the
       * {@link java.lang.Object#notify()} method or the
       * {@link java.lang.Object#notifyAll()} method for this object, or

*** 448,10 ***
--- 462,13 ---
              }
  
              wait(timeout);
      }
  
+     // final modifier so method not in vtable
+     private final native void wait0(long timeoutMillis) throws InterruptedException;
+ 
      /**
       * Causes current thread to wait until another thread invokes the
       * {@link java.lang.Object#notify()} method or the
       * {@link java.lang.Object#notifyAll()} method for this object.
       * In other words, this method behaves exactly as if it simply
< prev index next >