diff --git a/compiler/testData/compileKotlinAgainstBinariesCustom/brokenJarWithNoClassForObjectProperty/broken.jar b/compiler/testData/compileKotlinAgainstBinariesCustom/brokenJarWithNoClassForObjectProperty/broken.jar
index dea7e1716a8..c525df804cb 100644
Binary files a/compiler/testData/compileKotlinAgainstBinariesCustom/brokenJarWithNoClassForObjectProperty/broken.jar and b/compiler/testData/compileKotlinAgainstBinariesCustom/brokenJarWithNoClassForObjectProperty/broken.jar differ
diff --git a/compiler/testData/compileKotlinAgainstBinariesCustom/duplicateObjectInBinaryAndSources/objectBinaries.jar b/compiler/testData/compileKotlinAgainstBinariesCustom/duplicateObjectInBinaryAndSources/objectBinaries.jar
index f59e659dc74..b0b5c56fa9a 100644
Binary files a/compiler/testData/compileKotlinAgainstBinariesCustom/duplicateObjectInBinaryAndSources/objectBinaries.jar and b/compiler/testData/compileKotlinAgainstBinariesCustom/duplicateObjectInBinaryAndSources/objectBinaries.jar differ
diff --git a/compiler/testData/compileKotlinAgainstCustomBinaries/duplicateLibraries/DuplicateLibTest-1.jar b/compiler/testData/compileKotlinAgainstCustomBinaries/duplicateLibraries/DuplicateLibTest-1.jar
index 638144d94a4..e9c28a7f36d 100644
Binary files a/compiler/testData/compileKotlinAgainstCustomBinaries/duplicateLibraries/DuplicateLibTest-1.jar and b/compiler/testData/compileKotlinAgainstCustomBinaries/duplicateLibraries/DuplicateLibTest-1.jar differ
diff --git a/compiler/testData/compileKotlinAgainstCustomBinaries/duplicateLibraries/DuplicateLibTest-2.jar b/compiler/testData/compileKotlinAgainstCustomBinaries/duplicateLibraries/DuplicateLibTest-2.jar
index 638144d94a4..e9c28a7f36d 100644
Binary files a/compiler/testData/compileKotlinAgainstCustomBinaries/duplicateLibraries/DuplicateLibTest-2.jar and b/compiler/testData/compileKotlinAgainstCustomBinaries/duplicateLibraries/DuplicateLibTest-2.jar differ
diff --git a/compiler/testData/compileKotlinAgainstCustomBinaries/missingEnumReferencedInAnnotation/MissingEnum.jar b/compiler/testData/compileKotlinAgainstCustomBinaries/missingEnumReferencedInAnnotation/MissingEnum.jar
index afdaa84cedd..bd34d7a66ae 100644
Binary files a/compiler/testData/compileKotlinAgainstCustomBinaries/missingEnumReferencedInAnnotation/MissingEnum.jar and b/compiler/testData/compileKotlinAgainstCustomBinaries/missingEnumReferencedInAnnotation/MissingEnum.jar differ
diff --git a/generators/generators.iml b/generators/generators.iml
index fa0ffa7a831..4787edce5ae 100644
--- a/generators/generators.iml
+++ b/generators/generators.iml
@@ -21,6 +21,7 @@
+
diff --git a/generators/src/org/jetbrains/jet/generators/tests/CompileBinaryTestData.kt b/generators/src/org/jetbrains/jet/generators/tests/CompileBinaryTestData.kt
new file mode 100644
index 00000000000..150fce75427
--- /dev/null
+++ b/generators/src/org/jetbrains/jet/generators/tests/CompileBinaryTestData.kt
@@ -0,0 +1,128 @@
+/*
+ * Copyright 2010-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jetbrains.jet.generators.tests
+
+import java.io.File
+import com.intellij.openapi.util.SystemInfo
+import com.intellij.openapi.util.io.FileUtil
+import java.lang.annotation.Retention
+import java.lang.annotation.RetentionPolicy
+
+var cwd = File("")
+fun mv(from: String, to: String) = File(cwd, from).renameTo(File(cwd, to))
+fun cp(from: String, to: String) = File(cwd, from).copyTo(File(cwd, to))
+fun rm(path: String) = FileUtil.delete(File(cwd, path))
+
+fun runProcess(cmd: String) {
+ val process = Runtime.getRuntime().exec(cmd)
+ process.waitFor()
+ process.getInputStream()?.reader()?.forEachLine { println(it) }
+ process.getErrorStream()?.reader()?.forEachLine { System.err.println(it) }
+ if (process.exitValue() != 0) {
+ System.err.println("Exit code ${process.exitValue()} was returned by: $cmd")
+ }
+}
+
+fun jar(dest: String, src: String) {
+ runProcess("jar cvf $cwd/$dest -C $cwd $src")
+}
+
+Retention(RetentionPolicy.RUNTIME)
+private annotation class GenScript(val dir: String, val source: String, val binary: String)
+
+private object BinaryTestData {
+ GenScript("compiler/testData/compileKotlinAgainstBinariesCustom/brokenJarWithNoClassForObjectProperty", "source.kt", "broken.jar")
+ fun genBrokenJarWithNoClassForObjectProperty() {
+ rm("test/Lol.class")
+ jar("broken.jar", "test")
+ rm("test")
+ }
+
+ GenScript("compiler/testData/compileKotlinAgainstBinariesCustom/duplicateObjectInBinaryAndSources", "source.kt", "objectBinaries.jar")
+ fun genDuplicateObjectInBinaryAndSources() {
+ jar("objectBinaries.jar", "test")
+ rm("test")
+ }
+
+ GenScript("compiler/testData/compileKotlinAgainstCustomBinaries/duplicateLibraries", "DuplicateTest.kt", "DuplicateLibTest-1.jar")
+ fun genDuplicateLibraries() {
+ jar("DuplicateLibTest-1.jar", "testing")
+ cp("DuplicateLibTest-1.jar", "DuplicateLibTest-2.jar")
+ rm("testing")
+ }
+
+ GenScript("compiler/testData/compileKotlinAgainstCustomBinaries/missingEnumReferencedInAnnotation", "MissingEnum.kt", "MissingEnum.jar")
+ fun genMissingEnumReferencedInAnnotation() {
+ rm("test/E.class")
+ jar("MissingEnum.jar", "test")
+ rm("test")
+ }
+
+ GenScript("idea/testData/codeInsight/overrideImplement/withLib", "source.kt", "fakeOverride.jar")
+ fun genFakeOverride() {
+ jar("fakeOverride.jar", "dependency")
+ rm("dependency")
+ }
+
+ GenScript("idea/testData/completion/basic/custom/", "TopLevelNonImportedExtFunSource.kt", "TopLevelNonImportedExtFun.jar")
+ fun genTopLevelNonImportedExtFun() {
+ jar("TopLevelNonImportedExtFun.jar", "abc")
+ rm("abc")
+ }
+
+ GenScript("idea/testData/completion/basic/custom/", "TopLevelNonImportedFunSource.kt", "TopLevelNonImportedFun.jar")
+ fun genTopLevelNonImportedFun() {
+ jar("TopLevelNonImportedFun.jar", "abc")
+ rm("abc")
+ }
+}
+
+fun changeDirectory(dir: String) {
+ cwd = File(dir)
+}
+
+fun deleteBinary(file: String) = rm(file)
+
+fun compileSource(src: String) {
+ // We assume that ${script.source}.txt file exists and contains the source to compile. Kotlin compiler would not compile the source
+ // with the ".txt" extension, so we temporarily rename this file to ${script.source} (it should end with ".kt")
+ assert(src.endsWith(".kt"), "Source should have a '.kt' extension: $src")
+ mv("$src.txt", src)
+ try {
+ runProcess("dist/kotlinc/bin/kotlinc-jvm${if (SystemInfo.isWindows) ".bat" else ""} -src $cwd/$src -output $cwd")
+ }
+ finally {
+ mv(src, "$src.txt")
+ }
+}
+
+fun main(args: Array) {
+ System.setProperty("java.awt.headless", "true")
+ for (method in javaClass().getDeclaredMethods()) {
+ val script = method.getAnnotation(javaClass()) as? GenScript ?: continue
+
+ println()
+ println("---------------------------------")
+ println("Processing: ${script.dir}")
+
+ changeDirectory(script.dir)
+ deleteBinary(script.binary)
+ compileSource(script.source)
+
+ method.invoke(BinaryTestData)
+ }
+}
diff --git a/idea/testData/codeInsight/overrideImplement/withLib/fakeOverride.jar b/idea/testData/codeInsight/overrideImplement/withLib/fakeOverride.jar
index 589ae2c8f41..5d4aeefb604 100644
Binary files a/idea/testData/codeInsight/overrideImplement/withLib/fakeOverride.jar and b/idea/testData/codeInsight/overrideImplement/withLib/fakeOverride.jar differ
diff --git a/idea/testData/completion/basic/custom/TopLevelNonImportedExtFun.jar b/idea/testData/completion/basic/custom/TopLevelNonImportedExtFun.jar
index c188655e547..37b7d3b6c61 100644
Binary files a/idea/testData/completion/basic/custom/TopLevelNonImportedExtFun.jar and b/idea/testData/completion/basic/custom/TopLevelNonImportedExtFun.jar differ
diff --git a/idea/testData/completion/basic/custom/TopLevelNonImportedExtFunSrc/abc.kt b/idea/testData/completion/basic/custom/TopLevelNonImportedExtFunSource.kt.txt
similarity index 75%
rename from idea/testData/completion/basic/custom/TopLevelNonImportedExtFunSrc/abc.kt
rename to idea/testData/completion/basic/custom/TopLevelNonImportedExtFunSource.kt.txt
index cd2a1b8f239..5a59cd4d890 100644
--- a/idea/testData/completion/basic/custom/TopLevelNonImportedExtFunSrc/abc.kt
+++ b/idea/testData/completion/basic/custom/TopLevelNonImportedExtFunSource.kt.txt
@@ -6,4 +6,4 @@ public fun abcdBBB2(i: Int) {}
public fun Int.abcdCCC3() {}
-public fun Int.abcdDDD4(i: Int) {}
\ No newline at end of file
+public fun Int.abcdDDD4(i: Int) {}
diff --git a/idea/testData/completion/basic/custom/TopLevelNonImportedFun.jar b/idea/testData/completion/basic/custom/TopLevelNonImportedFun.jar
index 5c5910a1aa1..5a6d86533bb 100644
Binary files a/idea/testData/completion/basic/custom/TopLevelNonImportedFun.jar and b/idea/testData/completion/basic/custom/TopLevelNonImportedFun.jar differ
diff --git a/idea/testData/completion/basic/custom/TopLevelNonImportedFunSrc/abc.kt b/idea/testData/completion/basic/custom/TopLevelNonImportedFunSource.kt.txt
similarity index 75%
rename from idea/testData/completion/basic/custom/TopLevelNonImportedFunSrc/abc.kt
rename to idea/testData/completion/basic/custom/TopLevelNonImportedFunSource.kt.txt
index cd2a1b8f239..5a59cd4d890 100644
--- a/idea/testData/completion/basic/custom/TopLevelNonImportedFunSrc/abc.kt
+++ b/idea/testData/completion/basic/custom/TopLevelNonImportedFunSource.kt.txt
@@ -6,4 +6,4 @@ public fun abcdBBB2(i: Int) {}
public fun Int.abcdCCC3() {}
-public fun Int.abcdDDD4(i: Int) {}
\ No newline at end of file
+public fun Int.abcdDDD4(i: Int) {}