Skip to content

Conversation

mehmet-karaman
Copy link
Contributor

@mehmet-karaman mehmet-karaman commented Oct 13, 2025

@mehmet-karaman
Copy link
Contributor Author

@laeubi @iloveeclipse this is the first split of the original PR.

@iloveeclipse
Copy link
Member

Mehmet, please don't hesitate to link to original tickets or PR's. It is always an extra work to find out what is related.
In current case: original PR is #3397

Copy link
Contributor

@laeubi laeubi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I miss a reasoning why we can change the API contract of these methods, it looks like a API breaking change.

Also commit message should clearly state that e.g.

Require non null LockObject in IAnnotationMap

- describe the reasoning here -

this is obviously not a cleanup / javadoc only thing!

Copy link
Contributor

github-actions bot commented Oct 13, 2025

Test Results

 3 018 files  ±0   3 018 suites  ±0   2h 25m 11s ⏱️ - 13m 48s
 8 226 tests ±0   7 977 ✅ +1  249 💤 ±0  0 ❌  - 1 
23 598 runs  ±0  22 804 ✅ +1  794 💤 ±0  0 ❌  - 1 

Results for commit 67ea81a. ± Comparison against base commit c521dfc.

♻️ This comment has been updated with latest results.

@mehmet-karaman mehmet-karaman force-pushed the code_cleanup_and_javadoc_adjustment branch from 88572d3 to 82ccd1e Compare October 13, 2025 11:20
@laeubi
Copy link
Contributor

laeubi commented Oct 13, 2025

In general I'm not sure it pays of to change anything here. Even if I can see that removing some dead code might be a good thing I wonder if it is worth the hassle here if it is "really dead".

In contrast we introduce some asymmetry here to other places that use the ISycnronizer API... so I'm not totally against this but would propose to simply leave it as is.

@iloveeclipse
Copy link
Member

The point is: for the reader of the IAnnotationModel & AnnotationModel API's it is not clear at all what happens here. Why there is one piece of code checking lock for null andthe rest of the code not, when the ISynchronizable.getLockObject() explicitly says it can be null. Is all the code buggy? Surely not, something seem to work somehow. Can the new code rely on lock being not null or not? No idea.

