Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Java Model Status "Invalid name specified" exception - Possible bug
Java Model Status "Invalid name specified" exception - Possible bug [message #695939] Tue, 12 July 2011 21:47 Go to next message
john doe is currently offline john doeFriend
Messages: 74
Registered: June 2011
Member
Hi there.

I have the following piece of code:

try {
	for (IPackageFragmentRoot root : project.getPackageFragmentRoots()) {
		if (root.getElementName().equals("src")) {
			for (ICompilationUnit unit : root.getPackageFragment("soap.service.implementation.strongProfile.delegate").getCompilationUnits()) {
				for (IImportDeclaration dec : unit.getImports()) {
					dec.rename("soap.service.implementation.reader.HeadlineReader", true, null);
				}
			}
		}
	}
}catch(Exception e) {
	e.printStackTrace();
}


For some strange reason, I keep getting the following exception

Java Model Exception: Java Model Status [Invalid name specified: soap.service.implementation.reader.HeadlineReader]


I actually take the import from the exception that is printed out in the console and paste it into my class and it works fine. Is this an Eclipse bug?! Is there another way that I can rename an import in an ICompilation unit? Please help. thanks

[Updated on: Wed, 13 July 2011 21:05]

Report message to a moderator

Re: Java Model Status "Invalid name specified" exception [message #696043 is a reply to message #695939] Wed, 13 July 2011 07:11 Go to previous messageGo to next message
Satyam Kandula is currently offline Satyam KandulaFriend
Messages: 444
Registered: July 2009
Senior Member
There seems to be some problem. Please open a bug at https://bugs.eclipse.org/bugs/enter_bug.cgi?product=JDT;component=Core.
You could actually use ImportRewrite class to modify the imports.
Re: Java Model Status "Invalid name specified" exception [message #696117 is a reply to message #696043] Wed, 13 July 2011 09:56 Go to previous messageGo to next message
john doe is currently offline john doeFriend
Messages: 74
Registered: June 2011
Member
Will this work for my java project? Isn't ImportRewrite part of the javascript development toolkit, not JDT Core?

[Updated on: Wed, 13 July 2011 09:58]

Report message to a moderator

Re: Java Model Status "Invalid name specified" exception [message #696137 is a reply to message #696043] Wed, 13 July 2011 10:16 Go to previous messageGo to next message
Dani Megert is currently offline Dani MegertFriend
Messages: 3802
Registered: July 2009
Senior Member
On 13.07.2011 09:11, Satyam Kandula wrote:
> There seems to be some problem. Please open a bug at
> https://bugs.eclipse.org/bugs/enter_bug.cgi?product=JDT;component=Core.
https://bugs.eclipse.org/351940

Dani
> You could actually use ImportRewrite class to modify the imports.
Re: Java Model Status "Invalid name specified" exception [message #696393 is a reply to message #696137] Wed, 13 July 2011 21:05 Go to previous messageGo to next message
john doe is currently offline john doeFriend
Messages: 74
Registered: June 2011
Member
@Dani Thanks for that Smile To get around the issue, I delete the import and then recreate it with the new name.

[Updated on: Wed, 13 July 2011 21:05]

Report message to a moderator

Re: Java Model Status "Invalid name specified" exception [message #696544 is a reply to message #696117] Thu, 14 July 2011 09:05 Go to previous messageGo to next message
Satyam Kandula is currently offline Satyam KandulaFriend
Messages: 444
Registered: July 2009
Senior Member
ImportRewrite exists for JDT/Core.
Re: Java Model Status "Invalid name specified" exception [message #698551 is a reply to message #696544] Tue, 19 July 2011 17:00 Go to previous messageGo to next message
secretstowinbackgirlfriend is currently offline secretstowinbackgirlfriendFriend
Messages: 1
Registered: July 2011
Junior Member
But how do you use it to modify the imports?
Re: Java Model Status "Invalid name specified" exception [message #698716 is a reply to message #698551] Wed, 20 July 2011 04:48 Go to previous message
Satyam Kandula is currently offline Satyam KandulaFriend
Messages: 444
Registered: July 2009
Senior Member
ASTRewrite class's javadoc has an example.
Previous Topic:Debugging a remote Java application with Eclipse as the server (Socket listen)
Next Topic:Autocomplete function return value
Goto Forum:
  


Current Time: Tue Mar 19 05:31:04 GMT 2024

Powered by FUDForum. Page generated in 0.02452 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top