CLI: include META-INF/services/ from kotlin-reflect with -include-runtime

This is an addition to bd205317aa where we
started to add the contents of kotlin-reflect into the resulting jar if
-include-runtime is specified. Apparently kotlin-reflect doesn't work
without some services in META-INF/services/, which didn't satisfy the
condition for inclusion. The existing test didn't catch that because
loading class annotations does not always lead to those services being
loaded.
This commit is contained in:
Alexander Udalov
2021-02-04 13:25:07 +01:00
parent 3dfd2a95fa
commit e6588ee8a4
2 changed files with 11 additions and 5 deletions
@@ -33,7 +33,8 @@ import org.jetbrains.kotlin.utils.ExceptionUtilsKt;
import org.jetbrains.kotlin.utils.PathUtil;
import java.io.*;
import java.util.*;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.jar.*;
import static org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity.ERROR;
@@ -144,11 +145,13 @@ public class CompileEnvironmentUtil {
JarEntry e = jis.getNextJarEntry();
if (e == null) break;
if ((!FileUtilRt.extensionEquals(e.getName(), "class") &&
!FileUtilRt.extensionEquals(e.getName(), BuiltInSerializerProtocol.BUILTINS_FILE_EXTENSION)) ||
StringsKt.substringAfterLast(e.getName(), "/", e.getName()).equals("module-info.class")) {
String name = e.getName();
if (!FileUtilRt.extensionEquals(name, "class") &&
!FileUtilRt.extensionEquals(name, BuiltInSerializerProtocol.BUILTINS_FILE_EXTENSION) &&
!name.startsWith("META-INF/services/")) {
continue;
}
if (StringsKt.substringAfterLast(name, "/", name).equals("module-info.class")) continue;
if (resetJarTimestamps) {
e.setTime(DOS_EPOCH);
}
+4 -1
View File
@@ -1,5 +1,8 @@
package reflect
import kotlin.reflect.jvm.kotlinFunction
fun main() {
String::class.annotations
}
KotlinVersion::class.java.methods.first().kotlinFunction
}