byte-buddy icon indicating copy to clipboard operation
byte-buddy copied to clipboard

how to enhance thread construct method

Open githubcheng2978 opened this issue 1 year ago • 7 comments

how to enhance thread construct method ?

githubcheng2978 avatar Apr 29 '24 03:04 githubcheng2978

image it is not work~

githubcheng2978 avatar Apr 29 '24 03:04 githubcheng2978

The Thread class will already be loaded, so you likely will need to apply retransformation. Typically, you'd also disable class format changes doing so. There's steps for both in the DSL.

raphw avatar Apr 29 '24 16:04 raphw

Thank you very much for your answer.because lambda Runnable didn’t can be interceptor, so I want interceptor Thread construct method,then delegate lambda .

获取 Outlook for iOShttps://aka.ms/o0ukef


发件人: Rafael Winterhalter @.> 发送时间: Tuesday, April 30, 2024 12:46:10 AM 收件人: raphw/byte-buddy @.> 抄送: githubcheng2978 @.>; Author @.> 主题: Re: [raphw/byte-buddy] how to enhance thread construct method (Issue #1627)

The Thread class will already be loaded, so you likely will need to apply retransformation. Typically, you'd also disable class format changes doing so. There's steps for both in the DSL.

― Reply to this email directly, view it on GitHubhttps://github.com/raphw/byte-buddy/issues/1627#issuecomment-2083201404, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AFISMWBFD4IMBLY2GVROWIDY7Z2NFAVCNFSM6AAAAABG5RVBKWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAOBTGIYDCNBQGQ. You are receiving this because you authored the thread.Message ID: @.***>

githubcheng2978 avatar Apr 29 '24 16:04 githubcheng2978

So, what should I do to intercept the thread's constructor? Can you give me a dmeo?

githubcheng2978 avatar May 02 '24 04:05 githubcheng2978

You can intercept a constructor just as any method. Intercept via ElementMatchers.isConstructor().

raphw avatar May 02 '24 18:05 raphw

image it is not work~~~

githubcheng2978 avatar May 05 '24 14:05 githubcheng2978

skip the explicit retransformClasses.

Also, add .wtih(RetransformationStrategy.RETRANSFORM).disableClassFormatChanges().

raphw avatar May 08 '24 07:05 raphw