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.
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.
Created attachment 29593 [details] stacktrace
Created attachment 29594 [details] Customer.java
Created attachment 29595 [details] Order.java
> 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.
Yes, that solved the issue - thanks for looking into this.
Reorganization of java component