use of org.datanucleus.enhancer.EnhancerClassChecker in project datanucleus-core by datanucleus.
the class ClassEnhancerImpl method checkClassIsEnhanced.
/**
* Convenience method to return if a class is enhanced.
* @param logErrors Whether to log any errors (missing methods etc) as errors (otherwise info/debug)
* @return Whether the class is enhanced
*/
protected boolean checkClassIsEnhanced(boolean logErrors) {
try {
// Create an adapter using a writer
EnhancerClassChecker checker = new EnhancerClassChecker(this, logErrors);
InputStream classReaderInputStream = null;
try {
// Create a reader for the class and visit it using the checker
ClassReader cr = null;
if (inputBytes != null) {
cr = new ClassReader(inputBytes);
} else {
classReaderInputStream = clr.getResource(inputResourceName, null).openStream();
cr = new ClassReader(classReaderInputStream);
}
// [ASM Note : In 2.2 this should be "cr.accept(checker, false);"]
cr.accept(checker, 0);
} finally {
if (classReaderInputStream != null) {
classReaderInputStream.close();
}
}
return checker.isEnhanced();
} catch (Exception e) {
DataNucleusEnhancer.LOGGER.error("Error thrown enhancing with ASMClassEnhancer", e);
}
return false;
}
Aggregations