hazendaz / jmockit1

Advanced Java library for integration testing, mocking, faking, and code coverage
Other
17 stars 6 forks source link

"class redefinition failed" while overriding an Enum static (or not) method on JDK17 (correto) #116

Open rjunqueira opened 1 year ago

rjunqueira commented 1 year ago

Hello,

I have this UnsupportedOpEx : class redefinition failed: attempted to change the class NestHost, NestMembers, Record, or PermittedSubclasses attribute

The stack: image

extracted and cleaned sample code : private void mockEnumEquitySwapCodificationMethodologyNone() { new MockUp() { @mockit.Mock public final EnumEquitySwapCodificationMethodology getCodificationGlobalConfig() { return EnumEquitySwapCodificationMethodology.EESCM_NONE; } }; }

public enum EnumEquitySwapCodificationMethodology { EESCM_NONE, EESCM_ROOT_CONTRACT;

@Nonnull static public final EnumEquitySwapCodificationMethodology getCodificationGlobalConfig() { return EESCM_ROOT_CONTRACT; } }

Thx

MERGHOOB commented 1 year ago

Hi I am also seeing this issue in version jmockit version 1.44. I am trying to move the project to Java 17

hazendaz commented 1 year ago

You have to use my fork versions not the original. The original doesn't even support jdk 11 properly.

So know it's hard to upgrade but once on the fork apis will never be so abused again. 1.44 up is a lot of work unfortunately

Sent from my Verizon, Samsung Galaxy smartphone Get Outlook for Androidhttps://aka.ms/AAb9ysg


From: MERGHOOB @.> Sent: Friday, May 5, 2023 3:09:16 AM To: hazendaz/jmockit1 @.> Cc: Jeremy Landis @.>; Assign @.> Subject: Re: [hazendaz/jmockit1] "class redefinition failed" while overriding an Enum static (or not) method on JDK17 (correto) (Issue #116)

Hi I am also seeing this issue in version jmockit version 1.44. I am trying to move the project to Java 17

— Reply to this email directly, view it on GitHubhttps://github.com/hazendaz/jmockit1/issues/116#issuecomment-1535818432, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AAHODI634Y6LM3X5DFT5LHLXESRRZANCNFSM6AAAAAAWM4H5LQ. You are receiving this because you were assigned.Message ID: @.***>

MERGHOOB commented 1 year ago

In your fork version, My project will not compile as there is no De-encapsulation class and Concrete class (lots of test are depending on that). I would love to see your fix for Class Redefinition if possible. Original is working fine with jdk11

hazendaz commented 1 year ago

The original author deleted de encapsulation. If someone can do the work to add it back I'd merge it. My use case at work we already long ago dumped it when the author did for powermock reflect whitebox. It's simple to do that even. Also mockito can do same.

I'm not seeing the other issue myself and not sure if anyone can add a fix for it.

I know someone had raised a PR to add back deencapsulation but then they closed stating not ready. May be worth you checking PR history and tracking that dev down to see if they can resolve that so you can upgrade to this point then help in trying to figure this issue out.

Sent from my Verizon, Samsung Galaxy smartphone Get Outlook for Androidhttps://aka.ms/AAb9ysg


From: MERGHOOB @.> Sent: Thursday, May 11, 2023 12:53:19 AM To: hazendaz/jmockit1 @.> Cc: Jeremy Landis @.>; Assign @.> Subject: Re: [hazendaz/jmockit1] "class redefinition failed" while overriding an Enum static (or not) method on JDK17 (correto) (Issue #116)

In your fork version, My project will not compile as there is no De-encapsulation class and Concrete class (lots of test are depending on that). I would love to see your fix for Class Redefinition if possible.

— Reply to this email directly, view it on GitHubhttps://github.com/hazendaz/jmockit1/issues/116#issuecomment-1543329595, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AAHODIZQKGL4FCTJYW5HHJTXFRWD7ANCNFSM6AAAAAAWM4H5LQ. You are receiving this because you were assigned.Message ID: @.***>

hazendaz commented 11 months ago

@MERGHOOB De-encapsulation is now restored and will be in upcoming release, if possibly maybe you can compile our master or pull our snapshot from sonatype and see. However this sounds like issue #135 so you may want to look there to see if same issue so we can close one of these. There is a link over there to mockito when they had same issue.