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

Investigate supporting WithType for single input parameter of shadow method #6888

Open
utzcoz opened this issue Nov 27, 2021 · 4 comments · May be fixed by #8829
Open

Investigate supporting WithType for single input parameter of shadow method #6888

utzcoz opened this issue Nov 27, 2021 · 4 comments · May be fixed by #8829
Labels

Comments

@utzcoz
Copy link
Member

utzcoz commented Nov 27, 2021

Description

Robolectric maybe need to add new shadow method with class type as input parameter, added from latest SDK, for example #6883. Developers can run related tests correctly when compileSdk is latest SDK. But if they change it to a lower SDK, related tests may failed because of NoClassDefFound problem. As @hoisie pointed out at #6884 (comment), we can investigate whether we can support WithType for single input parameter of shadow method.

It's better if we can expand this feature to support simulation for non-shadow method with new class type, such as #6589. Maybe we can add internal wrapper methods likes shadow method to wrapper those normal methods with WithType.

Steps to Reproduce

None.

Robolectric & Android Version

Latest Robolectric before this issue closed/fixed.

Link to a public git repo demonstrating the problem:

Robolectric itself.

@utzcoz utzcoz added the feature label Nov 27, 2021
@Akshay2131
Copy link
Contributor

Hi @utzcoz, i want to work on it as it is also a part of my GSoC project (To improve shadowOf generation)..
I am working on to add some feature so as to prevant ClassNotFoundException and NoClassDefFound types of errors that come when it tries to load classes that are not present in compileSdk level.

@Akshay2131
Copy link
Contributor

There are some possible solutions that include Replacing classes with Object and then using type-casting to convert it to particular type..
But i think there could be better alternative to it like if i investigate WithType.
If you have any other suggestion or any feature recommendation, please do let me know..

@utzcoz
Copy link
Member Author

utzcoz commented Apr 19, 2022

There are some possible solutions that include Replacing classes with Object and then using type-casting to convert it to particular type..

We are using this mechanism to avoid ClassNotFoundException and related above mentioned problems with looseSignature. But we don't think it is concise solution, and mark it as workaround. This issue is just an idea to improve solution. If you have other better ideas, it's welcome to post it out, and we can discuss it.

@Akshay2131
Copy link
Contributor

Currently, i am working on the same and soon I will update it here itself..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants