Skip to content

Commit 0398cee

Browse files
authored
Eliminate Java 9+ dependency for UP (elastic#4286)
* Eliminate Java 9+ dependency for UP * add changelog entry
1 parent 71f25bc commit 0398cee

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

CHANGELOG.next-release.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ This file contains all changes which are not released yet.
99

1010
# Fixes
1111
<!--FIXES-START-->
12-
12+
Prevent Universal Profiling integration crashing agent on startup when run on Java 8 - [#4286](https://github.com/elastic/apm-agent-java/pull/4286)
1313
<!--FIXES-END-->
1414
# Features and enhancements
1515
<!--ENHANCEMENTS-START-->

apm-agent-core/src/main/java/co/elastic/apm/agent/universalprofiling/ProfilerSharedMemoryWriter.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import co.elastic.otel.UniversalProfilingCorrelation;
2626

2727
import javax.annotation.Nullable;
28+
import java.nio.Buffer;
2829
import java.nio.ByteBuffer;
2930
import java.nio.ByteOrder;
3031
import java.nio.charset.StandardCharsets;
@@ -47,7 +48,8 @@ public class ProfilerSharedMemoryWriter {
4748
static ByteBuffer generateProcessCorrelationStorage(String serviceName, @Nullable String environment, String socketFilePath) {
4849
ByteBuffer buffer = ByteBuffer.allocateDirect(4096);
4950
buffer.order(ByteOrder.nativeOrder());
50-
buffer.position(0);
51+
//To make it java 8 compatible regardless of how it's compiled, need to explicitly use Buffer.position(int)
52+
((Buffer) buffer).position(0);
5153

5254
buffer.putChar((char) 1); // layout-minor-version
5355
writeUtf8Str(buffer, serviceName);

0 commit comments

Comments
 (0)