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

IllegalAccessError with Jackson Afterburner #143

Open
cemo opened this issue Jun 29, 2021 · 1 comment
Open

IllegalAccessError with Jackson Afterburner #143

cemo opened this issue Jun 29, 2021 · 1 comment

Comments

@cemo
Copy link

cemo commented Jun 29, 2021

I am using immutables v2.8.2 and jackson v2.12.3 with Afterburner module. However this is causing some issue regarding access modifers.

I created a sample project with 2 test. One of them is registering AfterBurner and other one is not. The one without afterburner is working properly. However other one is not.

https://github.com/cemo/immutable-afterburner-issue

Here is the sample error

WARNING: Disabling Afterburner serialization for class com.mycompany.app.ImmutableVal (field #0; mutator com.fasterxml.jackson.module.afterburner.ser.IntMethodPropertyWriter), due to access error (type java.lang.IllegalAccessError, message=failed to access class com.mycompany.app.ImmutableVal from class com.mycompany.app.ImmutableVal$Access4JacksonSerializer7db6db1a (com.mycompany.app.ImmutableVal is in unnamed module of loader 'app'; com.mycompany.app.ImmutableVal$Access4JacksonSerializer7db6db1a is in unnamed module of loader com.fasterxml.jackson.module.afterburner.util.MyClassLoader @5c30a9b0))

java.lang.IllegalAccessError: failed to access class com.mycompany.app.ImmutableVal from class com.mycompany.app.ImmutableVal$Access4JacksonSerializer7db6db1a (com.mycompany.app.ImmutableVal is in unnamed module of loader 'app'; com.mycompany.app.ImmutableVal$Access4JacksonSerializer7db6db1a is in unnamed module of loader com.fasterxml.jackson.module.afterburner.util.MyClassLoader @5c30a9b0)
	at com.mycompany.app.ImmutableVal$Access4JacksonSerializer7db6db1a.intGetter(com/mycompany/app/ImmutableVal$Access4JacksonSerializer.java)
	at com.fasterxml.jackson.module.afterburner.ser.IntMethodPropertyWriter.serializeAsField(IntMethodPropertyWriter.java:55)
	at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:770)
	at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:178)
	at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider._serialize(DefaultSerializerProvider.java:480)
	at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:319)
	at com.fasterxml.jackson.databind.ObjectMapper._writeValueAndClose(ObjectMapper.java:4487)
	at com.fasterxml.jackson.databind.ObjectMapper.writeValueAsString(ObjectMapper.java:3742)
	at com.mycompany.app.AppTest.shouldAnswerWithThisTrueToo(AppTest.java:46)

I did not get why it is working without afterburner. Seems a bug to me.

@cowtowncoder
Copy link
Member

cowtowncoder commented Jun 29, 2021

Sounds like you need to open up access via JPMS module definitions, or disable module restrictions for JVM.
Afterburner cannot force access otherwise; nor can it do anything about it. But even with failure actual serialization should work -- message points out that optimization is disabled but the default handling should still work.

Another thing to consider might be to try the new Blackbird module instead: it is designed to work better with post-Java-8 JDKs/JVMs.

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

No branches or pull requests

2 participants