Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug 545605 - Adjust ecj to change in JVMS 4.7.18./19. #2628

Merged
merged 1 commit into from
Jun 23, 2024

Conversation

stephan-herrmann
Copy link
Contributor

fixes #2625

With this change we implement the following sentence present in JVMS 4.7.18./19. since version 9:

num_parameters: [...] There is no assurance that this number is the same as the number of parameter descriptors in the method descriptor.

This, however, would leave us guessing, which parameters are annotated by that partial array.

Original use case:

For example, a compiler may choose to create entries in the table corresponding only to those parameter descriptors which represent explicitly declared parameters in source code. In the Java programming language, a constructor of an inner class is specified to have an implicitly declared parameter before its explicitly declared parameters (JLS §8.8.1), so the corresponding method in a class file has a parameter descriptor representing the implicitly declared parameter before any parameter descriptors representing explicitly declared parameters. If the first explicitly declared parameter is annotated in source code, then a compiler may create parameter_annotations[0] to store annotations corresponding to the second parameter descriptor.

As I did not want to enter the realm of reading between the lines of a use case that is given as "For example", I did not implement any further heuristics to correlate annotations to parameters. I will leave this to be sorted out by a future spec version.

I did, however, add a flag that would allow to print the original error message before this change.

Should anybody suspect that the correlation between parameters and their annotations goes astray define a system property jdt.reject.parameterAnnotations.countMismatch=true and recompile.

@stephan-herrmann stephan-herrmann added this to the 4.33 M1 milestone Jun 23, 2024
@stephan-herrmann stephan-herrmann merged commit 2feaa74 into eclipse-jdt:master Jun 23, 2024
9 checks passed
@stephan-herrmann stephan-herrmann deleted the issue2625 branch June 23, 2024 11:22
robstryker pushed a commit to robstryker/eclipse.jdt.core that referenced this pull request Jul 18, 2024
Accept class files with mismatching parameter count vis-a-vis parameter annotations (which is legal since Java 9).

Also introduces system property jdt.reject.parameterAnnotations.countMismatch to get back the previous error reporting.

fixes eclipse-jdt#2625
gayanper pushed a commit to gayanper/eclipse.jdt.core that referenced this pull request Sep 7, 2024
Accept class files with mismatching parameter count vis-a-vis parameter annotations (which is legal since Java 9).

Also introduces system property jdt.reject.parameterAnnotations.countMismatch to get back the previous error reporting.

fixes eclipse-jdt#2625
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.

Bug 545605 - Adjust ecj to change in JVMS 4.7.18./19.
1 participant