This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 28160 - Incorect anotation for java.io.IOException: invalid class format
Summary: Incorect anotation for java.io.IOException: invalid class format
Status: VERIFIED WORKSFORME
Alias: None
Product: java
Classification: Unclassified
Component: Unsupported (show other bugs)
Version: -S1S-
Hardware: All All
: P4 blocker (vote)
Assignee: issues@java
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-10-22 10:40 UTC by pzajac
Modified: 2005-06-16 10:18 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Suggested patch (731 bytes, patch)
2003-03-12 08:38 UTC, Svata Dedic
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description pzajac 2002-10-22 10:40:31 UTC
Exception has very short message. 
better is for example:
Invalid format of class "className".

And there is necessary to add anotation to
ErrorManager. 

java.io.IOException: invalid class format
        at
org.netbeans.modules.classfile.ClassFile.loadClassHeader(ClassFile.ja
va:158)
        at
org.netbeans.modules.classfile.ClassFile.load(ClassFile.java:144)
        at
org.netbeans.modules.classfile.ClassFile.<init>(ClassFile.java:107)
        at
org.netbeans.modules.clazz.ClassDataObject.loadClassFile(ClassDataObj
ect.java:267)
        at
org.netbeans.modules.clazz.ClassDataObject.getClassFile(ClassDataObje
ct.java:244)
        at
org.netbeans.modules.clazz.ClassDataObject.getSource(ClassDataObject.
java:187)
        at
org.netbeans.modules.editor.java.JCUpdater.isValidMountPoint(JCUpdate
r.java:324)
        at
org.netbeans.modules.editor.java.JCUpdater.inspectFolder(JCUpdater.ja
va:290)
        at
org.netbeans.modules.editor.java.JCUpdater.inspectFolder(JCUpdater.ja
va:283)
        at
org.netbeans.modules.editor.java.JCUpdater.inspectFolder(JCUpdater.ja
va:283)
        at
org.netbeans.modules.editor.java.JCUpdater.inspectFolder(JCUpdater.ja
va:283)
        at
org.netbeans.modules.editor.java.JCUpdater.inspectFolder(JCUpdater.ja
va:283)
        at
org.netbeans.modules.editor.java.JCUpdater.inspectFolder(JCUpdater.ja
va:283)
        at
org.netbeans.modules.editor.java.JCUpdater.processNode(JCUpdater.java
:223)
        at
org.netbeans.modules.editor.java.JCUpdater.run(JCUpdater.java:170)
Comment 1 Svata Dedic 2003-02-27 18:22:09 UTC
Reassigning to the Editor - that's where the exception is probably 
reported. Does it appear as "unexpected exception" dialog box, or is it 
some nicer message ? 
 
Comment 2 Martin Roskanin 2003-03-06 15:53:07 UTC
Svata,
what's wrong on calling getSource() on SourceCookie as it is done in
JCUpdater.isValidMountPoint method?
The method SC.getSource() doesn't declare it throws IOE.
Should the SourceCookie be checked somehow for validity?
Comment 3 Martin Roskanin 2003-03-11 15:22:02 UTC
IOException is lost in the ClassDataObject.getClassFile()...
Reassigning back to clazz module.
Comment 4 Svata Dedic 2003-03-12 07:53:18 UTC
Petr, which version/build is it ? Line numbers do not match sources on 
3.5 branch. 
Comment 5 Svata Dedic 2003-03-12 08:37:28 UTC
Petr -- this is only a message printed to the log file, isn't it ? There's a 
hardcoded printStackTrace in the classfile module; attaching 
suggested patch. 
Comment 6 Svata Dedic 2003-03-12 08:38:04 UTC
Created attachment 9366 [details]
Suggested patch
Comment 7 pzajac 2003-03-12 17:12:53 UTC
Swata I cannot reproduce it and a cannot remember to my invalid class
and build. After I saw to your patch you have right that the 
exception was printed to log file. But why you don't add to your code: 

} catch (IOException ioe) {
   Exception newExc = new Exception("invalid class");
   ErrorManager.getDefault().annotate(newExc,ioe);
   throw newExc;
} 
Comment 8 Svata Dedic 2003-03-12 17:17:03 UTC
Because the original code looked strange to me - one IOException
catched and another thrown -- I do not know why the original one was
not passed up. So I proposed only a minimal change.
Anyway, if the inner exception contains some useful data, your code is
definitely better.
Comment 9 _ tball 2003-03-12 20:00:28 UTC
I've removed the printStackTrace line from ClassFile.java, and will
commit it when I am back outside of Sun's firewall tonight. 

The reason the original exception isn't thrown is because the message
associated with it doesn't describe the real problem, which is that an
invalid class file/stream was passed to the library.  When 1.4 becomes
the minimum API, this can be changed to use its exception chaining.

Perhaps a ClassFormatError is a more accurate exception, but the
reason I don't throw a ClassFormatError is because that error is
unchecked.
Comment 10 _ tball 2004-07-03 20:25:25 UTC
I updated the exception message as you requested in ClassFile where
files or filenames are used.  However, the ClassDataObject is opening
the ClassFile using a stream, and so I don't have the original class
name to report in the exception message.  The clazz module therefore
needs to either catch the IOException and throw a new one with a
better error message, or annotation the exception.

Additionally, the classfile module is not really a module, but just a
library with no NetBeans dependencies; it has a module manifest just
to support the auto-update feature.  So any ErrorManager annotating
has to be done by its clients.

I don't currently have commit rights for the clazz module, but would
be happy to make the above changes to ClassDataObject if given that
privilege.
Comment 11 pzajac 2005-05-02 10:56:03 UTC
This issue is opened for long time and I cannot reproduce it. 
Comment 12 pzajac 2005-06-16 10:18:43 UTC
v