RT/classForName currently hardwires the "initialize" option of  
Class.forName to false. In working with jdbc drivers, the need to  
initialize classes in some circumstances came up--in some JRE  
configurations, the driver class needs to be initialized explicitly to  
work.

I don't understand all the subtleties of class loading, but I gather  
from previous discussions here that it's good practice for Clojure to  
provide a class loader and for Clojure code to use it in the absence  
of a compelling reason not to. Use of Class.forName directly is (at  
least mildly) discouraged.

To address both of those concerns, classForName-initialize.patch  
(uploaded to the group and in-line below) changes RT.java to expose an  
optional "initialize" flag for RT/classForName.

After the change, existing calls to RT/classForName will work as they  
always have, but callers that need to ensure the class is initialized  
are now able to.

--Steve

Index: src/jvm/clojure/lang/RT.java
===================================================================
--- src/jvm/clojure/lang/RT.java        (revision 1080)
+++ src/jvm/clojure/lang/RT.java        (working copy)
@@ -1510,10 +1510,15 @@

  static public Class classForName(String name) throws  
ClassNotFoundException{

-       return Class.forName(name, false, baseLoader());
+       return classForName(name, false);
  }

+static public Class classForName(String name, boolean initialize)  
throws ClassNotFoundException{

+       return Class.forName(name, initialize, baseLoader());
+}
+
+
  static public float aget(float[] xs, int i){
        return xs[i];
  }


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to