Replace Cass.forName uses by ClassLoader.loadClass
--------------------------------------------------
Key: SLING-1891
URL: https://issues.apache.org/jira/browse/SLING-1891
Project: Sling
Issue Type: Bug
Components: Extensions, JCR, Launchpad, Scripting
Affects Versions: Extensions Event 2.4.2, JCR Resource 2.0.6, Launchpad
Base 2.2.0, Scripting API 2.1.0, Scripting JavaScript 2.0.8, Scripting JSP
2.0.10
Reporter: Felix Meschberger
Fix For: Scripting JSP 2.0.12, Scripting JavaScript 2.0.10,
Scripting API 2.1.2, Launchpad Base 2.2.2, JCR Resource 2.0.8, Extensions Event
3.0.0
Class.forName has a nasty problem in that it caches returned classes in the
class load first asked (the initiator) in addition to the class loader actually
defining the class. The ClassLoader.loadClass methods do not have this problem
and only caches the loaded class in the defining class loader.
Looking for uses in the Sling code base (using find . -name "*.java" -exec
fgrep -l Class.forName {} \;) I found the following nice occurrences:
launchpad/base/src/main/java/org/apache/sling/launchpad/base/impl/Sling.java
bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/jcr/JCRHelper.java
bundles/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/wrapper/ScriptableResource.java
bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/JspUtil.java
bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/TagPluginManager.java
bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/JspCompilationContext.java
bundles/scripting/api/src/main/java/sun/misc/Service.java
bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/JcrPropertyMap.java
contrib/explorers/gwt/src/main/java/org/apache/sling/explorer/client/widgets/tree/resource/ResourceTree.java
For more information on this problem, I suggest reading the blog series by BJ
Hargrave, probably starting with
http://blog.bjhargrave.com/2007/09/classforname-caches-defined-class-in.html.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.