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 74372 - IllegalStateException after changing annotation attribute value
Summary: IllegalStateException after changing annotation attribute value
Status: RESOLVED INVALID
Alias: None
Product: java
Classification: Unclassified
Component: Unsupported (show other bugs)
Version: 5.x
Hardware: All Windows XP
: P2 blocker (vote)
Assignee: issues@java
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-04-04 12:56 UTC by Erno Mononen
Modified: 2007-09-26 09:14 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
stacktrace (2.20 KB, text/plain)
2006-04-04 12:56 UTC, Erno Mononen
Details
Customer.java (836 bytes, text/plain)
2006-04-04 12:57 UTC, Erno Mononen
Details
Order.java (779 bytes, text/plain)
2006-04-04 12:57 UTC, Erno Mononen
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Erno Mononen 2006-04-04 12:56:11 UTC
I'm developing refactoring support for entity annotations and have run into 
following problem: I'm trying to change the value of an annotation attribute 
value, i.e. say I have an annotation @OneToMany(mappedBy="property") and I want 
to change the value from "property" to something else. I use following code for 
that:

To obtain a new StringLiteral:
StringLiteral literal = ((JavaModelPackage) reference.getAnnotation
().refImmediatePackage()).getStringLiteral().createStringLiteral
("newPropertyName");

And then setting the value to apporiate attribute value:
attri.setValue(literal);

This is done inside of a write JMI transaction. The problems with this are:
1. It doesn't seem to actually change the value 
2. After setting the new value I start to get IllegalStateExceptions from 
MetadataElement.testResourceChange (see attached stacktrace)

Possibly the problem lies in my usage of the API, but I don't know what exactly 
could cause this. The code to demonstrate this problem is checked in the 
release55 branch (module j2ee/refactoring), actual setting is performed in the 
performExternalChange method in the EntityRenameRefactoringElement class (inner 
class of EntityRenameRefactoring). This refactoring is however currently 
disabled because of this issue, it may activated by enabling lines 159 and 160 
in J2EERenameRefactoringPlugin. Attached is also two java classes representing 
entities for reproducing this problem, renaming getCustomer method in 
Order.java should demonstrate the issues described above.
Comment 1 Erno Mononen 2006-04-04 12:56:55 UTC
Created attachment 29593 [details]
stacktrace
Comment 2 Erno Mononen 2006-04-04 12:57:26 UTC
Created attachment 29594 [details]
Customer.java
Comment 3 Erno Mononen 2006-04-04 12:57:52 UTC
Created attachment 29595 [details]
Order.java
Comment 4 Jan Becicka 2006-04-13 07:38:55 UTC
> actual setting is performed in the performExternalChange method
This is probably the problem. External changes are those changes, which are out
of JavaModel scope. But you do external change using JMI. This is probably
reason why you get ISE: model was modified.

Please don't use JMI inside external changes.
Comment 5 Erno Mononen 2006-04-13 10:02:21 UTC
Yes, that solved the issue - thanks for looking into this.
Comment 6 Quality Engineering 2007-09-20 11:59:33 UTC
Reorganization of java component