GithubHelp home page GithubHelp logo

Comments (7)

raphw avatar raphw commented on July 19, 2024

Hi, I already identified the actual issue. Refactoring gone wrong. I fixed the problem and just released version 0.6.10 where the visibility is appropriately resolved.

from byte-buddy.

bric3 avatar bric3 commented on July 19, 2024

ok, great :)

from byte-buddy.

bric3 avatar bric3 commented on July 19, 2024

It indeed fixes the issue :)

from byte-buddy.

raphw avatar raphw commented on July 19, 2024

Great! This time I actually cloned Mockito and tested it and then reproduced the problem in my tests. I think I knew the issue and did not test it properly. Moved to fast.

I really hope there will not be too many of these corner cases coming up to the surface. Mockito is the first large-scale user of Byte Buddy, there will probably be one or two things I have not thought off.

from byte-buddy.

bric3 avatar bric3 commented on July 19, 2024

No problem this is no small piece of development you crafted.

I'm excited by possibilities now :)
Just need time to work on it.

Also I think there's another issue with ByteBuddy or the way Mockito uses ByteBuddy.
The test in this commit hightlight an issue some are facing : bric3/mockito@7f2beb8

I didn't have time to dive in here yet, this probably have to do with a feature add in mockito lately that can generated partial mocks, so mocked types may be instantiated with the constructor instead of objenesis. So not sure it's a bytebuddy issue.

Must go now. Cheers

from byte-buddy.

raphw avatar raphw commented on July 19, 2024

When you mock a class, you delegate all invocations to an instance field:

.method(any()).intercept(toInstanceField(MockMethodInterceptor.class, "mockitoInterceptor")
       .filter(isDeclaredBy(MockMethodInterceptor.class)))

If the field is not yet set (during a constructor call), a null pointer exception is thrown.

To avoid this, you can for example delegate to a static interceptor which then checks if the interceptor is already set and only delegates a method if the interceptor is already set: https://gist.github.com/raphw/8789f5ef08240008efc8

from byte-buddy.

bric3 avatar bric3 commented on July 19, 2024

Yeah that's somehow what I suspected. Thanks for the tip.

from byte-buddy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.