|
[
Permlink
| « Hide
]
Kevin Sutter added a comment - 27/Jun/08 04:49 PM
File pmr.zip is a simplified version of the problem that I put together for the IBM JDK problem report. To reproduce the problem, you have to build a jar file for this project and run the testcase with the -javaagent parameter. Or, you could just point the javaagent at the OpenJPA runtime jar file and use the "real" TempClassLoader implementation. Either way, you should be able to reproduce the problem.
Kevin Sutter made changes - 27/Jun/08 04:49 PM
This hack of a patch just modifies our TempClassLoader implementation to treat enum class types like annotation class types and use the Class.forName() mechanism to load the class instead of the defineClass() mechanism. Until I get educated on what exactly is wrong with our current processing, I don't want to commit this change. But, in case someone runs into this situation, this is a potential workaround.
Kevin Sutter made changes - 27/Jun/08 04:52 PM
Michael Dick made changes - 30/Jul/08 04:20 PM
Kevin Sutter made changes - 31/Jul/08 10:39 PM
I accidentally opened a new Issue for this same problem (
From working with the JDK team, the problem is surfacing because the ClassLoader (AppClassLoader) that is used to load the Enum type when the alt.persistence.OneToMany is loaded is not the same ClassLoader (TemporaryClassLoader) when the Enum type is loaded by our enhancement processing. Thus, the AnnotationTypeMismatchExceptionProxy from the JDK. One way to workaround the problem is to add a test for Enum types in the TemporaryClassLoader and use the AppClassLoader in this case (much like we do for Annotation types): if (isAnnotation(classBytes) || isEnum(classBytes)) return Class.forName(name, resolve, getClass().getClassLoader()); The JDK team suggested removing the check for isAnnotation (and isEnum) altogether since that resolved the simple testcase that I had put together for their benefit. Unfortunately, that doesn't work for our enhancement processing for a couple of reasons. The _strats structure in PersistentMetaDataDefaults depended on the org.apache.openjpa.persistence.PersistentCollection class. By removing the conditional above, then we had a mismatch in classloaders for this data structure, much like the jdk problem. I tried changing the key for this _strats structure to use the class name string instead of the actual class instance. This got us around our immediate concern, but eventually I hit another JDK issue with mismatched classloaders when processing the annotations in AnnotationPersistentMetaDataParser: parsePersistentCollection(fmd, (PersistentCollection) el.getAnnotation(PersistentCollection.class)); The loading of this PersistentCollection.class used the AppClassLoader, so the lookup via getAnnotation didn't find anything since the original annotation was loaded by the TemporaryClassLoader. Trying to get around this situation was creating some pretty ugly code. So, I am leaning towards the original workaround as a "solution" with proper commenting. By allowing the AppClassLoader to load enum types (vs the TemporaryClassLoader), we would "pollute" the AppClassLoader with left over enum classes. This would seem to be a minor drawback. Of course, if we ever need to allow for the enhancement of enum classes, then we're up a creek... Enough detail for now. Comments and suggestions are welcome.
Resolved in the 1.2.x branch and 1.3.0 trunk.
Kevin Sutter made changes - 08/Sep/08 08:12 PM
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||