src/share/classes/java/lang/ref/Reference.java
Print this page
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2013, 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. Oracle designates this
@@ -136,12 +136,21 @@
if (pending != null) {
r = pending;
pending = r.discovered;
r.discovered = null;
} else {
+ // we explicitly cascade the two exceptions here to avoid
+ // double throw of OOME in case InterruptedException needs
+ // to be loaded during OOME caused by waiting for the
+ // lock to be signaled.
+ // The class loading may further trigger other secondary
+ // exceptions due to low memory that may cause the thread
+ // to terminate too.
+ try {
try {
lock.wait();
+ } catch (OutOfMemoryError x) { }
} catch (InterruptedException x) { }
continue;
}
}