am 5f9aa938: Merge change 4334 into donut
Merge commit '5f9aa93881e796a66c2a625ced1ee89292c2b570'
* commit '5f9aa93881e796a66c2a625ced1ee89292c2b570':
Modified Thread to copy the context class loader from parent to child threads. Re-enabled test that covers this. Removed security-related code from test since it was invalid (the security check
diff --git a/libcore/luni-kernel/src/main/java/java/lang/Thread.java b/libcore/luni-kernel/src/main/java/java/lang/Thread.java
index d3795f8..3cde7e1 100644
--- a/libcore/luni-kernel/src/main/java/java/lang/Thread.java
+++ b/libcore/luni-kernel/src/main/java/java/lang/Thread.java
@@ -508,6 +508,8 @@
this.priority = currentThread.getPriority();
+ this.contextClassLoader = currentThread.contextClassLoader;
+
// Transfer over InheritableThreadLocals.
if (currentThread.inheritableValues != null) {
inheritableValues
diff --git a/libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ThreadTest.java b/libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ThreadTest.java
index 6ef6d33..47eb166 100644
--- a/libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ThreadTest.java
+++ b/libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ThreadTest.java
@@ -604,8 +604,6 @@
method = "getContextClassLoader",
args = {}
)
- @KnownFailure("The context class loader is not inherited by a new thread."
- + " On android the initial context class loader is alsways null.")
public void test_getContextClassLoader() {
// Test for method java.lang.ClassLoader
// java.lang.Thread.getContextClassLoader()
@@ -614,28 +612,6 @@
assertTrue("Incorrect class loader returned",
t.getContextClassLoader() == Thread.currentThread()
.getContextClassLoader());
- t.start();
-
- /* SecurityManager sm = new SecurityManager() {
-
- public void checkPermission(Permission perm) {
- if(perm.getName().equals("getClassLoader")) {
- throw new SecurityException();
- }
- }
- };
-
- SecurityManager oldSm = System.getSecurityManager();
- System.setSecurityManager(sm);
- try {
- t.getContextClassLoader();
- fail("Should throw SecurityException");
- } catch (SecurityException e) {
- // expected
- } finally {
- System.setSecurityManager(oldSm);
- }
-*/
}
/**