openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ss...@apache.org
Subject svn commit: r680451 - in /openjpa/branches/0.9.7-r547073: openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/ClassAnnotationMetaDataFilter.java openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceMetaDataFactory.java
Date Mon, 28 Jul 2008 19:23:03 GMT
Author: ssegu
Date: Mon Jul 28 12:23:03 2008
New Revision: 680451

URL: http://svn.apache.org/viewvc?rev=680451&view=rev
Log:
OPENJPA-385. To properly skip and optionally log malformed .class files.(Merge back into branch
from trunk)

Modified:
    openjpa/branches/0.9.7-r547073/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/ClassAnnotationMetaDataFilter.java
    openjpa/branches/0.9.7-r547073/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceMetaDataFactory.java

Modified: openjpa/branches/0.9.7-r547073/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/ClassAnnotationMetaDataFilter.java
URL: http://svn.apache.org/viewvc/openjpa/branches/0.9.7-r547073/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/ClassAnnotationMetaDataFilter.java?rev=680451&r1=680450&r2=680451&view=diff
==============================================================================
--- openjpa/branches/0.9.7-r547073/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/ClassAnnotationMetaDataFilter.java
(original)
+++ openjpa/branches/0.9.7-r547073/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/ClassAnnotationMetaDataFilter.java
Mon Jul 28 12:23:03 2008
@@ -20,6 +20,9 @@
 
 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 @@
 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 @@
                 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 @@
         }
         return skipped;
     }
+
+    public Log getLog() {
+        return _log;
+    }
+
+    public void setLog(Log _log) {
+        this._log = _log;
+    }
 }

Modified: openjpa/branches/0.9.7-r547073/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceMetaDataFactory.java
URL: http://svn.apache.org/viewvc/openjpa/branches/0.9.7-r547073/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceMetaDataFactory.java?rev=680451&r1=680450&r2=680451&view=diff
==============================================================================
--- openjpa/branches/0.9.7-r547073/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceMetaDataFactory.java
(original)
+++ openjpa/branches/0.9.7-r547073/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceMetaDataFactory.java
Mon Jul 28 12:23:03 2008
@@ -349,8 +349,11 @@
 
     @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;
     }
 
     /**



Mime
View raw message