commits@javamail.java.net

[mercurial:130] Switch from Classloader.loadClass to Class.forName, as recommended by

From: <shannon_at_kenai.com>
Date: Fri, 8 May 2009 20:35:35 +0000 (GMT)

Repository: mercurial
Revision: 130
Author: Bill Shannon <bill.shannon_at_sun.com>
Date: 2009-03-02 05:37:00 UTC
Link:
http://kenai.com/projects/javamail/sources/mercurial/revision/130

Log Message:
-----------
Switch from Classloader.loadClass to Class.forName, as recommended by
bug 6500212.

Modified Paths:
--------------
    mail/src/main/java/com/sun/mail/pop3/POP3Store.java
    mail/src/main/java/com/sun/mail/util/SocketFetcher.java
    mail/src/main/java/javax/mail/Session.java

Diffs:
-----
diff -r 657279c208d4 -r b20510d623f3
mail/src/main/java/com/sun/mail/pop3/POP3Store.java
--- a/mail/src/main/java/com/sun/mail/pop3/POP3Store.java Sun Mar
01 19:17:54 2009 -0800
+++ b/mail/src/main/java/com/sun/mail/pop3/POP3Store.java Sun Mar
01 21:37:00 2009 -0800
@@ -1,7 +1,7 @@
 /*
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
  *
- * Copyright 1997-2008 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved.
  *
  * The contents of this file are subject to the terms of either the
GNU
  * General Public License Version 2 only ("GPL") or the Common
Development
@@ -114,7 +114,7 @@
                    // First try the "application's" class loader.
                    // This should eventually be replaced by
                    // Thread.currentThread().getContextClassLoader().
- messageClass = cl.loadClass(s);
+ messageClass = Class.forName(s, false, cl);
                } catch (ClassNotFoundException ex1) {
                    // That didn't work, now try the "system" class
loader.
                    // (Need both of these because JDK 1.1 class
loaders
diff -r 657279c208d4 -r b20510d623f3
mail/src/main/java/com/sun/mail/util/SocketFetcher.java
--- a/mail/src/main/java/com/sun/mail/util/SocketFetcher.java Sun Mar
01 19:17:54 2009 -0800
+++ b/mail/src/main/java/com/sun/mail/util/SocketFetcher.java Sun Mar
01 21:37:00 2009 -0800
@@ -298,7 +298,7 @@
        Class clsSockFact = null;
        if (cl != null) {
            try {
- clsSockFact = cl.loadClass(sfClass);
+ clsSockFact = Class.forName(sfClass, false, cl);
            } catch (ClassNotFoundException cex) { }
        }
        if (clsSockFact == null)
diff -r 657279c208d4 -r b20510d623f3
mail/src/main/java/javax/mail/Session.java
--- a/mail/src/main/java/javax/mail/Session.java Sun Mar 01
19:17:54 2009 -0800
+++ b/mail/src/main/java/javax/mail/Session.java Sun Mar 01
21:37:00 2009 -0800
@@ -1,7 +1,7 @@
 /*
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
  *
- * Copyright 1997-2008 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved.
  *
  * The contents of this file are subject to the terms of either the
GNU
  * General Public License Version 2 only ("GPL") or the Common
Development
@@ -757,12 +757,14 @@
            ClassLoader ccl = getContextClassLoader();
            if (ccl != null)
                try {
- serviceClass =
ccl.loadClass(provider.getClassName());
+ serviceClass =
+ Class.forName(provider.getClassName(), false,
ccl);
                } catch (ClassNotFoundException ex) {
                    // ignore it
                }
            if (serviceClass == null)
- serviceClass = cl.loadClass(provider.getClassName());
+ serviceClass =
+ Class.forName(provider.getClassName(), false, cl);
        } catch (Exception ex1) {
            // That didn't work, now try the "system" class loader.
            // (Need both of these because JDK 1.1 class loaders