OpenPojo / openpojo

POJO Testing & Identity Management Made Trivial
http://openpojo.com
Apache License 2.0
156 stars 40 forks source link

InaccessibleObjectException while executing tests with JDK17 #149

Open nskshared opened 1 year ago

nskshared commented 1 year ago

hi We are getting below error while running our tests against POJO classes. Looks like they increased security levels in jdk17 hence its difficult to change access modifiers etc.

Please can you advise if there is any alternative for below issue.

Unable to make field private static final long java.time.LocalDate.serialVersionUID accessible: module java.base does not "opens java.time" to unnamed module @6be46e8f java.lang.reflect.InaccessibleObjectException: Unable to make field private static final long java.time.LocalDate.serialVersionUID accessible: module java.base does not "opens java.time" to unnamed module @6be46e8f

flowerforest0123 commented 1 year ago

Same Problem with Map: Unable to make field private static final java.util.Map java.util.Locale.CONSTANT_LOCALES accessible: module java.base does not "opens java.util" to unnamed module @757942a1

rahul-konduru commented 12 months ago

I got the same issue for java.time.LocalDate.serialVersionUID. After looking at the stacktrace found out that openpojo is trying to generate a random value for LocalDateTime which was used in one of my class. There are 2 possible solutions to get over this error.

vmgbrown commented 10 months ago

I tried the workaround suggested above but it didn't work for me.

This is a major issue, but it doesn't seem like this project has gotten much attention lately. Wondering if it will ever be addressed.

rahul-konduru commented 10 months ago

@vmgbrown Did neither of the two options work for you? Which one did you try? We were migrating 20 of our services and these work arounds worked for us always. Just curious.

On Thu, Dec 21, 2023 at 14:12 vmgbrown @.***> wrote:

I tried the workaround suggested above but it didn't work for me.

This is a major issue, but it doesn't seem like this project has gotten much attention lately. Wondering if it will ever be addressed.

— Reply to this email directly, view it on GitHub https://github.com/OpenPojo/openpojo/issues/149#issuecomment-1866808054, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABRLX35PFGFARF5WYLR3LS3YKSC3HAVCNFSM6AAAAAA2CCCNMGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNRWHAYDQMBVGQ . You are receiving this because you commented.Message ID: @.***>

vmgbrown commented 10 months ago

@rahul-konduru Sorry I wasn't clear. I tried the --add-opens workaround. We use OpenPOJO in a lot of tests, so any sort of custom workaround is likely to be a non-starter.

My bigger issue is the lack of updates. If this project is not being maintained, we will most likely need to look into other options.

rahul-konduru commented 10 months ago

Its the same case with us. Lots of dependency on this library and couldn’t replace it for now.

There is a catch if you are using —add-opens option. The package name is the key. For example if there are multiple classes with the error, you need to add the arguments those many times. For example, if you get the error for the following classes (the nesting example is intensional) com.a.Class1 com.a.b.Class2

You need to add these two arguments —add-options java.base/com.a=ALL-UNNAMED —add-options java.base/com.a.b=ALL-UNNAMED Hope this helps.

On Thu, Dec 21, 2023 at 14:22 vmgbrown @.***> wrote:

@rahul-konduru https://github.com/rahul-konduru Sorry I wasn't clear. I tried the --add-opens workaround. We use OpenPOJO in a lot of tests, so any sort of custom workaround is likely to be a non-starter.

My bigger issue is the lack of updates. If this project is not being maintained, we will most likely need to look into other options.

— Reply to this email directly, view it on GitHub https://github.com/OpenPojo/openpojo/issues/149#issuecomment-1866817487, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABRLX35A4CR2PV55NX2GXODYKSD6RAVCNFSM6AAAAAA2CCCNMGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNRWHAYTONBYG4 . You are receiving this because you were mentioned.Message ID: @.***>

vmgbrown commented 9 months ago

@rahul-konduru The custom generator case is working for now. Thank you for the suggestion!