Bug 428858 - Rebuild after changes in project settings while editor is dirty results in weird errors.
Summary: Rebuild after changes in project settings while editor is dirty results in we...
Status: ASSIGNED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.4   Edit
Hardware: PC Windows 7
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2014-02-23 20:16 EST by Srikanth Sankaran CLA
Modified: 2023-02-18 13:01 EST (History)
2 users (show)

See Also:


Attachments
MarkerDelta after the build (51.01 KB, image/png)
2014-02-26 09:03 EST, Noopur Gupta CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Srikanth Sankaran CLA 2014-02-23 20:16:50 EST
See https://bugs.eclipse.org/bugs/show_bug.cgi?id=419829#c7 and
https://bugs.eclipse.org/bugs/show_bug.cgi?id=419829#c18 for details.

Please pass it back if JDT/Core has a hand somewhere. It would be nice to
have a fix soon, as this hits me fairly frequently as I often switch back and 
forth between project settings to study behavior in different levels.
Comment 1 Dani Megert CLA 2014-02-24 04:12:49 EST
Noopur, please investigate.
Comment 2 Noopur Gupta CLA 2014-02-26 05:10:16 EST
I can consistently reproduce the issue mentioned in https://bugs.eclipse.org/bugs/show_bug.cgi?id=419829#c18.
Comment 3 Noopur Gupta CLA 2014-02-26 06:35:15 EST
The issue exists in Eclipse 3.8.1 also, while changing the project JRE from 1.7 to 1.6 (as per the steps given in bug 419829 comment #18) with the following snippets:
---------------------------------------------------------
package com.bug;

import java.util.ArrayList;
import java.util.List;

public class CTest {
	List<String> l= new ArrayList<>();
}
---------------------------------------------------------
package com.bug;

import java.util.ArrayList;
import java.util.List;

public class CTest {
	void foo() {
		return "";
	}
}
---------------------------------------------------------

Looks like the rebuild happens on the last saved contents of the file and hence Problem view shows the error from snippet 1. The dirty editor shows error markers at incorrect locations, also showing the errors from old content.

Needs more investigation. It could be related to bug 423416 as mentioned by Markus in bug 419829 comment #15.
Comment 4 Dani Megert CLA 2014-02-26 06:48:51 EST
This smells like bug 65267.
Comment 5 Noopur Gupta CLA 2014-02-26 09:03:18 EST
Created attachment 240333 [details]
MarkerDelta after the build

On changing the Project's JRE system library, org.eclipse.core.internal.events.AutoBuildJob.doBuild(IProgressMonitor monitor) is called and the build is performed. 

Adding a breakpoint in org.eclipse.jdt.internal.ui.viewsupport.ProblemMarkerManager.resourceChanged(IResourceChangeEvent event) shows that after the above build, the ResourceDelta has MarkerDelta corresponding to the org.eclipse.jdt.core.problem - '<>' operator is not allowed for source level before 1.7 (See attached screenshot).

The above MarkerDelta corresponds to the old contents of the file.

Accordingly, ProblemMarkerManager.runPendingUpdates() notifies the ProblemLabelDecorator and JavaEditorErrorTickUpdater listeners.

ResourceDelta should not contain the MarkerDelta corresponding to the old contents of the file after the build.

Please suggest where should we investigate further.
Comment 6 Eclipse Genie CLA 2021-02-26 14:06:28 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 7 Eclipse Genie CLA 2023-02-18 13:01:33 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.