So this PR clarifies that mess and helps the reader of next one (#3397) to assume we are always working with non null lock object.

@iloveeclipse
Copy link
Member

I'm not totally against this but would propose to simply leave it as is.

Is there anything in this PRT to be changed? If yes, please point which exact changes are needed so we can continue.

Otherwise remove the negative review, because from our understanding this PR makes sense in the context of the next one.

@laeubi
Copy link
Contributor

laeubi commented Oct 13, 2025

he point is: for the reader of the IAnnotationModel & AnnotationModel API's it is not clear at all what happens here. Why there is one piece of code checking lock for null andthe rest of the code not

This is I think what is mainly a confusing of different levels of code and it is claimed without a proof.

e.g. I have checked that all public access to IAnnotationModel is doing proper null checks... AnnotationModel is not API and do not do null checks because its implementation ensures null is never returned.

This is completely common way and I do not see why implementation details need to show up in the public API ... so this is my primary concern.

@iloveeclipse
Copy link
Member

AnnotationModel is not API

Why that?

@mickaelistria
Copy link
Contributor

mickaelistria commented Oct 13, 2025

AnnotationModel is not API

Why that?

It's package-visible only.

@iloveeclipse
Copy link
Member

AnnotationModel is not API

Why that?

It's package-visible only.

public class AnnotationModel

@mickaelistria
Copy link
Contributor

My bad, I had (mis)read AnnotationMap...

@iloveeclipse
Copy link
Member

This is I think what is mainly a confusing of different levels of code and it is claimed without a proof.

The proof is the current code in the AnnotationModel class that dereferences the "possible null" lock objects 10 times out of 11 without null check.

e.g. I have checked that all public access to IAnnotationModel is doing proper null checks...

You have most likely checked ISynchronizable.getLockObject() callers, not AnnotationModel.getLockObject() callers.
This calls aren't doing null checks:

org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitDocumentProvider.CompilationUnitAnnotationModel.addAnnotation(Annotation, Position, boolean)
org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitDocumentProvider.CompilationUnitAnnotationModel.getJavaMarkerAnnotations(Position)
org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitDocumentProvider.CompilationUnitAnnotationModel.internalBeginReporting(boolean)
org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitDocumentProvider.CompilationUnitAnnotationModel.internalEndReporting(ProblemRequestorState)
org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitDocumentProvider.CompilationUnitAnnotationModel.removeAllAnnotations(boolean)
org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitDocumentProvider.CompilationUnitAnnotationModel.removeAnnotation(Annotation, boolean)
org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitDocumentProvider.CompilationUnitAnnotationModel.reportProblems(List<IProblem>)
org.eclipse.pde.internal.ui.editor.text.XMLReconcilingStrategy.SpellingProblemCollector.endCollecting()
org.eclipse.ui.texteditor.spelling.SpellingReconcileStrategy.SpellingProblemCollector.endCollecting()
org.eclipse.cdt.internal.ui.editor.CDocumentProvider.TranslationUnitAnnotationModel.addAnnotation(Annotation, Position, boolean)
org.eclipse.cdt.dsf.debug.internal.ui.disassembly.model.BreakpointsAnnotationModel.breakpointChanged(IBreakpoint, IMarkerDelta)
org.eclipse.cdt.internal.ui.editor.CDocumentProvider.TranslationUnitAnnotationModel.getAnnotations(Position)
org.eclipse.cdt.internal.ui.editor.CDocumentProvider.TranslationUnitAnnotationModel.internalBeginReporting(boolean)
org.eclipse.cdt.internal.ui.editor.CDocumentProvider.TranslationUnitAnnotationModel.internalEndReporting(ProblemRequestorState)
org.eclipse.xtext.ui.editor.quickfix.XtextResourceMarkerAnnotationModel.queueAnnotationChanged(Annotation)
org.eclipse.cdt.internal.ui.editor.CDocumentProvider.TranslationUnitAnnotationModel.removeAllAnnotations(boolean)
org.eclipse.cdt.internal.ui.editor.CDocumentProvider.TranslationUnitAnnotationModel.removeAnnotation(Annotation, boolean)
org.eclipse.cdt.internal.ui.editor.CDocumentProvider.TranslationUnitAnnotationModel.reportProblems(List<IProblem>)

AnnotationModel is not API and do not do null checks because its implementation ensures null is never returned.

It is API and it should do null checks on IAnnotationMap getAnnotationMap() return value because it could be overridden, but it never did.

OK, I will push a PR update that will:

  1. log warning instead of assert
  2. Improve javadoc of the IAnnotationModel.getLockObject() method to mention that changing the lock object after setting it is not expected and mght lead to synchronization problems
  3. Add javadoc to AnnotationModel.getLockObject() and AnnotationModel.setLockObject() methods matching the javadoc of IAnnotationModel.getLockObject().
  4. Rebase on master
  5. Update commit message

@iloveeclipse iloveeclipse force-pushed the code_cleanup_and_javadoc_adjustment branch from 82ccd1e to 8050bb4 Compare October 14, 2025 13:10
@iloveeclipse
Copy link
Member

@laeubi , @mickaelistria : could you please re-review?

@iloveeclipse
Copy link
Member

@laeubi , @mickaelistria : could you please re-review?

Ping.

Copy link
Contributor

@laeubi laeubi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Give the limited scope of this it looks "safe" to do, I added some style comments that might or might not be considered.

- Clarified contract of IAnnotationMap.getLockObject() and
setLockObject().
- Clarified contract of AnnotationModel.getLockObject() and
setLockObject().
- Added warning in AnnotationMap.setLockObject() if the lock is changed
- Removed dead code in AnnotationModel.cleanup because mapLock can't be
null.

Co-authored-by: Andrey Loskutov <[email protected]>
@iloveeclipse iloveeclipse force-pushed the code_cleanup_and_javadoc_adjustment branch from 8050bb4 to 67ea81a Compare October 16, 2025 15:30
@iloveeclipse iloveeclipse merged commit 4f771f0 into eclipse-platform:master Oct 16, 2025
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants