Hi,
I have been trying to update a (very!) old code-base from FastClasspathScanner 2.18.1 to ClassGraph 4.8.52. This code must be able to scan Kotlin as well as Java classes, and while I have replicated most of the functionality, I am still struggling to persuade ClassGraph to handle this:
class HasJvmField {
@JvmField
val stringValue = "Hello World"
}
The problem is that ClassGraph doesn't realise that this field has an initialier, whereas FastClasspathScanner did. The Kotlin compiler generates the following byte-code for this case:
public final java.lang.String stringValue;
descriptor: Ljava/lang/String;
flags: ACC_PUBLIC, ACC_FINAL
ConstantValue: String Hello World
RuntimeInvisibleAnnotations:
0: #9()
1: #10()
#9 = Utf8 Lkotlin/jvm/JvmField;
#10 = Utf8 Lorg/jetbrains/annotations/NotNull;
I suspect this is because stringValue is not a static field and so enabling
.enableStaticFinalFieldConstantInitializerValues()
does not help me here.
Is there a workaround for this please?
Hi,
I have been trying to update a (very!) old code-base from FastClasspathScanner 2.18.1 to ClassGraph 4.8.52. This code must be able to scan Kotlin as well as Java classes, and while I have replicated most of the functionality, I am still struggling to persuade ClassGraph to handle this:
The problem is that ClassGraph doesn't realise that this field has an initialier, whereas FastClasspathScanner did. The Kotlin compiler generates the following byte-code for this case:
I suspect this is because
stringValueis not astaticfield and so enabling.enableStaticFinalFieldConstantInitializerValues()does not help me here.
Is there a workaround for this please?