mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 08:14:09 -08:00
Fix compilation of Kotlin code when there's kotlin-reflect library in the classpath, but it's actually not used by Kotlin code. See #345
This commit is contained in:
parent
cdffb779e0
commit
dc99ead514
|
@ -116,7 +116,7 @@ public class ClassForNameTransformer implements ClassHolderTransformer {
|
|||
if (nameIndex >= 0) {
|
||||
representative = program.variableAt(nameRepresentatives[nameIndex]);
|
||||
} else if (constant != null) {
|
||||
if (classSource.get(constant) == null) {
|
||||
if (classSource.get(constant) == null || !filterClassName(constant)) {
|
||||
continue;
|
||||
}
|
||||
ClassConstantInstruction classConstant = new ClassConstantInstruction();
|
||||
|
@ -148,4 +148,18 @@ public class ClassForNameTransformer implements ClassHolderTransformer {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean filterClassName(String className) {
|
||||
switch (className) {
|
||||
// It's a hack for Kotlin. Kotlin full reflection library is too heavyweight for TeaVM.
|
||||
// This optimization enables full reflection when there's Kotlin/JVM reflection library
|
||||
// in the classpath, since Kotlin uses Class.forName() to check whether there's
|
||||
// full reflection library presents. If program does not use full reflection,
|
||||
// but build configuration includes kotlin-reflect artifact as a dependency,
|
||||
// it gets into classpath, which allows this optimization to be applied.
|
||||
case "kotlin.reflect.jvm.internal.ReflectionFactoryImpl":
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user