Sdk (Sdk jdk) { try { jdk = (Sdk)jdk.clone(); } catch (CloneNotSupportedException e) { throw new RuntimeException(e); } final SdkModificator modificator = jdk.getSdkModificator(); VirtualFile rtJar = null; for (VirtualFile root : modificator.getRoots(OrderRootType.CLASSES)) { if (root.getName().equals("rt.jar")) { rtJar = root; break; } } assertNotNull("rt.jar not found in jdk: " + jdk, rtJar); modificator.setVersionString(IdeaTestUtil.getMockJdkVersion(jdk.getHomePath())); modificator.removeAllRoots(); modificator.addRoot(rtJar, OrderRootType.CLASSES); modificator.commitChanges(); return jdk; }