DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUGĀ·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=41795>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED ANDĀ·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=41795

           Summary: ClassParser throws unintelligible Exception
           Product: BCEL
           Version: unspecified
          Platform: Other
        OS/Version: other
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Main
        AssignedTo: bcel-dev@jakarta.apache.org
        ReportedBy: [EMAIL PROTECTED]


o.a.b.classfile.ClassParser throws two exceptions. One has the file_name
variable included but the one that only comes up when you have a corrupted class
file does not. When you have thousands and thousands of classes (counting all
the classes in dependent jars) in a large project, this can make it very
difficult to find the problem! 

One could in theory argue that the application using BCEL should report this,
but the canonical example of a file-related problem is FileNotFoundException
which does include the filename, for the same reason as I suggest the exception
thrown by ClassParser does. E.g., create new FileReader("/nosuchfile") and you 
get:

Exception in thread "main" java.io.FileNotFoundException: /nosuchfile (No such
file or directory)

A simple SVN patch against r516101  follows (bigger than it needs to be due to
Eclipse's auto-remove-excess-whitespace mode):

Index:
/home/ian/workspace/bcel/src/main/java/org/apache/bcel/classfile/ClassParser.java
===================================================================
---
/home/ian/workspace/bcel/src/main/java/org/apache/bcel/classfile/ClassParser.java
(revision 516101)
+++
/home/ian/workspace/bcel/src/main/java/org/apache/bcel/classfile/ClassParser.java
(working copy)
@@ -38,7 +38,7 @@
  * further details about the structure of a bytecode file.
  *
  * @version $Id$
- * @author <A HREF="mailto:[EMAIL PROTECTED]">M. Dahm</A> 
+ * @author <A HREF="mailto:[EMAIL PROTECTED]">M. Dahm</A>
  */
 public final class ClassParser {
 
@@ -206,7 +206,8 @@
         }
         if (((access_flags & Constants.ACC_ABSTRACT) != 0)
                 && ((access_flags & Constants.ACC_FINAL) != 0)) {
-            throw new ClassFormatException("Class can't be both final and
abstract");
+            throw new ClassFormatException(
+               "Class " + file_name + " can't be both final and abstract");
         }
         class_name_index = file.readUnsignedShort();
         superclass_name_index = file.readUnsignedShort();

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to