6961506: TEST_BUG: ResourceBundle/Bug4168625Test.java and TestBug4179766.java fails in samevm mode
Summary: Set the proper parent class loader of Loader and SimpleLoader
Reviewed-by: naoto
--- a/jdk/test/ProblemList.txt Tue Jun 15 20:29:22 2010 -0700
+++ b/jdk/test/ProblemList.txt Tue Jun 15 20:34:49 2010 -0700
@@ -1234,10 +1234,6 @@
java/util/logging/ParentLoggersTest.java generic-all
# Need to be marked othervm, or changed to be samevm safe
-java/util/ResourceBundle/Bug4168625Test.java generic-all
-java/util/ResourceBundle/TestBug4179766.java generic-all
-
-# Need to be marked othervm, or changed to be samevm safe
java/util/WeakHashMap/GCDuringIteration.java generic-all
# Possible missing input stream close()? Causes samevm issues on windows
--- a/jdk/test/java/util/ResourceBundle/Bug4168625Test.java Tue Jun 15 20:29:22 2010 -0700
+++ b/jdk/test/java/util/ResourceBundle/Bug4168625Test.java Tue Jun 15 20:34:49 2010 -0700
@@ -431,9 +431,11 @@
private boolean network = false;
public SimpleLoader() {
+ super(SimpleLoader.class.getClassLoader());
this.network = false;
}
public SimpleLoader(boolean simulateNetworkLoad) {
+ super(SimpleLoader.class.getClassLoader());
this.network = simulateNetworkLoad;
}
public Class loadClass(final String className, final boolean resolveIt)
@@ -448,7 +450,7 @@
} catch (java.lang.InterruptedException e) {
}
}
- result = super.findSystemClass(className);
+ result = getParent().loadClass(className);
if ((result != null) && resolveIt) {
resolveClass(result);
}
@@ -464,11 +466,13 @@
private String[] classesToWaitFor;
public Loader() {
+ super(Loader.class.getClassLoader());
classesToLoad = new String[0];
classesToWaitFor = new String[0];
}
public Loader(final String[] classesToLoadIn, final String[] classesToWaitForIn) {
+ super(Loader.class.getClassLoader());
classesToLoad = classesToLoadIn;
classesToWaitFor = classesToWaitForIn;
}
@@ -544,10 +548,12 @@
}
/**
- * Delegate loading to the system loader
+ * Delegate loading to its parent class loader that loads the test classes.
+ * In othervm mode, the parent class loader is the system class loader;
+ * in samevm mode, the parent class loader is the jtreg URLClassLoader.
*/
private Class loadFromSystem(String className) throws ClassNotFoundException {
- return super.findSystemClass(className);
+ return getParent().loadClass(className);
}
public void logClasses(String title) {
--- a/jdk/test/java/util/ResourceBundle/TestBug4179766.java Tue Jun 15 20:29:22 2010 -0700
+++ b/jdk/test/java/util/ResourceBundle/TestBug4179766.java Tue Jun 15 20:34:49 2010 -0700
@@ -209,6 +209,7 @@
* Create a new loader
*/
public Loader(boolean sameHash) {
+ super(Loader.class.getClassLoader());
if (sameHash) {
thisHashCode = SAME_HASH_CODE;
} else {
@@ -287,7 +288,7 @@
*/
private Class loadFromSystem(String className) throws ClassNotFoundException {
try {
- Class result = super.findSystemClass(className);
+ Class result = getParent().loadClass(className);
printInfo(" ***Returning system class: "+className, result);
return result;
} catch (ClassNotFoundException e) {