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][Java] Unable to correctly resolve the full name of the method inherited from the parent class #4835

Open
michwqy opened this issue Aug 11, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@michwqy
Copy link

michwqy commented Aug 11, 2024

Describe the bug
When I used Joern to detect a Java project that used MyBatis-Plus, I found that Joern could not correctly resolve the full name of method selectById of UserMapper inherited from the parent class BaseMapper. I'm not sure if this is Joern's bug or I didn't use the correct method.

To Reproduce
The detected Java code

@Mapper
public interface UserMapper extends BaseMapper<Users> {
}

@Service
public class UserService extends ServiceImpl<UserMapper, Users> {
    @Autowired
    private UserMapper userMapper;

    public Users getUserById(Long userId) {
        return userMapper.selectById(userId);
    }
}

The method getUserById call the method selectById of UserMapper inherited from BaseMapper.
And I used

cpg.call.methodFullName(".*selectById.*").l

Expected behavior
Since the method selectById is inherited from BaseMapper, the methodFullName of call userMapper.selectById(userId) should be
com.baomidou.mybatisplus.core.mapper.BaseMapper.selectById

Actual behavior
Joern gave the result that the methodFullName of call userMapper.selectById(userId) was org.wqy.mybatisplus.mapper.UserMapper.selectById

val res1: List[io.shiftleft.codepropertygraph.generated.nodes.Call] = List(
  Call(
    argumentIndex = 2,
    argumentName = None,
    code = "$stack2.selectById(userId)",
    columnNumber = None,
    dispatchType = "DYNAMIC_DISPATCH",
    dynamicTypeHintFullName = IndexedSeq(),
    lineNumber = Some(value = 18),
    methodFullName = "org.wqy.mybatisplus.mapper.UserMapper.selectById:java.lang.Object(java.io.Serializable)",
    name = "selectById",
    order = 2,
    possibleTypes = IndexedSeq(),
    signature = "java.lang.Object(java.io.Serializable)",
    typeFullName = "org.wqy.mybatisplus.mapper.UserMapper"
  )
)

Desktop

  • OS: macOS 13
  • Joern Version: 4.0.33
  • Java version: 17.0.11
@michwqy michwqy added the bug Something isn't working label Aug 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant