Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » IClasspathContainer.getClasspathEntries() gets called multiple times
IClasspathContainer.getClasspathEntries() gets called multiple times [message #1803830] Tue, 12 March 2019 00:40 Go to next message
Alex Kravets is currently offline Alex KravetsFriend
Messages: 561
Registered: November 2009
Senior Member
I've implemented IClasspathContainer and see that getClasspathEntries() gets called at least 10 times during creation of the project. JavaDoc for the method says
Quote:

The method is typically called exactly once for a given Java project, and the resulting list of entries cached internally by the Java model.

What I am seeing is that JavaProject.resolveClasspath() is being called every times getClasspathEntries() is called, and classpath entries get re-resolved every time with no caching that I can see. Any ideas what am I doing wrong?
Re: IClasspathContainer.getClasspathEntries() gets called multiple times [message #1803832 is a reply to message #1803830] Tue, 12 March 2019 02:22 Go to previous messageGo to next message
Eclipse UserFriend
Put a breakpoint and take a look at the stack trace: there may be some other plugin that's changing or updating the classpath somehow, which may trigger a refresh.

Brian.
Re: IClasspathContainer.getClasspathEntries() gets called multiple times [message #1803847 is a reply to message #1803832] Tue, 12 March 2019 12:13 Go to previous messageGo to next message
Alex Kravets is currently offline Alex KravetsFriend
Messages: 561
Registered: November 2009
Senior Member
Thanks Brian,

The classpath container is added during project creation. Code that does this is:

	ApplicationClasspathContainer appClasspathContainer;
		try {
			appClasspathContainer = new ApplicationClasspathContainer(javaProject);
			IPath appClasspathContainerPath = appClasspathContainer.getPath();
			
			IClasspathEntry appEntry = JavaCore.newContainerEntry(appClasspathContainerPath, true);
			
			JavaCore.setClasspathContainer(	appClasspathContainerPath,  
					new IJavaProject[]{javaProject }, 
					new IClasspathContainer[] {appClasspathContainer}, 
					monitor);
			classpathEntries.add(appEntry);
		} catch (CoreException | XmlException | IOException e) {
			Activator.getDefault().logError(e.getLocalizedMessage(), e);
		}
		javaProject.setRawClasspath((IClasspathEntry [])classpathEntries.toArray(new IClasspathEntry[classpathEntries.size()]), monitor);


If I comment out javaProject.setRawClasspath... line then IClasspathContainer.getClasspathEntries() is called exactly once, but container is not added of course, otherwise as 10+ times.

I tried debugging the call chain and it seems that JavaProject.resolveClasspath() gets called during calls to workspace refresh and different workspace modification operations.

[Updated on: Tue, 12 March 2019 13:13]

Report message to a moderator

Re: IClasspathContainer.getClasspathEntries() gets called multiple times [message #1803875 is a reply to message #1803847] Tue, 12 March 2019 21:32 Go to previous message
Alex Kravets is currently offline Alex KravetsFriend
Messages: 561
Registered: November 2009
Senior Member
Brian,

I debugged JREContainer and see the same behavior as in my case - JavaProject.resolveClasspath() is being called numerous times when Java project is created.
Previous Topic:Content assist: Disable "No Default Proposals"-Message
Next Topic:Java Virtual machine error
Goto Forum:
  


Current Time: Thu Sep 26 19:55:57 GMT 2024

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

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

Back to the top