Skip to content

Commit 9cec4d7

Browse files
quaffsobychacko
authored andcommitted
Fix "no private access for invokespecial"
Resolves IllegalAccessException by using MethodHandles.privateLookupIn() instead of MethodHandles.lookup().in() to obtain proper private access privileges before invoking interface default methods reflectively. Introduced by spring-projectsGH-4149 Signed-off-by: Yanming Zhou <[email protected]>
1 parent 68adc26 commit 9cec4d7

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

spring-ai-spring-boot-testcontainers/src/main/java/org/springframework/ai/testcontainers/service/connection/mongo/MongoDbAtlasLocalContainerConnectionDetailsFactory.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ public ConnectionString getConnectionString() {
8383
public SslBundle getSslBundle() {
8484
if (GET_SSL_BUNDLE_METHOD != null) { // Boot 3.5.x+
8585
try {
86-
return (SslBundle) MethodHandles.lookup()
87-
.in(GET_SSL_BUNDLE_METHOD.getDeclaringClass())
86+
MethodHandles.Lookup origin = MethodHandles.lookup().in(getClass());
87+
return (SslBundle) MethodHandles.privateLookupIn(GET_SSL_BUNDLE_METHOD.getDeclaringClass(), origin)
8888
.unreflectSpecial(GET_SSL_BUNDLE_METHOD, GET_SSL_BUNDLE_METHOD.getDeclaringClass())
8989
.bindTo(this)
9090
.invokeWithArguments();

0 commit comments

Comments
 (0)