changeset 2486:55e512967525

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
author mchung
date Tue, 15 Jun 2010 20:34:49 -0700
parents 1b7879ca3e74
children 8a4557c5dfa1
files test/ProblemList.txt test/java/util/ResourceBundle/Bug4168625Test.java test/java/util/ResourceBundle/TestBug4179766.java
diffstat 3 files changed, 11 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/test/ProblemList.txt	Tue Jun 15 20:29:22 2010 -0700
+++ b/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/test/java/util/ResourceBundle/Bug4168625Test.java	Tue Jun 15 20:29:22 2010 -0700
+++ b/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/test/java/util/ResourceBundle/TestBug4179766.java	Tue Jun 15 20:29:22 2010 -0700
+++ b/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) {