Skip to content

Commit 2e177dc

Browse files
authored
fix: JDK version check wouldn't detect JDK 8 correctly (react-native-community#1395)
`envinfo` uses `javac -version` to work out the JDK version number. The doctor command was looking for a semver range of `>= 8` but this won't work for JDK 8 as it uses the old style numbering scheme (e.g. `1.8.x` not `8.x.x`). JDKs 9+ use the new version numbering scheme. Fixes react-native-community#1255
1 parent a52b25e commit 2e177dc

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

packages/cli/src/commands/doctor/healthchecks/__tests__/jdk.test.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,20 @@ describe('jdk', () => {
4040
expect(diagnostics.needsToBeFixed).toBe(true);
4141
});
4242

43-
it('returns false if JDK version is in range', async () => {
43+
it('returns false if JDK version is in range (JDK 9+ version number format)', async () => {
4444
// @ts-ignore
4545
environmentInfo.Languages.Java = {
46-
version: '9',
46+
version: '9.0.4',
47+
};
48+
49+
const diagnostics = await jdk.getDiagnostics(environmentInfo);
50+
expect(diagnostics.needsToBeFixed).toBe(false);
51+
});
52+
53+
it('returns false if JDK version is in range (JDK 8 version number format)', async () => {
54+
// @ts-ignore
55+
environmentInfo.Languages.Java = {
56+
version: '1.8.0_282',
4757
};
4858

4959
const diagnostics = await jdk.getDiagnostics(environmentInfo);

packages/cli/src/commands/doctor/versionRanges.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
YARN: '>= 1.10.x',
55
NPM: '>= 4.x',
66
WATCHMAN: '4.x',
7-
JAVA: '>= 8',
7+
JAVA: '1.8.x || >= 9',
88
// Android
99
ANDROID_SDK: '>= 26.x',
1010
ANDROID_NDK: '>= 19.x',

0 commit comments

Comments
 (0)