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 132799 - Problem with hash codes and equals in in javabeans
Summary: Problem with hash codes and equals in in javabeans
Status: NEW
Alias: None
Product: ide
Classification: Unclassified
Component: Schema2Beans (show other bugs)
Version: 6.x
Hardware: All All
: P2 blocker (vote)
Assignee: schema2beans-issues@ide
Depends on:
Reported: 2008-04-14 17:58 UTC by scanti
Modified: 2008-12-10 11:04 UTC (History)
0 users

See Also:
Exception Reporter:


Note You need to log in before you can comment on or make changes to this bug.
Description scanti 2008-04-14 17:58:05 UTC
I am using the beans generated by schema2Beans as keys in Children.Keys.
When I used BaseBeans I had no problem, but using javabeans I have got this exception after adding/removing some elements:

java.lang.IllegalStateException: Error in com.streamsim.multigeomodelproject.xmlmultiview.ui.nodes.GeomodelNode$a with
entry Children.Keys.KE[<intervalList>
	<interval name='interval_1' bottom='4' top='1'>
		<faciesDescrip,0] from among [Children.Keys.KE[<intervalList>
	<interval name='interval_1' bottom='4' top='1'>
		<faciesDescrip,0], Children.Array.AE[]] in {Children.Array.AE[]=Children.Info[Children.Array.AE[],length=0],
	<interval name='interval_1' bottom='4' top='1'>
	<interval name='interval_1' bottom='4' top='1'>
		<faciesDescrip,0],length=1]} probably caused by faulty key implementation. The key hashCode() and equals() methods
must behave as for an IMMUTABLE object and the hashCode() must return the same value for equals() keys.
	at org.openide.nodes.Children.checkInfo(
	at org.openide.nodes.Children.updateOrder(
	at org.openide.nodes.Children.setEntries(
	at org.openide.nodes.Children$Keys$
	at org.openide.util.Mutex.postRequest(
	at org.openide.util.Mutex.postWriteRequest(
	at org.openide.nodes.Children$Keys.applyKeys(
	at org.openide.nodes.Children$Keys.setKeys(

In order to fix this I had to wrap beans with other objects, but I do not think that is the best solution.
Comment 1 Erno Mononen 2008-04-15 12:31:19 UTC
Doesn't affect the IDE itself, so adding the NO61 keyword.
Comment 2 Erno Mononen 2008-04-15 15:04:34 UTC
I don't think this use case is supported, the objects generated by s2b are mutable and therefore the generated equals 
and hashcode don't behave as for an immutable object. You can always override the generated equals / hashCode for your 
beans using the user code section in the extra info file. Changing to enhancement for now.
Comment 3 scanti 2008-04-15 15:30:45 UTC
yes, but it used to work when I generated baseBeans