openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Pinaki Poddar" <>
Subject Usage of classloader for alias resolution to class during query expression and dynamically generated classes
Date Thu, 12 Jul 2007 03:20:55 GMT
Getting runtime metadata given an alias takes into account that same
alias may be used for more than one class. The particular method in
public ClassMetaData getMetaData(String alias, ClassLoader envLoader,
boolean mustExist) 
filters the list of classes registered for the given alias by attempting
to reload each class by the given envLoader. 

This filtering feature is causing an issue when I am using classes whose
bytecodes are generated dynamically. 
The classes were enhanced and had their aliases registered. The
instances of these dynamic classes can be persisted as well.

When a query is issued, JPQLExpressionBuilder.getClassMetaData() invokes
above MetaDataRepository.getMetaData() method with the classloader X
where X = JPQLExpressionBuilder.getClass().getClassLoader(). X can not
reload by name the dynamically generated class that had  been loaded by
a BCClassLoader from serp library. 

1: Is there a way to instruct the query to use a specifc classloader or

2: Comment in abstract method getClassLoader() in
AbstractExpressionBuilder says:
     * Returns the class loader that should be used for resolving
     * class names (in addition to the resolver in the query).
    protected abstract ClassLoader getClassLoader();

   JPQLExpressionBuilder's implementation
    protected ClassLoader getClassLoader() {
        // we don't resolve in the context of anything but ourselves
        return getClass().getClassLoader();
Is the implementation in synch with getClassLoader() contract as per
this JavaDoc? 
However, the comment suggests that there may exist a way to attach a
ClassResolver to a query.

Regards --

Pinaki Poddar

Notice:  This email message, together with any attachments, may contain information  of  BEA
Systems,  Inc.,  its subsidiaries  and  affiliated entities,  that may be confidential,  proprietary,
 copyrighted  and/or legally privileged, and is intended solely for the use of the individual
or entity named in this message. If you are not the intended recipient, and have received
this message in error, please immediately return this by email and then delete it.
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message