fasten-project / fasten

Analyse package dependency networks at the call graph level
https://www.fasten-project.eu
Apache License 2.0
90 stars 28 forks source link

FastenUriUtils parsing incorrectly the "class", "method" for some cases with lambda function. #260

Open cg122 opened 3 years ago

cg122 commented 3 years ago

Describe the bug

A clear and concise description of what the bug is.

To Reproduce

Parsing the partial uri in the following FASTEN uri

fasten://mvn!nl.tudelft.jpacman:jpacman-framework$8.1.1/nl.tudelft.jpacman.ui/PacManUiBuilder$addStopButton%28Lnl$tudelft$jpacman$game$Game%3A%29V%3A30$Lambda.$newInstance(%2Fnl.tudelft.jpacman.game%2FGame)PacManUiBuilder$addStopButton%28Lnl$tudelft$jpacman$game$Game%3A%29V%3A30$Lambda

output:

[nl.tudelft.jpacman.ui, PacManUiBuilder$addStopButton(Lnl$tudelft$jpacman$game$Game:)V:30$Lambda, ui/PacManUiBuilder$addStopButton, Lnl$tudelft$jpacman$game$Game:)V:30$Lambda.$newInstance(/nl.tudelft.jpacman.game/Game)PacManUiBuilder$addStopButton(Lnl$tudelft$jpacman$game$Game:, V:30$Lambda.$newInstance(/nl.tudelft.jpacman.game/Game)PacManUiBuilder$addStopButton(Lnl$tudelft$jpacman$game$Game:)V:30$Lambda]

Expected behavior

class name should be "PacManUiBuilder", method should be "addStopButton"

Additional context

Result got on develop branch (1001e75ac0a45d2126b7f33b767d9ecee9ef3364)

MrLightful commented 3 years ago

@cg122 I adjusted implementation towards the better way. It returns PacManUiBuilder as the class, but newInstance as the method. However, it is more of an "ideological problem" which of two to return (newInstance or addStopButton).

@ashkboos will contact you to know some context behind it. Do you think there might be different scenarios when either of them are needed? In this case, we need to solve this issue somehow? Maybe a nested array of method names in the order of inclusion? For example, ['addStopButton', 'newInstance']?

@cg122 also, do you maybe have artifacts similar to this one, with inner classes? Just to test the implementation.

And also, sorry for the late fix 😅

cg122 commented 3 years ago

Thanks @romatallinn. I will look at it and see how it works for other example.

cg122 commented 3 years ago

I checked the source code corresponding to the FASTEN uri above:

    private void addStopButton(final Game game) {
        assert game != null;

        buttons.put(STOP_CAPTION, game::stop);
    }

I guess the uri corresponds to 'Game::stop', and the simplified form of passing method reference used here complicates the understanding of the uri.

proksch commented 2 years ago

I just stumbled across this issue... as there are no follow-up comments, I would assume that the problem still persists. To me this looks more like a problem of how the FastenUri is created, rather than how it is parsed.

Who in the team was involved in the creation of the FastenUri part? (Sorry, that I do not know that, but it was before my time :D)