INRIA / INRIA/spoon

Reproduceable BUG: spoon.reflect.declaration.CtMethod#clone : statement invoking method with a string concatenation expression as argument

Open
#3,997 4 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Java
Stars
2k
Forks
392
Avg merge
11h 24m
Merged PRs (30d)
36

Description

How to reproduce?

1. Check-out the project Lang-1 (fixed version).
2. create a `Launcher launcher = new Launcher();`.
3. set a diff-only printer to the launcher `launcher.getEnvironment().setPrettyPrinterCreator(() -> new SniperJavaPrettyPrinter(launcher.getEnvironment()));`
2. load the test class `FastDateParserTest` and clone the method `testSdfAndFdp` and add it to the class as `testSdfAndFdp__cloned`
3. `prettyPrint` this updated model.

--> The code will not compile because the cloned method presents problems in one of its `fail()` call statements: `((FastDateParser)fdp).getParsePattern()` is cloned by spoon to `getParsePattern()`.

Here's the full statement
original statement: `Assert.fail("Expected FDF failure, but got " + dfdp + " for ["+format+","+date+"] using "+((FastDateParser)fdp).getParsePattern());`
cloned statement: `fail((((((("Expected FDF failure, but got " + dfdp) + " for [") + format) + ",") + date) + "] using ") + getParsePattern());`

As written in the title, I think there's an issue in cloning statements containing complex method invocations (with complex expressions as a parameter).

Thank you for providing such a great tool and I hope I will be able to use it in my research.
Please, don't hesitate to let me know if I can help by any mean.

Best regards.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the issue with the fixed Lang-1 project, using Launcher, the diff-only pretty printer, and FastDateParserTest.testSdfAndFdp. Inspect how cloning and pretty-printing handle the fail() statement with the concatenated argument and method invocation. Done means the cloned test method produces compiling Java with the invocation preserved.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.