Skip to content

CompleteTypeBindingsSteps.INTEGRATE_ANNOTATIONS_IN_HIERARCHY violates TypeBinding's protocol by direct updation of fields in various places#4842

Open
srikanth-sankaran wants to merge 1 commit into
eclipse-jdt:masterfrom
srikanth-sankaran:typebinding-protocol-violations
Open

CompleteTypeBindingsSteps.INTEGRATE_ANNOTATIONS_IN_HIERARCHY violates TypeBinding's protocol by direct updation of fields in various places#4842
srikanth-sankaran wants to merge 1 commit into
eclipse-jdt:masterfrom
srikanth-sankaran:typebinding-protocol-violations

Conversation

@srikanth-sankaran
Copy link
Copy Markdown
Contributor

@srikanth-sankaran
Copy link
Copy Markdown
Contributor Author

In this PR I have inspected and sanitized the assignments to all 8 fields of org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding that are marked with the comment // MUST NOT be modified directly, use setter !

The 3 fields of TypeVariableBinding that carry the same comment are better scrutinized by @stephan-herrmann

So this PR should be seen as work in progress and taken to completion.

I don't think we need to bend over backwards writing tests for these changes. To future proof this code against regression by a future change, I have simply opted to call out in the code that direct assignment should not be done.

I think that plenty future proofing :)

@iloveeclipse
Copy link
Copy Markdown
Member

sanitized the assignments to all 8 fields of org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding that are marked with the comment // MUST NOT be modified directly, use setter !

Can we made the fields protected or private in 4.40? It is not API.
For now, I would also add javadoc style comments to them too saying that one should never modify them directly.

@srikanth-sankaran
Copy link
Copy Markdown
Contributor Author

Can we made the fields protected or private in 4.40?

Thing is they should not be assigned directly by the declaring class itself, because important side effects are encoded inside the corresponding set method. (Unless the developer is absolutely sure those side effects are not desirable in some situation, that is). This intent is not capturable directly under the access protection model of the language. (although it would be step in the right direction - yes so may be we should/could)

TypeBinding's protocol by direct updation of fields in various places

* Fixes eclipse-jdt#4823
@srikanth-sankaran srikanth-sankaran force-pushed the typebinding-protocol-violations branch from dfbb51b to a6c5e23 Compare February 16, 2026 09:35
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.

CompleteTypeBindingsSteps.INTEGRATE_ANNOTATIONS_IN_HIERARCHY violates TypeBinding's protocol by direct updation of fields in various places

2 participants