openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From awh...@apache.org
Subject svn commit: r430171 - /incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/ClassAnnotationMetaDataFilter.java
Date Wed, 09 Aug 2006 22:39:25 GMT
Author: awhite
Date: Wed Aug  9 15:39:24 2006
New Revision: 430171

URL: http://svn.apache.org/viewvc?rev=430171&view=rev
Log:
Give better error when run on bad .class file.


Modified:
    incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/ClassAnnotationMetaDataFilter.java

Modified: incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/ClassAnnotationMetaDataFilter.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/ClassAnnotationMetaDataFilter.java?rev=430171&r1=430170&r2=430171&view=diff
==============================================================================
--- incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/ClassAnnotationMetaDataFilter.java
(original)
+++ incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/ClassAnnotationMetaDataFilter.java
Wed Aug  9 15:39:24 2006
@@ -51,35 +51,39 @@
         if (_annos.length == 0 || !rsrc.getName().endsWith(".class"))
             return false;
 
-        ConstantPoolTable table = new ConstantPoolTable(rsrc.getContent());
-        int idx = table.getEndIndex();
-        idx += 6; // skip access, cls, super
+        try {
+            ConstantPoolTable table = new ConstantPoolTable(rsrc.getContent());
+            int idx = table.getEndIndex();
+            idx += 6; // skip access, cls, super
 
-        // skip interfaces
-        int interfaces = table.readUnsignedShort(idx);
-        idx += 2 + interfaces * 2;
+            // skip interfaces
+            int interfaces = table.readUnsignedShort(idx);
+            idx += 2 + interfaces * 2;
 
-        // skip fields and methods
-        int fields = table.readUnsignedShort(idx);
-        idx += 2;
-        for (int i = 0; i < fields; i++)
-            idx += skipFieldOrMethod(table, idx);
-        int methods = table.readUnsignedShort(idx);
-        idx += 2;
-        for (int i = 0; i < methods; i++)
-            idx += skipFieldOrMethod(table, idx);
+            // skip fields and methods
+            int fields = table.readUnsignedShort(idx);
+            idx += 2;
+            for (int i = 0; i < fields; i++)
+                idx += skipFieldOrMethod(table, idx);
+            int methods = table.readUnsignedShort(idx);
+            idx += 2;
+            for (int i = 0; i < methods; i++)
+                idx += skipFieldOrMethod(table, idx);
 
-        // look for annotation attrs
-        int attrs = table.readUnsignedShort(idx);
-        idx += 2;
-        int name;
-        for (int i = 0; i < attrs; i++) {
-            name = table.readUnsignedShort(idx);
+            // look for annotation attrs
+            int attrs = table.readUnsignedShort(idx);
             idx += 2;
-            if ("RuntimeVisibleAnnotations".equals(table.readString
-                (table.get(name))))
-                return matchAnnotations(table, idx + 4);
-            idx += 4 + table.readInt(idx);
+            int name;
+            for (int i = 0; i < attrs; i++) {
+                name = table.readUnsignedShort(idx);
+                idx += 2;
+                if ("RuntimeVisibleAnnotations".equals(table.readString
+                    (table.get(name))))
+                    return matchAnnotations(table, idx + 4);
+                idx += 4 + table.readInt(idx);
+            }
+        } catch (ArrayIndexOutOfBoundsException e) {
+            throw new ClassFormatError(rsrc.getName());
         }
         return false;
     }



Mime
View raw message