ClassDescriptor ReflectionUtils ClassLoader Defect
--------------------------------------------------
Key: JCR-1858
URL: https://issues.apache.org/jira/browse/JCR-1858
Project: Jackrabbit
Issue Type: Bug
Components: jackrabbit-ocm
Affects Versions: 1.4
Environment: JVM 1.6.0.6/Windows XP SP2/Netbeans 6.2 Beta
Reporter: V. W.
I have stumbuled on a bug in the interaction between ClassDescriptor and
ReflectionUtils classes:
1. ClassDescriptor.validateClassName() uses ReflectionUtils.forName(String) to
resolve an annotated class by its name
2. ReflectionUtils is an evil stateful statics-based singleton. It has a field
of a ClassLoader, which by default is the one that loaded the ReflectionUtils.
The method forName(String) uses this ClassLoader to resolve the annotated class.
The problem is that the ClassDescriptor assumses that the annotated class comes
from a global ClassLoader (the one that loaded the jars), which is not always
correct. The workaround is to manually set the ReflectionUtils ClassLoader
field for it to use the correct ClassLoader.
I've found this bug while working with NetBeans, writing a small Scala
application and using ScalaTest TestNG integration for testing. Apparantly many
ClassLoader need to by involved to run a single test.
I've created a unit test (java only, libraries included) to reproduce the bug.
The best solution would be for the ClassDescriptor to use a Class reference
(the Class contains its ClassLoader reference) instead of just a class-name or
at least pair every class-name with its ClassLoader.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.