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

Fix bug where call origins cannot be found on descriptor signature mismatch #812

Commits on Feb 24, 2022

  1. fix compileJdk9mainJava task dependencies

    This task depends on the compiled output of the `compileJava` task, so we should explicitly declare this dependency. Otherwise, if you just run `compileJdk9mainJava` on a clean build it breaks.
    
    Signed-off-by: Peter Gafert <peter.gafert@tngtech.com>
    codecholeric committed Feb 24, 2022
    Configuration menu
    Copy the full SHA
    2628803 View commit details
    Browse the repository at this point in the history

Commits on Feb 25, 2022

  1. log dependency resolution process configuration on debug

    In the end this is not relevant for most users which will be happy with the default configuration and do not need to get into the depths of tweaking specific resolutions.
    
    Signed-off-by: Peter Gafert <peter.gafert@tngtech.com>
    codecholeric committed Feb 25, 2022
    Configuration menu
    Copy the full SHA
    a98c4d6 View commit details
    Browse the repository at this point in the history

Commits on Feb 27, 2022

  1. fix call origin cannot be found if descriptor and signature mismatch

    With ArchUnit 0.23.0 we fixed an ambiguity problem when resolving method call origins (bridge methods would cause two methods with same name and parameter types, so we would pick one randomly, which could be the wrong/synthetic one). Unfortunately, this broke some Kotlin use cases, because inline functions would cause the compiler to create synthetic classes with methods where the `signature` and the `descriptor` do not match (e.g. the signature says the return type is `String`, but the descriptor claims `Object`). In these cases the erasure of the generic type does not match the raw type. But so far for the return type we derived the raw return type as erasure from the generic return type.
    This is now fixed by keeping raw and generic return type completely separate, since we obviously cannot derive one from the other (the JVM spec also clearly states that this is a valid case, that descriptor and signature do not need to match exactly and are not validated against each other).
    
    Note that for parameter types we have already separated this a while ago, so there it never was a problem.
    
    Signed-off-by: Peter Gafert <peter.gafert@tngtech.com>
    codecholeric committed Feb 27, 2022
    Configuration menu
    Copy the full SHA
    63618cb View commit details
    Browse the repository at this point in the history
  2. compare descriptor to find call origins

    Since we meanwhile have the descriptor both on the search target and the code unit candidates, we can simply compare that instead of comparing raw parameter types and return type individually.
    
    Note that this by itself would have already fixed the bug where call origins cannot be identified if descriptor and signature mismatch, but nevertheless the API would have been behaving wrongly when deriving the raw return type from the erasure of the generic return type.
    
    Signed-off-by: Peter Gafert <peter.gafert@tngtech.com>
    codecholeric committed Feb 27, 2022
    Configuration menu
    Copy the full SHA
    87f1b15 View commit details
    Browse the repository at this point in the history