Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ name: Release Binary Package
on:
push:
tags:
- "v*.*.*"
- "v*"

jobs:
build:
Expand Down
7 changes: 5 additions & 2 deletions kotlin/internal/jvm/kover.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,11 @@ def get_kover_jvm_flags(kover_agent_files, kover_args_file):
returns:
the flag string to be used by test runner jvm
"""

return "-javaagent:%s=file:%s" % (kover_agent_files[0].short_path, kover_args_file.short_path)
jvm_args = [
"-Xbootclasspath/a:%s" % (kover_agent_files[0].short_path),
"-javaagent:%s=file:%s" % (kover_agent_files[0].short_path, kover_args_file.short_path)
]
return " ".join(jvm_args)

def create_kover_agent_actions(ctx, name):
""" Generate the actions needed to emit Kover code coverage metadata file. It creates
Expand Down
54 changes: 44 additions & 10 deletions src/main/kotlin/io/bazel/kotlin/plugin/jdeps/k2/JdepsK2Utils.kt
Original file line number Diff line number Diff line change
@@ -1,23 +1,49 @@
package io.bazel.kotlin.plugin.jdeps.k2

import io.bazel.kotlin.plugin.jdeps.k2.RefCache.vbseClass
import io.bazel.kotlin.plugin.jdeps.k2.RefCache.vbseGetVirtualFileMethod
import org.jetbrains.kotlin.descriptors.SourceElement
import org.jetbrains.kotlin.fir.expressions.FirPropertyAccessExpression
import org.jetbrains.kotlin.fir.expressions.FirQualifiedAccessExpression
import org.jetbrains.kotlin.fir.java.JavaBinarySourceElement
import org.jetbrains.kotlin.load.kotlin.JvmPackagePartSource
import org.jetbrains.kotlin.load.kotlin.KotlinJvmBinarySourceElement
import org.jetbrains.kotlin.name.ClassId
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedContainerSource

private object RefCache {
val vbseClass: Class<*>? by lazy {
runCatching {
Class.forName("org.jetbrains.kotlin.fir.java.VirtualFileBasedSourceElement")
}.getOrNull()
}

val vbseGetVirtualFileMethod by lazy {
vbseClass
?.runCatching {
getMethod("getVirtualFile")
}?.getOrNull()
}

val jbseClass: Class<*>? by lazy {
runCatching {
Class.forName("org.jetbrains.kotlin.fir.java.JavaBinarySourceElement")
}.getOrNull()
}

val jbseGetJavaClassMethod by lazy {
jbseClass
?.runCatching {
getMethod("getJavaClass")
}?.getOrNull()
}
}

/**
* Returns whether class is coming from JVM runtime env. There is no need to track these classes.
*
* @param className the class name of the class
* @return whether class is provided by JSM runtime or not
*/
internal fun isJvmClass(className: String): Boolean =
className.startsWith("java") ||
className.startsWith("modules/java.base/java/")
className.startsWith("java") || className.startsWith("modules/java.base/java/")

internal fun DeserializedContainerSource.classId(): ClassId? =
when (this) {
Expand All @@ -27,11 +53,19 @@ internal fun DeserializedContainerSource.classId(): ClassId? =
}

internal fun SourceElement.binaryClass(): String? =
when (this) {
is KotlinJvmBinarySourceElement -> binaryClass.location
is JvmPackagePartSource -> this.knownJvmBinaryClass?.location
is JavaBinarySourceElement -> this.javaClass.virtualFile.path
else -> null
if (this is KotlinJvmBinarySourceElement) {
binaryClass.location
} else if (this is JvmPackagePartSource) {
this.knownJvmBinaryClass?.location
} else if (vbseClass != null && vbseClass!!.isInstance(this)) {
val virtualFile = vbseGetVirtualFileMethod!!.invoke(this)
virtualFile?.javaClass!!.getMethod("getPath").invoke(virtualFile) as? String
} else if (RefCache.jbseClass != null && RefCache.jbseClass!!.isInstance(this)) {
val jClass = RefCache.jbseGetJavaClassMethod!!.invoke(this)
val virtualFile = jClass!!.javaClass.getMethod("getVirtualFile").invoke(jClass)
virtualFile.javaClass.getMethod("getPath").invoke(virtualFile) as? String
} else {
null
}

internal fun DeserializedContainerSource.binaryClass(): String? =
Expand Down