diff --git a/java/compiler/compiler-tests.iml b/java/compiler/compiler-tests.iml
index 00f4449e83c6..943b1830d3dd 100644
--- a/java/compiler/compiler-tests.iml
+++ b/java/compiler/compiler-tests.iml
@@ -19,6 +19,7 @@
+
diff --git a/java/compiler/impl/src/com/intellij/compiler/CompilerConfigurationImpl.java b/java/compiler/impl/src/com/intellij/compiler/CompilerConfigurationImpl.java
index 2b114b96e13f..09feb937e561 100644
--- a/java/compiler/impl/src/com/intellij/compiler/CompilerConfigurationImpl.java
+++ b/java/compiler/impl/src/com/intellij/compiler/CompilerConfigurationImpl.java
@@ -1,4 +1,6 @@
-// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
+/*
+ * Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
+ */
package com.intellij.compiler;
import com.intellij.CommonBundle;
@@ -824,7 +826,7 @@ public class CompilerConfigurationImpl extends CompilerConfiguration implements
Element bytecodeTargetElement = parentNode.getChild(JpsJavaCompilerConfigurationSerializer.BYTECODE_TARGET_LEVEL);
if (bytecodeTargetElement != null) {
myBytecodeTargetLevel = bytecodeTargetElement.getAttributeValue(JpsJavaCompilerConfigurationSerializer.TARGET_ATTRIBUTE);
- readByteTargetLevel(parentNode);
+ readByteTargetLevel(parentNode, myModuleBytecodeTarget);
}
Map externalState = myProject.getComponent(ExternalCompilerConfigurationStorage.class).getLoadedState();
diff --git a/java/compiler/impl/src/com/intellij/compiler/ExternalCompilerConfigurationStorage.kt b/java/compiler/impl/src/com/intellij/compiler/ExternalCompilerConfigurationStorage.kt
index c7e85cefed90..d18a25640d26 100644
--- a/java/compiler/impl/src/com/intellij/compiler/ExternalCompilerConfigurationStorage.kt
+++ b/java/compiler/impl/src/com/intellij/compiler/ExternalCompilerConfigurationStorage.kt
@@ -1,4 +1,6 @@
-// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
+/*
+ * Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
+ */
package com.intellij.compiler
import com.intellij.openapi.components.PersistentStateComponent
@@ -36,7 +38,9 @@ internal class ExternalCompilerConfigurationStorage(private val project: Project
}
override fun loadState(state: Element) {
- loadedState = readByteTargetLevel(state)
+ val result = THashMap()
+ readByteTargetLevel(state, result)
+ loadedState = result
}
override fun getExternalSource(): ProjectModelExternalSource? {
@@ -73,13 +77,11 @@ internal fun writeBytecodeTarget(moduleNames: List, map: Map {
- val result = THashMap()
- val bytecodeTargetElement = parentNode.getChild(JpsJavaCompilerConfigurationSerializer.BYTECODE_TARGET_LEVEL) ?: return result
+internal fun readByteTargetLevel(parentNode: Element, result: MutableMap) {
+ val bytecodeTargetElement = parentNode.getChild(JpsJavaCompilerConfigurationSerializer.BYTECODE_TARGET_LEVEL) ?: return
for (element in bytecodeTargetElement.getChildren(JpsJavaCompilerConfigurationSerializer.MODULE)) {
val name = element.getAttributeValue(JpsJavaCompilerConfigurationSerializer.NAME) ?: continue
val target = element.getAttributeValue(JpsJavaCompilerConfigurationSerializer.TARGET_ATTRIBUTE) ?: continue
result.put(name, target)
}
- return result
}
\ No newline at end of file
diff --git a/java/compiler/tests/com/intellij/compiler/CompilerConfigurationTest.java b/java/compiler/tests/com/intellij/compiler/CompilerConfigurationTest.java
index 4e8a6472c8b8..62576ac24e28 100644
--- a/java/compiler/tests/com/intellij/compiler/CompilerConfigurationTest.java
+++ b/java/compiler/tests/com/intellij/compiler/CompilerConfigurationTest.java
@@ -6,12 +6,17 @@ package com.intellij.compiler;
import com.intellij.module.ModuleGroupTestsKt;
import com.intellij.openapi.module.Module;
import com.intellij.testFramework.PlatformTestCase;
+import org.jdom.JDOMException;
import org.jetbrains.jps.model.java.compiler.ProcessorConfigProfile;
import org.jetbrains.jps.model.java.impl.compiler.ProcessorConfigProfileImpl;
+import java.io.IOException;
import java.util.Arrays;
import java.util.List;
+import static com.intellij.testFramework.assertions.Assertions.assertThat;
+import static com.intellij.util.JdomKt.loadElement;
+
public class CompilerConfigurationTest extends PlatformTestCase {
public void testUpdateTargetLevelOnModuleRename() {
Module module = createModule("foo");
@@ -22,6 +27,25 @@ public class CompilerConfigurationTest extends PlatformTestCase {
assertEquals("1.6", getConfiguration().getBytecodeTargetLevel(module));
}
+ public void testLoadState() throws IOException, JDOMException {
+ Module module = createModule("foo");
+ CompilerConfigurationImpl configuration = getConfiguration();
+ configuration.setBytecodeTargetLevel(module, "1.6");
+ assertThat(configuration.getState()).isEqualTo("\n" +
+ " \n" +
+ " \n" +
+ " \n" +
+ "");
+
+ configuration.loadState(loadElement("\n" +
+ " \n" +
+ " \n" +
+ " \n" +
+ ""));
+
+ assertThat(configuration.getBytecodeTargetLevel(module)).isEqualTo("1.7");
+ }
+
public void testUpdateOptionsOnModuleRename() {
Module module = createModule("foo");
List options = Arrays.asList("-nowarn");