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.
Summary: | Visual editing fails and corrupts the code if constractor or property get method throws an Exception | ||
---|---|---|---|
Product: | guibuilder | Reporter: | greenbee <greenbee> |
Component: | Code | Assignee: | issues@guibuilder <issues> |
Status: | RESOLVED WORKSFORME | ||
Severity: | blocker | ||
Priority: | P3 | ||
Version: | -S1S- | ||
Hardware: | PC | ||
OS: | Windows 3.1/NT | ||
Issue Type: | DEFECT | Exception Reporter: | |
Attachments: |
Form file for the test case
Code for the test case second form file for the test case second java file |
Description
greenbee
2003-04-11 00:41:30 UTC
Created attachment 9855 [details]
Form file for the test case
Created attachment 9856 [details]
Code for the test case
Created attachment 9857 [details]
second form file for the test case
Created attachment 9858 [details]
second java file
Could you please try to reproduce it in the NB3.5. I am not able to reproduce this issue in the last NB3.5 Beta build - decreasing the priority to P3 for now. Reassign to responsible developer. > In general I do not understand why IDE should instantiate
> a class or invoke a method during the graphic design.
How do you expect the IDE can show you something in the designer if it
can't create an instance? The IDE works that way it tries to
instantiate exactly the components you give it so the design
corresponds to real application as much as possible. So the IDE *must*
create instances of your classes and call their methods. Throwing
exceptions from constructor or property getter methods violates the
JavaBeans spec. What do you suppose the IDE can do if you add a
component to the designed form, but the component cannot be
instantiated due to an exception? The only thing the IDE can do is to
notify you about the problem: the instance cannot be created. It's
generally bad design of the component in such case, not the IDE.
But I agree it definitely should not corrupt generated code or break
integrity of internal metadata (so making the whole form editor
unusable). That's what this bug report is about: the IDE must be
robust enough and handle exceptions from user components well.
I see you report this against S1S 4.1, that's based on NetBeans 3.3.x.
I think the problem with reporting and robustness are solved now
(NetBeans 3.5) - at least I don't see any problem with the attached
sample - the instantiation error is correctly reported. Could you
verify it? (You can download NetBeans 3.5 Beta at this time; or wait
for S1S 5 release alternatively too.)
Note: if you need your component(s) to behave that way (potentially
throwing exceptions) and it is not possible to set up correct
environment during graphics design (so the exceptions are unavoidable)
- and you still want to be able to use the components in the designer
- then you should make your components behave different when they are
used in designer environment. You can check the "design time" using
java.beans.Beans.isDesignTime() method, or by implementing
java.beans.DesignMode.
As for getXXXList(), it is recognized as a property automatically by
java.beans.Introspector. The IDE just tries to get value of each
property, so that's why the method is called. If you don't want the
method to be recognized as property, then write your own BeanInfo
class specifying exactly those properties that are relevant (writing
BeanInfo is always recommended). That's the standard JavaBeans' way...
I think NetBeans 3.5 reports the exceptions correctly (at least for the attached test case) and does not currupt code. I'm not 100% sure about the exception from getter method, but anyway, it just reveals problems in user component. I don't see what we could do more in NetBeans. |