private Sdk getJdkForStartupCommand(final ModuleChunk chunk) { final Sdk jdk = chunk.getJdk(); if (ApplicationManager.getApplication().isUnitTestMode() && JavacConfiguration.getOptions(myProject, JavacConfiguration.class).isTestsUseExternalCompiler()) { final String jdkHomePath = CompilerConfigurationImpl.getTestsExternalCompilerHome(); if (jdkHomePath == null) { throw new IllegalArgumentException("[TEST-MODE] Cannot determine home directory for JDK to use javac from"); } // when running under Mock JDK use VM executable from the JDK on which the tests run return new MockJdkWrapper(jdkHomePath, jdk); } return jdk; }