From 3f3180841e39258ef8e74e9df041511fc8535765 Mon Sep 17 00:00:00 2001 From: Lauri Tulmin Date: Sun, 5 Dec 2021 13:37:01 +0200 Subject: [PATCH] Avoid crashing on early 1.8 openjdk vms (#4789) --- .../opentelemetry/javaagent/bootstrap/AgentInitializer.java | 4 ++-- .../src/test/resources/crashearlyjdk8/CrashEarlyJdk8.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/javaagent-bootstrap/src/main/java/io/opentelemetry/javaagent/bootstrap/AgentInitializer.java b/javaagent-bootstrap/src/main/java/io/opentelemetry/javaagent/bootstrap/AgentInitializer.java index ad683f81232d..15d89cbbd20d 100644 --- a/javaagent-bootstrap/src/main/java/io/opentelemetry/javaagent/bootstrap/AgentInitializer.java +++ b/javaagent-bootstrap/src/main/java/io/opentelemetry/javaagent/bootstrap/AgentInitializer.java @@ -44,9 +44,9 @@ public static void initialize(Instrumentation inst, File javaagentFile, boolean * @return true for oracle 1.8 before 1.8.0_40 */ private static boolean isEarlyOracle18() { - // Java HotSpot(TM) 64-Bit Server VM + // Java HotSpot(TM) 64-Bit Server VM or OpenJDK 64-Bit Server VM String vmName = System.getProperty("java.vm.name"); - if (!vmName.contains("HotSpot")) { + if (!vmName.contains("HotSpot") && !vmName.contains("OpenJDK")) { return false; } // 1.8.0_31 diff --git a/smoke-tests/src/test/resources/crashearlyjdk8/CrashEarlyJdk8.java b/smoke-tests/src/test/resources/crashearlyjdk8/CrashEarlyJdk8.java index ddd2d8502804..c89e24a573ca 100644 --- a/smoke-tests/src/test/resources/crashearlyjdk8/CrashEarlyJdk8.java +++ b/smoke-tests/src/test/resources/crashearlyjdk8/CrashEarlyJdk8.java @@ -16,7 +16,7 @@ public static void main(String... args) { public void test() { // run loop enough times for jit compiler to kick in - for (int i = 0; i < 10_000; i++) { + for (int i = 0; i < 100_000; i++) { this.bar(this::foo); } }