Skip to content

Commit f6f6714

Browse files
committed
Ignore more common JVM detection errors
1 parent 947a5c5 commit f6f6714

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/interceptors/jvm.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import { ErrorLike } from '../util/error';
1414
type JvmTarget = { pid: string, name: string, interceptedByProxy: number | undefined };
1515

1616
const OLD_JAVA_MISSING_ATTACH_CLASS = 'com/sun/tools/attach/AgentLoadException';
17+
const MISSING_ATTACH_LIB_MESSAGE = 'java.lang.UnsatisfiedLinkError: no attach in java.library.path';
18+
const JRE_NOT_JDK_MESSAGE = 'Are we running in a JRE instead of a JDK';
1719

1820
// Check that Java is present, and that it's compatible with agent attachment:
1921
const javaBinPromise: Promise<string | false> = (async () => {
@@ -72,8 +74,13 @@ const javaBinPromise: Promise<string | false> = (async () => {
7274
// the necessary APIs to attach to remote JVMs. That's inconvenient, but unavoidable & not unusual.
7375
// Fortunately, I think most active Java developers do have a recent version of Java installed.
7476
const unusualJavaErrors = javaTestResults.filter(({ output }) =>
75-
!output.stderr.includes(OLD_JAVA_MISSING_ATTACH_CLASS) &&
76-
!output.stdout.includes(OLD_JAVA_MISSING_ATTACH_CLASS) &&
77+
// Not caused by a known normal not-supported-in-your-env error:
78+
![
79+
MISSING_ATTACH_LIB_MESSAGE, OLD_JAVA_MISSING_ATTACH_CLASS, JRE_NOT_JDK_MESSAGE
80+
].some(knownError =>
81+
output.stderr.includes(knownError) || output.stdout.includes(knownError)
82+
) &&
83+
// And not caused by ENOENT for an invalid Java path:
7784
!('spawnError' in output && output.spawnError.code === 'ENOENT')
7885
);
7986

0 commit comments

Comments
 (0)