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 5714 - JavaInstanceSupport is turned on while a classfile is still being written by the compiler.
Summary: JavaInstanceSupport is turned on while a classfile is still being written by ...
Status: CLOSED WONTFIX
Alias: None
Product: java
Classification: Unclassified
Component: Unsupported (show other bugs)
Version: 3.x
Hardware: All All
: P4 normal (vote)
Assignee: Svata Dedic
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2000-02-11 01:56 UTC by Jesse Glick
Modified: 2007-09-26 09:14 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jesse Glick 2000-02-11 01:56:34 UTC
I am not sure if this is even possible to fix:


From time to time in 481 IE, while compiling a source file, I get:

JavaInstanceSupport gets truncated classfiles sometimes:
java.lang.ClassNotFoundException: MyBean (Truncated class file)
        at com.netbeans.developer.modules.loaders.java.JavaDataObject$JavaInstanceSupport.findClass(JavaDataObject.java:7
        at com.netbeans.developer.modules.loaders.java.JavaDataObject$JavaInstanceSupport.instanceClass(JavaDataObject.ja
        at com.netbeans.developer.modules.apisupport.ShowAPIJavadocAction.findClass(ShowAPIJavadocAction.java:75)
        at com.netbeans.developer.modules.apisupport.ShowAPIJavadocAction.enable(ShowAPIJavadocAction.java:52)
        at org.openide.util.actions.CookieAction$CookiesChangeListener.propertyChange(CookieAction.java:236)
[snip]
        at com.netbeans.developer.modules.loaders.java.JavaDataObject.updateInstanceCookie(JavaDataObject.java:142)
        at com.netbeans.developer.modules.loaders.java.JavaDataObject$2.propertyChange(JavaDataObject.java:129)
        at org.openide.loaders.DataObject.firePropertyChange(DataObject.java:718)
[snip]

The problem is that while the class file is being compiled, the filesystem notices a new file, fires changes, data object notices it owns the file, JavaInstanceSupport decides that the class is now co
mpiled, and adds an InstanceCookie. APISupport then gets this cookie and tries to load the class--but the class file is only half-created, so loading it fails and throws this exception.

Is it possible to delay adding the InstanceCookie until the class is fully compiled? I think probably not...

See also #5582 for better steps to reproduce.

[jglick later] Note that ShowAPIJavadocAction will no longer use InstanceCookie this way, so you must reproduce some other way if you are still interested.
Comment 1 Svata Dedic 2001-02-21 08:32:41 UTC
Although the compiler can disable InstanceCookie on some classes during compiler execution, it's not possible to handle all files traversed by the (external) compiler this way. Clients of InstanceCookie should better catch the CNFE and either report a message to the user, or recover somehow.
Comment 2 Jesse Glick 2001-02-21 12:27:10 UTC
Understood that you cannot tell exactly when the external compiler is running,
nor on what. What about this: if a new classfile is recognized on disk and
reported as a new secondary entry, but its lastModified timestamp is very recent
(past second or so), don't add the instance cookie immediately--wait another
second or so, by which point it is likely the compiler will have finished
dealing with it.

But I doubt this bug really matters very much, so don't waste time on it.
Comment 3 Quality Engineering 2003-07-01 13:19:57 UTC
Resolved for 3.4.x or earlier, no new info since then -> closing.