< prev index next >
test/sun/security/provider/FileInputStreamPool/FileInputStreamPoolTest.java
Print this page
rev 15227 : imported patch vm_api
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, 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.
@@ -67,11 +67,11 @@
static void processReferences() {
// make JVM process References
System.gc();
// help ReferenceHandler thread enqueue References
- while (TestProxy.Reference_tryHandlePending(false)) {}
+ while (TestProxy.Reference_waitForReferenceProcessing()) { }
// help run Finalizers
System.runFinalization();
}
public static void main(String[] args) throws Exception {
@@ -101,28 +101,28 @@
}
/**
* A proxy for (package)private static methods:
* sun.security.provider.FileInputStreamPool.getInputStream
- * java.lang.ref.Reference.tryHandlePending
+ * java.lang.ref.Reference.waitForReferenceProcessing
*/
static class TestProxy {
private static final Method getInputStreamMethod;
- private static final Method tryHandlePendingMethod;
+ private static final Method waitForReferenceProcessingMethod;
static {
try {
Class<?> fileInputStreamPoolClass =
Class.forName("sun.security.provider.FileInputStreamPool");
getInputStreamMethod =
fileInputStreamPoolClass.getDeclaredMethod(
"getInputStream", File.class);
getInputStreamMethod.setAccessible(true);
- tryHandlePendingMethod = Reference.class.getDeclaredMethod(
- "tryHandlePending", boolean.class);
- tryHandlePendingMethod.setAccessible(true);
+ waitForReferenceProcessingMethod =
+ Reference.class.getDeclaredMethod("waitForReferenceProcessing");
+ waitForReferenceProcessingMethod.setAccessible(true);
} catch (Exception e) {
throw new Error(e);
}
}
@@ -144,17 +144,18 @@
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
}
- static boolean Reference_tryHandlePending(boolean waitForNotify) {
+ static boolean Reference_waitForReferenceProcessing() {
try {
- return (boolean) tryHandlePendingMethod
- .invoke(null, waitForNotify);
+ return (boolean) waitForReferenceProcessingMethod.invoke(null);
} catch (InvocationTargetException e) {
Throwable te = e.getTargetException();
- if (te instanceof RuntimeException) {
+ if (te instanceof InterruptedException) {
+ return true;
+ } else if (te instanceof RuntimeException) {
throw (RuntimeException) te;
} else if (te instanceof Error) {
throw (Error) te;
} else {
throw new UndeclaredThrowableException(te);
< prev index next >