UnsupportedOperationException at startup when using JDK 26+
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 48/100
Hướng nghiên cứu
Bắt đầu với co.elastic.apm.agent.bci.IndyBootstrap#loadClassInBootstrap và kiểm tra cách nó gọi ClassInjector của Byte Buddy. So sánh đường đi đó với triển khai HelperInjector được tham chiếu của OpenTelemetry, sau đó tái hiện quá trình khởi động agent trên JDK 26 hoặc mới hơn. Được xem là hoàn tất khi quá trình khởi động không còn thất bại với UnsupportedOperationException đã báo cáo mà không phụ thuộc vào workaround tạm thời bằng system-property.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Initially reported in our forum.
2026-06-25 17:22:20,878 [main] ERROR co.elastic.apm.agent.bci.ElasticApmAgent - Exception occurred while applying instrumentation co.elastic.apm.agent.java_ldap.LdapClientInstrumentation
java.lang.RuntimeException: java.lang.UnsupportedOperationException: Could not access Unsafe class: As of Java 26, using Unsafe is disabled by default, set net.bytebuddy.safe to true if you want to use the JVM's internal unsafe API even though it will become unsupported in the future and should be replaced by injection using method handles: net.bytebuddy.dynamic.loading.ClassInjector$UsingLookup
at co.elastic.apm.agent.bci.IndyBootstrap.getIndyBootstrapMethod(IndyBootstrap.java:240) ~[elastic-apm-agent-1.56.1-SNAPSHOT.jar:1.56.1-SNAPSHOT]
at co.elastic.apm.agent.bci.ElasticApmAgent.getTransformer(ElasticApmAgent.java:486) ~[elastic-apm-agent-1.56.1-SNAPSHOT.jar:1.56.1-SNAPSHOT]
at co.elastic.apm.agent.bci.ElasticApmAgent.applyAdvice(ElasticApmAgent.java:444) ~[elastic-apm-agent-1.56.1-SNAPSHOT.jar:1.56.1-SNAPSHOT]
at co.elastic.apm.agent.bci.ElasticApmAgent.initAgentBuilder(ElasticApmAgent.java:365) [elastic-apm-agent-1.56.1-SNAPSHOT.jar:1.56.1-SNAPSHOT]
at co.elastic.apm.agent.bci.ElasticApmAgent.initInstrumentation(ElasticApmAgent.java:290) [elastic-apm-agent-1.56.1-SNAPSHOT.jar:1.56.1-SNAPSHOT]
at co.elastic.apm.agent.bci.ElasticApmAgent.initInstrumentation(ElasticApmAgent.java:179) [elastic-apm-agent-1.56.1-SNAPSHOT.jar:1.56.1-SNAPSHOT]
at co.elastic.apm.agent.bci.ElasticApmAgent.initialize(ElasticApmAgent.java:165) [elastic-apm-agent-1.56.1-SNAPSHOT.jar:1.56.1-SNAPSHOT]
at jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104) ~[?:?]
at java.lang.reflect.Method.invoke(Method.java:565) ~[?:?]
at co.elastic.apm.agent.premain.AgentMain.loadAndInitializeAgent(AgentMain.java:157) [elastic-apm-agent-1.56.1-SNAPSHOT.jar:1.56.1-SNAPSHOT]
at co.elastic.apm.agent.premain.AgentMain.init(AgentMain.java:98) [elastic-apm-agent-1.56.1-SNAPSHOT.jar:1.56.1-SNAPSHOT]
at co.elastic.apm.agent.premain.AgentMain.premain(AgentMain.java:47) [elastic-apm-agent-1.56.1-SNAPSHOT.jar:1.56.1-SNAPSHOT]
at jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104) ~[?:?]
at java.lang.reflect.Method.invoke(Method.java:565) ~[?:?]
at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:544) [?:?]
at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:556) [?:?]
Caused by: java.lang.UnsupportedOperationException: Could not access Unsafe class: As of Java 26, using Unsafe is disabled by default, set net.bytebuddy.safe to true if you want to use the JVM's internal unsafe API even though it will become unsupported in the future and should be replaced by injection using method handles: net.bytebuddy.dynamic.loading.ClassInjector$UsingLookup
at net.bytebuddy.dynamic.loading.ClassInjector$UsingUnsafe$Dispatcher$Unavailable.initialize(ClassInjector.java:2206) ~[elastic-apm-agent-1.56.1-SNAPSHOT.jar:1.56.1-SNAPSHOT]
at net.bytebuddy.dynamic.loading.ClassInjector$UsingUnsafe.injectRaw(ClassInjector.java:1907) ~[elastic-apm-agent-1.56.1-SNAPSHOT.jar:1.56.1-SNAPSHOT]
at net.bytebuddy.dynamic.loading.ClassInjector$AbstractBase.injectRaw(ClassInjector.java:202) ~[elastic-apm-agent-1.56.1-SNAPSHOT.jar:1.56.1-SNAPSHOT]
at co.elastic.apm.agent.bci.IndyBootstrap.loadClassInBootstrap(IndyBootstrap.java:310) ~[elastic-apm-agent-1.56.1-SNAPSHOT.jar:1.56.1-SNAPSHOT]
at co.elastic.apm.agent.bci.IndyBootstrap.initIndyBootstrap(IndyBootstrap.java:268) ~[elastic-apm-agent-1.56.1-SNAPSHOT.jar:1.56.1-SNAPSHOT]
at co.elastic.apm.agent.bci.IndyBootstrap.getIndyBootstrapMethod(IndyBootstrap.java:234) ~[elastic-apm-agent-1.56.1-SNAPSHOT.jar:1.56.1-SNAPSHOT]
... 15 more
I think we need to modify the call to ClassInjector inco.elastic.apm.agent.bci.IndyBootstrap#loadClassInBootstrap method to implement something close to what is being done in upstream otel in https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/31188f0f8190356f8b943c81a0c8c51e9a45e6c4/muzzle/src/main/java/io/opentelemetry/javaagent/tooling/HelperInjector.java#L391
As reference, here is the PR that mainly contributed to the current version (where Unsafe usages were being removed) : https://github.com/open-telemetry/opentelemetry-java-instrumentation/pull/14855
The temporary workaround is to set net.bytebuddy.safe = false in Java system properties by adding the -Dnet.bytebuddy.safe=false JVM command line argument.
- Ngôn ngữ chính
- Java
- Star
- 593
- Fork
- 339
- Merge trung bình
- 1 ngày 9 giờ
- Pull request đã merge (30 ngày)
- 13
Chuẩn bị môi trường
- Có Dockerfile hoặc tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của elastic/apm-agent-java
-
Spring MVC View instrumentation incorrectly matches static render overloads (EasyPOI)Có thể đã có người làm @VelpulaGangavardhan đã nhận 6 ngày trước. Đang mởagent-java community triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
elastic/apm-agent-java#4594 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
agent-java
Độ khó 2/5 1-2 ngày Mức phù hợp với người mới 62/100
elastic/apm-agent-java#2844 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Improve docs and add error log related to illegal activation of transactionCó thể đã có người làm @AzazelSensei đã nhận 44 ngày trước. Đang mởdocs good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
elastic/apm-agent-java#850 · 4 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Log4j 2.7 log correlation calls ThreadContext.removeAll, which was introduced in 2.8Có thể đã có người làm @Anshuman-Prakash đã nhận 4 ngày trước. Đang mởagent-java community triage
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 55/100
elastic/apm-agent-java#4593 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
agent-java community triage
elastic/apm-agent-java#4573 · 4 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của elastic/apm-agent-java
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
2026 Error Report
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
triplea-game/triplea#15096 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Implement JDBC Domain Enums (`SqlCategory`, `SqlExecutionStatus`, `SqlExecutionType`) in Core ModuleĐang mởcore-module enhancement good first issue
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 87/100
sdlc-pro/spring-lens#531 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
Low-Drag-MC/LDLib2#78 ·
-
[GLOBAL] Advancement resetĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
Vakore/ZappierGames#184 ·