Hi David & Stuart,
Can you please help to review the fix for the bug 7147060
<http://monaco.us.oracle.com/detail.jsf?cr=7147060>, Thanks you!
The test reports ClassNotFoundException which is caused by below reasons:
1. Class can be found in "test.classes" instead of "test.src".
2. In agentvm mode, the MyTransform.class is loaded by the child of the
context ClassLoader of current thread, however, The method
Transform.register(String, String) tries to use context ClassLoader to
load class MyTransform.class which is not found.
The proposed fix is:
1. Replace "test.src" to "test.classes".
2. Replace the current thread ClassLoader to its child.
Regards,
Eric
--- old/test/ProblemList.txt 2012-07-05 15:57:49.477164126 +0800
+++ new/test/ProblemList.txt 2012-07-05 15:57:45.177070426 +0800
@@ -290,9 +290,6 @@
# 7177556
com/sun/crypto/provider/KeyFactory/TestProviderLeak.java generic-all
-# 7147060
-com/sun/org/apache/xml/internal/security/transforms/ClassLoaderTest.java
generic-all
-
# Failing on Solaris i586, 3/9/2010, not a -samevm issue (jdk_security3)
sun/security/pkcs11/Secmod/AddPrivateKey.java solaris-i586
sun/security/pkcs11/ec/ReadCertificates.java generic-all
---
old/test/com/sun/org/apache/xml/internal/security/transforms/ClassLoaderTest.java
2012-07-05 15:57:56.799140287 +0800
+++
new/test/com/sun/org/apache/xml/internal/security/transforms/ClassLoaderTest.java
2012-07-05 15:57:54.790043435 +0800
@@ -39,7 +39,7 @@
public class ClassLoaderTest {
- private final static String BASE = System.getProperty("test.src", "./");
+ private final static String BASE = System.getProperty("test.classes",
"./");
public static void main(String[] args) throws Exception {
@@ -50,15 +50,26 @@
URLClassLoader ucl = new URLClassLoader(urls);
Class c = ucl.loadClass("MyTransform");
Constructor cons = c.getConstructor();
- Object o = cons.newInstance();
- // Apache code swallows the ClassNotFoundExc, so we need to
- // check if the Transform has already been registered by registering
- // it again and catching an AlgorithmAlreadyRegisteredExc
+
+ Thread curThread = Thread.currentThread();
+ ClassLoader ctxLoader = curThread.getContextClassLoader();
+ ClassLoader loader = MyTransform.class.getClassLoader();
try {
+ // In agentvm mode, the class MyTransform is loaded by the child of
+ // context ClassLoader of this thread. Replace context ClassLoader
+ // with its child to avoid ClassNotFoundException thrown from
+ // Transform.register(String, String) method.
+ curThread.setContextClassLoader(loader);
+ Object o = cons.newInstance();
+ // Apache code swallows the ClassNotFoundExc, so we need to
+ // check if the Transform has already been registered by
registering
+ // it again and catching an AlgorithmAlreadyRegisteredExc
Transform.register(MyTransform.URI, "MyTransform");
throw new Exception("ClassLoaderTest failed");
} catch (AlgorithmAlreadyRegisteredException e) {
// test passed
+ } finally {
+ curThread.setContextClassLoader(ctxLoader);
}
}
}