Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-6384

Change all calls to Class.forName to direct dispatch so that differences around classloading between Groovy and Java are resolved

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.1.7
    • 2.1.8, 2.2.0-rc-1
    • None
    • None

    Description

      See issue http://jira.grails.org/browse/GRAILS-10562

      Currently in Groovy if you do Class.forName("..") for dynamic dispatch the classloader for the calling class is not used. This completely breaks the semantics of the method as described in the javadoc http://docs.oracle.com/javase/7/docs/api/java/lang/Class.html#forName(java.lang.String)

      Given that monkey patching Class.forName("..") is an unbelievably bad idea and the behavior should be the same as Java the recommendation is that all calls to Class.forName("..") are made directly. This has a number of benefits including:

      • Same semantics as the original Java method
      • Improved performance
      • Fewer long explanation as to why this method is broken to users

      Attachments

        Activity

          People

            blackdrag Jochen Theodorou
            graemerocher Graeme Rocher
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: