OPENJPA-385. Committing changes for both 1.0.x and 1.1.0 to properly skip and optionally log malformed .class files.

git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@580087 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Kevin W. Sutter 2007-09-27 16:36:48 +00:00
parent 12840cafbf
commit 6f43ce7d40
2 changed files with 28 additions and 3 deletions

View File

@ -20,6 +20,9 @@ package org.apache.openjpa.lib.meta;
import java.io.IOException;
import org.apache.openjpa.lib.log.Log;
import org.apache.openjpa.lib.util.Localizer;
import serp.bytecode.lowlevel.ConstantPoolTable;
/**
@ -33,6 +36,10 @@ import serp.bytecode.lowlevel.ConstantPoolTable;
public class ClassAnnotationMetaDataFilter implements MetaDataFilter {
private final String[] _annos;
private static final Localizer _loc = Localizer.forPackage
(ClassAnnotationMetaDataFilter.class);
private Log _log = null;
/**
* Constructor; supply annotation to match against.
@ -86,9 +93,16 @@ public class ClassAnnotationMetaDataFilter implements MetaDataFilter {
idx += 4 + table.readInt(idx);
}
} catch (ArrayIndexOutOfBoundsException e) {
/*
* This ArrayIndexOutOfBoundsException indicates an incorrectly
* formed .class file. We will eat the exception, log a trace
* message (if a log exists), and return "false" to indicate there
* was no match.
*/
Error cfe = new ClassFormatError(rsrc.getName());
cfe.initCause(e);
throw cfe;
if (_log != null && _log.isTraceEnabled())
_log.trace(_loc.get("class-arg", rsrc.getName()), cfe);
}
return false;
}
@ -184,4 +198,12 @@ public class ClassAnnotationMetaDataFilter implements MetaDataFilter {
}
return skipped;
}
public Log getLog() {
return _log;
}
public void setLog(Log _log) {
this._log = _log;
}
}

View File

@ -374,8 +374,11 @@ public class PersistenceMetaDataFactory
@Override
protected MetaDataFilter newMetaDataFilter() {
return new ClassAnnotationMetaDataFilter(new Class[]{
Entity.class, Embeddable.class, MappedSuperclass.class });
ClassAnnotationMetaDataFilter camdf = new ClassAnnotationMetaDataFilter(
new Class[] { Entity.class, Embeddable.class,
MappedSuperclass.class });
camdf.setLog(log);
return camdf;
}
/**