fix: Illegal Access error when using AgentMemoryExtension #3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix
IllegalAccessErrorduringAgentMemoryOutputdeserializationThis change resolves an
IllegalAccessErrorby defining a public stub for the AgentMemoryOutputBuilder. This makes the builder's constructor public and accessible during deserialization.Error log
``` java.util.concurrent.CompletionException: java.lang.IllegalAccessError: class com.phonepe.sentinelai.agentmemory.AgentMemoryOutput$AgentMemoryOutputBuilder$Creator4JacksonDeserializerafa25a47 tried to access method 'void com.phonepe.sentinelai.agentmemory.AgentMemoryOutput$AgentMemoryOutputBuilder.()' (com.phonepe.sentinelai.agentmemory.AgentMemoryOutput$AgentMemoryOutputBuilder$Creator4JacksonDeserializerafa25a47 is in unnamed module of loader com.fasterxml.jackson.module.afterburner.util.MyClassLoader @79a85907; com.phonepe.sentinelai.agentmemory.AgentMemoryOutput$AgentMemoryOutputBuilder is in unnamed module of loader 'app') at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:315) at java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:320) at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1770) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) at java.base/java.lang.Thread.run(Thread.java:842) Caused by: java.lang.IllegalAccessError: class com.phonepe.sentinelai.agentmemory.AgentMemoryOutput$AgentMemoryOutputBuilder$Creator4JacksonDeserializerafa25a47 tried to access method 'void com.phonepe.sentinelai.agentmemory.AgentMemoryOutput$AgentMemoryOutputBuilder.()' (com.phonepe.sentinelai.agentmemory.AgentMemoryOutput$AgentMemoryOutputBuilder$Creator4JacksonDeserializerafa25a47 is in unnamed module of loader com.fasterxml.jackson.module.afterburner.util.MyClassLoader @79a85907; com.phonepe.sentinelai.agentmemory.AgentMemoryOutput$AgentMemoryOutputBuilder is in unnamed module of loader 'app') at com.phonepe.sentinelai.agentmemory.AgentMemoryOutput$AgentMemoryOutputBuilder$Creator4JacksonDeserializerafa25a47.createUsingDefault(com/phonepe/sentinelai/agentmemory/AgentMemoryOutput$AgentMemoryOutputBuilder$Creator4JacksonDeserializer.java) at com.fasterxml.jackson.databind.deser.BuilderBasedDeserializer.vanillaDeserialize(BuilderBasedDeserializer.java:285) at com.fasterxml.jackson.databind.deser.BuilderBasedDeserializer.deserialize(BuilderBasedDeserializer.java:217) at com.fasterxml.jackson.databind.deser.DefaultDeserializationContext.readRootValue(DefaultDeserializationContext.java:322) at com.fasterxml.jackson.databind.ObjectMapper._readValue(ObjectMapper.java:4569) at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2798) at com.fasterxml.jackson.databind.ObjectMapper.treeToValue(ObjectMapper.java:3261) at com.phonepe.sentinelai.agentmemory.AgentMemoryExtension.consume(AgentMemoryExtension.java:173) at com.phonepe.sentinelai.models.SimpleOpenAIModel.lambda$convertToResponse$11(SimpleOpenAIModel.java:715) at java.base/java.lang.Iterable.forEach(Iterable.java:75) at com.phonepe.sentinelai.models.SimpleOpenAIModel.convertToResponse(SimpleOpenAIModel.java:703) at com.phonepe.sentinelai.models.SimpleOpenAIModel.processOutput(SimpleOpenAIModel.java:438) at com.phonepe.sentinelai.models.SimpleOpenAIModel.lambda$exchangeMessages$1(SimpleOpenAIModel.java:185) at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1768) ```