Remove "legacy" mode of jvm-abi-gen plugin

#KT-55375 Fixed
This commit is contained in:
Alexander Udalov
2023-03-03 23:52:42 +01:00
committed by Space Team
parent 77c68fc809
commit 9f269b83aa
35 changed files with 10 additions and 864 deletions
@@ -461,10 +461,7 @@ public class FunctionCodegen {
boolean staticInCompanionObject
) {
OwnerKind contextKind = methodContext.getContextKind();
if (!state.getClassBuilderMode().generateBodies
|| isAbstractMethod(functionDescriptor, contextKind, state.getJvmDefaultMode())
|| shouldSkipMethodBodyInAbiMode(state.getClassBuilderMode(), origin)
) {
if (!state.getClassBuilderMode().generateBodies || isAbstractMethod(functionDescriptor, contextKind, state.getJvmDefaultMode())) {
generateLocalVariableTable(
mv,
jvmSignature,
@@ -497,13 +494,6 @@ public class FunctionCodegen {
endVisit(mv, null, origin.getElement());
}
private static boolean shouldSkipMethodBodyInAbiMode(@NotNull ClassBuilderMode classBuilderMode, @NotNull JvmDeclarationOrigin origin) {
if (classBuilderMode != ClassBuilderMode.ABI) return false;
DeclarationDescriptor descriptor = origin.getDescriptor();
return descriptor != null && !InlineUtil.isInlineOrContainingInline(descriptor);
}
public static void generateParameterAnnotations(
@NotNull FunctionDescriptor functionDescriptor,
@NotNull MethodVisitor mv,
@@ -179,24 +179,6 @@ fun main(args: Array<String>) {
}
}
testGroup(
"plugins/jvm-abi-gen/test", "plugins/jvm-abi-gen/testData",
testRunnerMethodName = "runTestWithCustomIgnoreDirective",
additionalRunnerArguments = listOf("\"// IGNORE_BACKEND_LEGACY: \"")
) {
testClass<AbstractLegacyCompareJvmAbiTest> {
model("compare", recursive = false, extension = null, targetBackend = TargetBackend.JVM_IR)
}
testClass<AbstractLegacyJvmAbiContentTest> {
model("content", recursive = false, extension = null, targetBackend = TargetBackend.JVM_IR)
}
testClass<AbstractLegacyCompileAgainstJvmAbiTest> {
model("compile", recursive = false, extension = null, targetBackend = TargetBackend.JVM_IR)
}
}
testGroup("plugins/sam-with-receiver/tests-gen", "plugins/sam-with-receiver/testData") {
testClass<AbstractSamWithReceiverScriptTest> {
model("script", extension = "kts")
@@ -1,239 +0,0 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.jvm.abi
import com.intellij.openapi.project.Project
import com.intellij.openapi.util.io.FileUtil
import org.jetbrains.kotlin.analyzer.AnalysisResult
import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity
import org.jetbrains.kotlin.cli.common.messages.MessageRenderer
import org.jetbrains.kotlin.cli.common.messages.OutputMessageUtil
import org.jetbrains.kotlin.cli.common.messages.PrintingMessageCollector
import org.jetbrains.kotlin.codegen.*
import org.jetbrains.kotlin.codegen.state.GenerationState
import org.jetbrains.kotlin.compilerRunner.OutputItemsCollector
import org.jetbrains.kotlin.config.CommonConfigurationKeys
import org.jetbrains.kotlin.config.CompilerConfiguration
import org.jetbrains.kotlin.config.JVMConfigurationKeys
import org.jetbrains.kotlin.config.languageVersionSettings
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
import org.jetbrains.kotlin.diagnostics.Severity
import org.jetbrains.kotlin.incremental.isClassFile
import org.jetbrains.kotlin.jvm.abi.asm.AbiClassBuilder
import org.jetbrains.kotlin.jvm.abi.asm.FilterInnerClassesVisitor
import org.jetbrains.kotlin.jvm.abi.asm.InnerClassesCollectingVisitor
import org.jetbrains.kotlin.load.kotlin.FileBasedKotlinClass
import org.jetbrains.kotlin.load.kotlin.header.KotlinClassHeader
import org.jetbrains.kotlin.metadata.ProtoBuf
import org.jetbrains.kotlin.metadata.deserialization.Flags
import org.jetbrains.kotlin.metadata.jvm.deserialization.JvmProtoBufUtil
import org.jetbrains.kotlin.modules.TargetId
import org.jetbrains.kotlin.name.ClassId
import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.resolve.BindingTrace
import org.jetbrains.kotlin.resolve.jvm.JvmClassName
import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOrigin
import org.jetbrains.kotlin.resolve.jvm.extensions.AnalysisHandlerExtension
import org.jetbrains.kotlin.utils.toMetadataVersion
import org.jetbrains.org.objectweb.asm.ClassReader
import org.jetbrains.org.objectweb.asm.ClassVisitor
import org.jetbrains.org.objectweb.asm.ClassWriter
import org.jetbrains.org.objectweb.asm.Opcodes
import java.io.File
import java.util.*
class JvmAbiAnalysisHandlerExtension(
compilerConfiguration: CompilerConfiguration
) : AnalysisHandlerExtension {
private val compilerConfiguration: CompilerConfiguration = compilerConfiguration.copy().apply {
put(JVMConfigurationKeys.IR, false)
}
override fun analysisCompleted(
project: Project,
module: ModuleDescriptor,
bindingTrace: BindingTrace,
files: Collection<KtFile>
): AnalysisResult? {
val bindingContext = bindingTrace.bindingContext
if (bindingContext.diagnostics.any { it.severity == Severity.ERROR }) return null
val targetId = TargetId(
name = compilerConfiguration[CommonConfigurationKeys.MODULE_NAME] ?: module.name.asString(),
type = "java-production"
)
val generationState = GenerationState.Builder(
project,
AbiBinaries,
module,
bindingContext,
compilerConfiguration
).targetId(targetId).build()
KotlinCodegenFacade.compileCorrectFiles(files, generationState, DefaultCodegenFactory)
val outputDir = compilerConfiguration.get(JVMConfigurationKeys.OUTPUT_DIRECTORY)!!
val outputs = ArrayList<AbiOutput>()
for (outputFile in generationState.factory.asList()) {
val file = File(outputDir, outputFile.relativePath)
outputs.add(AbiOutput(file, outputFile.sourceFiles, outputFile.asByteArray()))
}
// private/local/synthetic class removal is temporarily turned off, because the implementation
// was not correct: it was not taking into account that private/local classes could be used
// from inline functions
// todo: implement correct removal
//removeUnneededClasses(outputs)
val messageCollector = compilerConfiguration.get(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY)
?: PrintingMessageCollector(System.err, MessageRenderer.PLAIN_FULL_PATHS, false)
val reportOutputFiles = generationState.configuration.getBoolean(CommonConfigurationKeys.REPORT_OUTPUT_FILES)
val outputItemsCollector =
OutputItemsCollector { sourceFiles, outputFile ->
messageCollector.report(CompilerMessageSeverity.OUTPUT, OutputMessageUtil.formatOutputMessage(sourceFiles, outputFile))
}.takeIf { reportOutputFiles }
outputs.forEach { it.flush(outputItemsCollector) }
return null
}
/**
* Removes private or local classes from outputs
*/
// todo: fix usage (see analysisCompleted)
@Suppress("unused")
private fun removeUnneededClasses(outputs: Iterable<AbiOutput>) {
// maps internal names of classes: class -> inner classes
val innerClasses = HashMap<String, Collection<String>>()
val internalNameToFile = HashMap<String, File>()
for (output in outputs) {
if (!output.file.isClassFile()) continue
val visitor = InnerClassesCollectingVisitor()
output.accept(visitor)
val outputInternalName = visitor.ownInternalName
internalNameToFile[outputInternalName] = output.file
innerClasses[outputInternalName] = visitor.innerClasses
}
// internal names of removed files
val classesToRemoveQueue = ArrayDeque<String>()
for (output in outputs) {
if (!output.file.isClassFile()) continue
val classData = output.classData(compilerConfiguration) ?: continue
val header = classData.classHeader
val isNeededForAbi = when (header.kind) {
KotlinClassHeader.Kind.CLASS -> {
val (_, classProto) = JvmProtoBufUtil.readClassDataFrom(header.data!!, header.strings!!)
val visibility = Flags.VISIBILITY.get(classProto.flags)
visibility != ProtoBuf.Visibility.PRIVATE && visibility != ProtoBuf.Visibility.LOCAL
}
KotlinClassHeader.Kind.SYNTHETIC_CLASS -> false
else -> true
}
if (!isNeededForAbi) {
val jvmClassName = JvmClassName.byClassId(classData.classId)
classesToRemoveQueue.add(jvmClassName.internalName)
}
}
// we can remove inner classes of removed classes
val classesToRemove = HashSet<String>()
classesToRemove.addAll(classesToRemoveQueue)
while (classesToRemoveQueue.isNotEmpty()) {
val classToRemove = classesToRemoveQueue.removeFirst()
innerClasses[classToRemove]?.forEach {
if (classesToRemove.add(it)) {
classesToRemoveQueue.add(it)
}
}
}
val classFilesToRemove = classesToRemove.mapTo(HashSet()) { internalNameToFile[it] }
for (output in outputs) {
if (!output.file.isClassFile()) continue
if (output.file in classFilesToRemove) {
output.delete()
} else {
output.transform { writer ->
FilterInnerClassesVisitor(classesToRemove, Opcodes.API_VERSION, writer)
}
}
}
}
private object AbiBinaries : ClassBuilderFactory {
override fun getClassBuilderMode(): ClassBuilderMode =
ClassBuilderMode.ABI
override fun newClassBuilder(origin: JvmDeclarationOrigin): ClassBuilder =
AbiClassBuilder(ClassWriter(0))
override fun asText(builder: ClassBuilder): String =
throw UnsupportedOperationException("AbiBinaries generator asked for text")
override fun asBytes(builder: ClassBuilder): ByteArray {
val visitor = builder.visitor as ClassWriter
return visitor.toByteArray()
}
override fun close() {}
}
private data class ClassData(
val classId: ClassId,
val classVersion: Int,
val classHeader: KotlinClassHeader
)
private class AbiOutput(
val file: File,
val sources: List<File>,
// null bytes means that file should not be written
private var bytes: ByteArray?
) {
fun classData(compilerConfiguration: CompilerConfiguration): ClassData? =
when {
bytes == null -> null
!file.isClassFile() -> null
else -> FileBasedKotlinClass.create(
bytes!!, compilerConfiguration.languageVersionSettings.languageVersion.toMetadataVersion()
) { classId, classVersion, classHeader, _ ->
ClassData(classId, classVersion, classHeader)
}
}
fun delete() {
bytes = null
}
fun transform(fn: (writer: ClassWriter) -> ClassVisitor) {
val bytes = bytes ?: return
val cr = ClassReader(bytes)
val cw = ClassWriter(0)
val visitor = fn(cw)
cr.accept(visitor, 0)
this.bytes = cw.toByteArray()
}
fun accept(visitor: ClassVisitor) {
val bytes = bytes ?: return
val cr = ClassReader(bytes)
cr.accept(visitor, 0)
}
fun flush(outputItemsCollector: OutputItemsCollector?) {
val bytes = bytes ?: return
outputItemsCollector?.add(sources, file)
FileUtil.writeToFile(file, bytes)
}
}
}
@@ -22,27 +22,18 @@ class JvmAbiCommandLineProcessor : CommandLineProcessor {
"Output path for generated files. This can be either a directory or a jar file.",
true
)
val LEGACY_ABI_GEN_OPTION: CliOption =
CliOption(
"useLegacyAbiGen",
"true|false",
"Use the legacy two pass implementation of jvm-abi-gen.",
false
)
}
override val pluginId: String
get() = COMPILER_PLUGIN_ID
override val pluginOptions: Collection<CliOption>
get() = listOf(OUTPUT_PATH_OPTION, LEGACY_ABI_GEN_OPTION)
get() = listOf(OUTPUT_PATH_OPTION)
override fun processOption(option: AbstractCliOption, value: String, configuration: CompilerConfiguration) {
when (option) {
OUTPUT_PATH_OPTION -> configuration.put(JvmAbiConfigurationKeys.OUTPUT_PATH, value)
LEGACY_ABI_GEN_OPTION -> configuration.put(JvmAbiConfigurationKeys.LEGACY_ABI_GEN, value == "true")
else -> throw CliOptionProcessingException("Unknown option: ${option.optionName}")
}
}
}
}
@@ -6,47 +6,23 @@
package org.jetbrains.kotlin.jvm.abi
import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity
import org.jetbrains.kotlin.cli.common.messages.MessageCollector
import org.jetbrains.kotlin.codegen.extensions.ClassBuilderInterceptorExtension
import org.jetbrains.kotlin.codegen.extensions.ClassFileFactoryFinalizerExtension
import org.jetbrains.kotlin.compiler.plugin.CompilerPluginRegistrar
import org.jetbrains.kotlin.config.CommonConfigurationKeys
import org.jetbrains.kotlin.config.CompilerConfiguration
import org.jetbrains.kotlin.config.JVMConfigurationKeys
import org.jetbrains.kotlin.resolve.jvm.extensions.AnalysisHandlerExtension
import java.io.File
class JvmAbiComponentRegistrar : CompilerPluginRegistrar() {
override fun ExtensionStorage.registerExtensions(configuration: CompilerConfiguration) {
val outputPath = configuration.getNotNull(JvmAbiConfigurationKeys.OUTPUT_PATH)
val messageCollector = configuration.get(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY, MessageCollector.NONE)
if (configuration.get(JvmAbiConfigurationKeys.LEGACY_ABI_GEN, false)) {
if (configuration.getBoolean(CommonConfigurationKeys.USE_FIR)) {
messageCollector.report(CompilerMessageSeverity.ERROR, "Legacy jvm-abi-gen does not support K2 compiler.")
} else {
messageCollector.report(
CompilerMessageSeverity.STRONG_WARNING,
"Legacy jvm-abi-gen is deprecated and will be removed in a future version. " +
"Please migrate to the new jvm-abi-gen implementation."
)
}
// Use the two-pass implementation
if (outputPath.endsWith(".jar")) {
messageCollector.report(CompilerMessageSeverity.ERROR, "Legacy jvm-abi-gen does not support jar output.")
}
val extension = JvmAbiAnalysisHandlerExtension(configuration.copy().apply {
put(JVMConfigurationKeys.OUTPUT_DIRECTORY, File(outputPath))
})
AnalysisHandlerExtension.registerExtension(extension)
} else {
// Use the single-pass implementation, using the new ABI flag in the metadata.
configuration.put(JVMConfigurationKeys.RETAIN_OUTPUT_IN_MEMORY, true)
val builderExtension = JvmAbiClassBuilderInterceptor()
val outputExtension = JvmAbiOutputExtension(File(outputPath), builderExtension.abiClassInfo, messageCollector)
ClassBuilderInterceptorExtension.registerExtension( builderExtension)
ClassFileFactoryFinalizerExtension.registerExtension( outputExtension)
}
configuration.put(JVMConfigurationKeys.RETAIN_OUTPUT_IN_MEMORY, true)
val builderExtension = JvmAbiClassBuilderInterceptor()
val outputExtension = JvmAbiOutputExtension(File(outputPath), builderExtension.abiClassInfo, messageCollector)
ClassBuilderInterceptorExtension.registerExtension(builderExtension)
ClassFileFactoryFinalizerExtension.registerExtension(outputExtension)
}
override val supportsK2: Boolean
@@ -9,8 +9,5 @@ import org.jetbrains.kotlin.config.CompilerConfigurationKey
object JvmAbiConfigurationKeys {
val OUTPUT_PATH: CompilerConfigurationKey<String> =
CompilerConfigurationKey.create<String>(JvmAbiCommandLineProcessor.OUTPUT_PATH_OPTION.description)
val LEGACY_ABI_GEN: CompilerConfigurationKey<Boolean> =
CompilerConfigurationKey.create<Boolean>(JvmAbiCommandLineProcessor.LEGACY_ABI_GEN_OPTION.description)
}
CompilerConfigurationKey.create(JvmAbiCommandLineProcessor.OUTPUT_PATH_OPTION.description)
}
@@ -1,88 +0,0 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.jvm.abi.asm
import com.intellij.psi.PsiElement
import org.jetbrains.kotlin.codegen.AbstractClassBuilder
import org.jetbrains.kotlin.descriptors.MemberDescriptor
import org.jetbrains.kotlin.descriptors.DescriptorVisibilities
import org.jetbrains.kotlin.resolve.inline.InlineUtil.isInlineOrContainingInline
import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOrigin
import org.jetbrains.org.objectweb.asm.ClassVisitor
import org.jetbrains.org.objectweb.asm.FieldVisitor
import org.jetbrains.org.objectweb.asm.MethodVisitor
import org.jetbrains.org.objectweb.asm.Opcodes
internal class AbiClassBuilder(private val cv: ClassVisitor) : AbstractClassBuilder() {
override fun getVisitor(): ClassVisitor = cv
override fun newMethod(
origin: JvmDeclarationOrigin,
access: Int,
name: String,
desc: String,
signature: String?,
exceptions: Array<out String>?
): MethodVisitor {
// if both descriptor's and access's visibilities are private, we can generate an empty method
// 1. we need to check a descriptor, because inline reified functions
// might have a non-private visibility in ABI, but they are private in bytecode
// 2. we need to check an access, because synthetic methods
// for default parameters have private visibility, but public in bytecode
val descriptor = origin.descriptor as? MemberDescriptor
if (isPrivate(access) && descriptor != null && isPrivate(descriptor) || isClinit(name, access)) return EMPTY_METHOD_VISITOR
val mv = super.newMethod(origin, access, name, desc, signature, exceptions)
// inline function bodies are part of ABI,
// but non-inline functions can be thrown out
if (isInlineOrContainingInline(descriptor)) return mv
return ReplaceWithEmptyMethodVisitor(
delegate = mv,
access = access,
name = name,
desc = desc,
signature = signature,
exceptions = exceptions
)
}
override fun newField(
origin: JvmDeclarationOrigin,
access: Int,
name: String,
desc: String,
signature: String?,
value: Any?
): FieldVisitor {
if (isPrivate(access) && !isInlineOrContainingInline(origin.descriptor)) return EMPTY_FIELD_VISITOR
return super.newField(origin, access, name, desc, signature, value)
}
override fun defineClass(
origin: PsiElement?,
version: Int,
access: Int,
name: String,
signature: String?,
superName: String,
interfaces: Array<out String>
) {
if (isPrivate(access)) return
super.defineClass(origin, version, access, name, signature, superName, interfaces)
}
private fun isPrivate(descriptor: MemberDescriptor): Boolean =
descriptor.visibility == DescriptorVisibilities.PRIVATE
private fun isPrivate(access: Int): Boolean =
(access and Opcodes.ACC_PRIVATE) == Opcodes.ACC_PRIVATE
private fun isClinit(name: String, access: Int): Boolean =
name == "<clinit>" && (access and Opcodes.ACC_STATIC) == Opcodes.ACC_STATIC
}
@@ -1,20 +0,0 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.jvm.abi.asm
import org.jetbrains.org.objectweb.asm.ClassVisitor
internal class FilterInnerClassesVisitor(
private val innerClassesToFilter: Set<String>,
api: Int,
cv: ClassVisitor
) : ClassVisitor(api, cv) {
override fun visitInnerClass(name: String, outerName: String?, innerName: String?, access: Int) {
if (name in innerClassesToFilter) return
super.visitInnerClass(name, outerName, innerName, access)
}
}
@@ -1,30 +0,0 @@
package org.jetbrains.kotlin.jvm.abi.asm
import org.jetbrains.org.objectweb.asm.ClassVisitor
import org.jetbrains.org.objectweb.asm.Opcodes
internal class InnerClassesCollectingVisitor : ClassVisitor(Opcodes.API_VERSION) {
lateinit var ownInternalName: String
private set
private val myInnerClasses = arrayListOf<String>()
val innerClasses: List<String>
get() = myInnerClasses
override fun visit(
version: Int,
access: Int,
name: String,
signature: String?,
superName: String?,
interfaces: Array<out String>?
) {
super.visit(version, access, name, signature, superName, interfaces)
ownInternalName = name
}
override fun visitInnerClass(name: String, outerName: String?, innerName: String?, access: Int) {
super.visitInnerClass(name, outerName, innerName, access)
myInnerClasses.add(name)
}
}
@@ -1,25 +0,0 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.jvm.abi.asm
import org.jetbrains.kotlin.codegen.TransformationMethodVisitor
import org.jetbrains.org.objectweb.asm.*
import org.jetbrains.org.objectweb.asm.tree.MethodNode
internal class ReplaceWithEmptyMethodVisitor(
delegate: MethodVisitor,
access: Int,
name: String,
desc: String,
signature: String?,
exceptions: Array<out String>?
) : TransformationMethodVisitor(delegate, access, name, desc, signature, exceptions, api = Opcodes.API_VERSION) {
override fun performTransformations(methodNode: MethodNode) {
methodNode.instructions.clear()
methodNode.localVariables.clear()
methodNode.tryCatchBlocks.clear()
}
}
@@ -1,11 +0,0 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.jvm.abi
abstract class AbstractLegacyCompareJvmAbiTest : AbstractCompareJvmAbiTest() {
override val useLegacyAbiGen: Boolean
get() = true
}
@@ -1,11 +0,0 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.jvm.abi
abstract class AbstractLegacyCompileAgainstJvmAbiTest : AbstractCompileAgainstJvmAbiTest() {
override val useLegacyAbiGen: Boolean
get() = true
}
@@ -1,11 +0,0 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.jvm.abi
abstract class AbstractLegacyJvmAbiContentTest : AbstractJvmAbiContentTest() {
override val useLegacyAbiGen: Boolean
get() = true
}
@@ -1,127 +0,0 @@
/*
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.jvm.abi;
import com.intellij.testFramework.TestDataPath;
import org.jetbrains.kotlin.test.JUnit3RunnerWithInners;
import org.jetbrains.kotlin.test.KotlinTestUtils;
import org.jetbrains.kotlin.test.util.KtTestUtil;
import org.jetbrains.kotlin.test.TargetBackend;
import org.jetbrains.kotlin.test.TestMetadata;
import org.junit.runner.RunWith;
import java.io.File;
import java.util.regex.Pattern;
/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.GenerateTestsKt}. DO NOT MODIFY MANUALLY */
@SuppressWarnings("all")
@TestMetadata("plugins/jvm-abi-gen/testData/compare")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public class LegacyCompareJvmAbiTestGenerated extends AbstractLegacyCompareJvmAbiTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTestWithCustomIgnoreDirective(this::doTest, TargetBackend.JVM_IR, testDataFilePath, "// IGNORE_BACKEND_LEGACY: ");
}
public void testAllFilesPresentInCompare() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("plugins/jvm-abi-gen/testData/compare"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, false);
}
@TestMetadata("anonymousObjects")
public void testAnonymousObjects() throws Exception {
runTest("plugins/jvm-abi-gen/testData/compare/anonymousObjects/");
}
@TestMetadata("classFlags")
public void testClassFlags() throws Exception {
runTest("plugins/jvm-abi-gen/testData/compare/classFlags/");
}
@TestMetadata("classPrivateMemebers")
public void testClassPrivateMemebers() throws Exception {
runTest("plugins/jvm-abi-gen/testData/compare/classPrivateMemebers/");
}
@TestMetadata("clinit")
public void testClinit() throws Exception {
runTest("plugins/jvm-abi-gen/testData/compare/clinit/");
}
@TestMetadata("constant")
public void testConstant() throws Exception {
runTest("plugins/jvm-abi-gen/testData/compare/constant/");
}
@TestMetadata("declarationOrderInline")
public void testDeclarationOrderInline() throws Exception {
runTest("plugins/jvm-abi-gen/testData/compare/declarationOrderInline/");
}
@TestMetadata("declarationOrderInlineCall")
public void testDeclarationOrderInlineCall() throws Exception {
runTest("plugins/jvm-abi-gen/testData/compare/declarationOrderInlineCall/");
}
@TestMetadata("declarationOrderPrivateInline")
public void testDeclarationOrderPrivateInline() throws Exception {
runTest("plugins/jvm-abi-gen/testData/compare/declarationOrderPrivateInline/");
}
@TestMetadata("functionBody")
public void testFunctionBody() throws Exception {
runTest("plugins/jvm-abi-gen/testData/compare/functionBody/");
}
@TestMetadata("inlineFunInPrivateClass")
public void testInlineFunInPrivateClass() throws Exception {
runTest("plugins/jvm-abi-gen/testData/compare/inlineFunInPrivateClass/");
}
@TestMetadata("inlineFunInPrivateNestedClass")
public void testInlineFunInPrivateNestedClass() throws Exception {
runTest("plugins/jvm-abi-gen/testData/compare/inlineFunInPrivateNestedClass/");
}
@TestMetadata("inlineFunctionBody")
public void testInlineFunctionBody() throws Exception {
runTest("plugins/jvm-abi-gen/testData/compare/inlineFunctionBody/");
}
@TestMetadata("lambdas")
public void testLambdas() throws Exception {
runTest("plugins/jvm-abi-gen/testData/compare/lambdas/");
}
@TestMetadata("parameterName")
public void testParameterName() throws Exception {
runTest("plugins/jvm-abi-gen/testData/compare/parameterName/");
}
@TestMetadata("privateTypealias")
public void testPrivateTypealias() throws Exception {
runTest("plugins/jvm-abi-gen/testData/compare/privateTypealias/");
}
@TestMetadata("returnType")
public void testReturnType() throws Exception {
runTest("plugins/jvm-abi-gen/testData/compare/returnType/");
}
@TestMetadata("superClass")
public void testSuperClass() throws Exception {
runTest("plugins/jvm-abi-gen/testData/compare/superClass/");
}
@TestMetadata("syntheticAccessors")
public void testSyntheticAccessors() throws Exception {
runTest("plugins/jvm-abi-gen/testData/compare/syntheticAccessors/");
}
@TestMetadata("topLevelPrivateMembers")
public void testTopLevelPrivateMembers() throws Exception {
runTest("plugins/jvm-abi-gen/testData/compare/topLevelPrivateMembers/");
}
}
@@ -1,137 +0,0 @@
/*
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.jvm.abi;
import com.intellij.testFramework.TestDataPath;
import org.jetbrains.kotlin.test.JUnit3RunnerWithInners;
import org.jetbrains.kotlin.test.KotlinTestUtils;
import org.jetbrains.kotlin.test.util.KtTestUtil;
import org.jetbrains.kotlin.test.TargetBackend;
import org.jetbrains.kotlin.test.TestMetadata;
import org.junit.runner.RunWith;
import java.io.File;
import java.util.regex.Pattern;
/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.GenerateTestsKt}. DO NOT MODIFY MANUALLY */
@SuppressWarnings("all")
@TestMetadata("plugins/jvm-abi-gen/testData/compile")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public class LegacyCompileAgainstJvmAbiTestGenerated extends AbstractLegacyCompileAgainstJvmAbiTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTestWithCustomIgnoreDirective(this::doTest, TargetBackend.JVM_IR, testDataFilePath, "// IGNORE_BACKEND_LEGACY: ");
}
public void testAllFilesPresentInCompile() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("plugins/jvm-abi-gen/testData/compile"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, false);
}
@TestMetadata("anonymousObject")
public void testAnonymousObject() throws Exception {
runTest("plugins/jvm-abi-gen/testData/compile/anonymousObject/");
}
@TestMetadata("classes")
public void testClasses() throws Exception {
runTest("plugins/jvm-abi-gen/testData/compile/classes/");
}
@TestMetadata("clinit")
public void testClinit() throws Exception {
runTest("plugins/jvm-abi-gen/testData/compile/clinit/");
}
@TestMetadata("inlineAnnotationInstantiation")
public void testInlineAnnotationInstantiation() throws Exception {
runTest("plugins/jvm-abi-gen/testData/compile/inlineAnnotationInstantiation/");
}
@TestMetadata("inlineAnonymousObject")
public void testInlineAnonymousObject() throws Exception {
runTest("plugins/jvm-abi-gen/testData/compile/inlineAnonymousObject/");
}
@TestMetadata("inlineCapture")
public void testInlineCapture() throws Exception {
runTest("plugins/jvm-abi-gen/testData/compile/inlineCapture/");
}
@TestMetadata("inlineClassWithPrivateConstructor")
public void testInlineClassWithPrivateConstructor() throws Exception {
runTest("plugins/jvm-abi-gen/testData/compile/inlineClassWithPrivateConstructor/");
}
@TestMetadata("inlineClassWithPrivateConstructorK2")
public void testInlineClassWithPrivateConstructorK2() throws Exception {
runTest("plugins/jvm-abi-gen/testData/compile/inlineClassWithPrivateConstructorK2/");
}
@TestMetadata("inlineNoRegeneration")
public void testInlineNoRegeneration() throws Exception {
runTest("plugins/jvm-abi-gen/testData/compile/inlineNoRegeneration/");
}
@TestMetadata("inlineReifiedFunction")
public void testInlineReifiedFunction() throws Exception {
runTest("plugins/jvm-abi-gen/testData/compile/inlineReifiedFunction/");
}
@TestMetadata("inlineWhenMappings")
public void testInlineWhenMappings() throws Exception {
runTest("plugins/jvm-abi-gen/testData/compile/inlineWhenMappings/");
}
@TestMetadata("innerObjectRegeneration")
public void testInnerObjectRegeneration() throws Exception {
runTest("plugins/jvm-abi-gen/testData/compile/innerObjectRegeneration/");
}
@TestMetadata("kt-40133")
public void testKt_40133() throws Exception {
runTest("plugins/jvm-abi-gen/testData/compile/kt-40133/");
}
@TestMetadata("kt-40340")
public void testKt_40340() throws Exception {
runTest("plugins/jvm-abi-gen/testData/compile/kt-40340/");
}
@TestMetadata("privateAnnotationsFromJavaApp")
public void testPrivateAnnotationsFromJavaApp() throws Exception {
runTest("plugins/jvm-abi-gen/testData/compile/privateAnnotationsFromJavaApp/");
}
@TestMetadata("privateAnnotationsFromJavaLib")
public void testPrivateAnnotationsFromJavaLib() throws Exception {
runTest("plugins/jvm-abi-gen/testData/compile/privateAnnotationsFromJavaLib/");
}
@TestMetadata("privateClassesFromJavaApp")
public void testPrivateClassesFromJavaApp() throws Exception {
runTest("plugins/jvm-abi-gen/testData/compile/privateClassesFromJavaApp/");
}
@TestMetadata("privateClassesFromJavaLib")
public void testPrivateClassesFromJavaLib() throws Exception {
runTest("plugins/jvm-abi-gen/testData/compile/privateClassesFromJavaLib/");
}
@TestMetadata("privateOnlyConstructors")
public void testPrivateOnlyConstructors() throws Exception {
runTest("plugins/jvm-abi-gen/testData/compile/privateOnlyConstructors/");
}
@TestMetadata("privateValueClassConstructor")
public void testPrivateValueClassConstructor() throws Exception {
runTest("plugins/jvm-abi-gen/testData/compile/privateValueClassConstructor/");
}
@TestMetadata("topLevel")
public void testTopLevel() throws Exception {
runTest("plugins/jvm-abi-gen/testData/compile/topLevel/");
}
}
@@ -1,72 +0,0 @@
/*
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.jvm.abi;
import com.intellij.testFramework.TestDataPath;
import org.jetbrains.kotlin.test.JUnit3RunnerWithInners;
import org.jetbrains.kotlin.test.KotlinTestUtils;
import org.jetbrains.kotlin.test.util.KtTestUtil;
import org.jetbrains.kotlin.test.TargetBackend;
import org.jetbrains.kotlin.test.TestMetadata;
import org.junit.runner.RunWith;
import java.io.File;
import java.util.regex.Pattern;
/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.GenerateTestsKt}. DO NOT MODIFY MANUALLY */
@SuppressWarnings("all")
@TestMetadata("plugins/jvm-abi-gen/testData/content")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public class LegacyJvmAbiContentTestGenerated extends AbstractLegacyJvmAbiContentTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTestWithCustomIgnoreDirective(this::doTest, TargetBackend.JVM_IR, testDataFilePath, "// IGNORE_BACKEND_LEGACY: ");
}
public void testAllFilesPresentInContent() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("plugins/jvm-abi-gen/testData/content"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, false);
}
@TestMetadata("annotation")
public void testAnnotation() throws Exception {
runTest("plugins/jvm-abi-gen/testData/content/annotation/");
}
@TestMetadata("annotationInstantiation")
public void testAnnotationInstantiation() throws Exception {
runTest("plugins/jvm-abi-gen/testData/content/annotationInstantiation/");
}
@TestMetadata("anonymousAnnotationInstantiation")
public void testAnonymousAnnotationInstantiation() throws Exception {
runTest("plugins/jvm-abi-gen/testData/content/anonymousAnnotationInstantiation/");
}
@TestMetadata("anonymousWhenMapping")
public void testAnonymousWhenMapping() throws Exception {
runTest("plugins/jvm-abi-gen/testData/content/anonymousWhenMapping/");
}
@TestMetadata("class")
public void testClass() throws Exception {
runTest("plugins/jvm-abi-gen/testData/content/class/");
}
@TestMetadata("innerClasses")
public void testInnerClasses() throws Exception {
runTest("plugins/jvm-abi-gen/testData/content/innerClasses/");
}
@TestMetadata("kt50005")
public void testKt50005() throws Exception {
runTest("plugins/jvm-abi-gen/testData/content/kt50005/");
}
@TestMetadata("whenMapping")
public void testWhenMapping() throws Exception {
runTest("plugins/jvm-abi-gen/testData/content/whenMapping/");
}
}
@@ -1 +0,0 @@
// IGNORE_BACKEND_LEGACY: JVM_IR
@@ -1,2 +1 @@
// IGNORE_BACKEND_LEGACY: JVM_IR
// IGNORE_BACKEND: JVM_IR
@@ -1,2 +1 @@
// IGNORE_BACKEND_LEGACY: JVM_IR
// NO_SOURCE_DEBUG_EXTENSION
@@ -1 +0,0 @@
// IGNORE_BACKEND_LEGACY: JVM_IR
@@ -1 +0,0 @@
// IGNORE_BACKEND_LEGACY: JVM_IR
@@ -1,2 +1 @@
// IGNORE_BACKEND_LEGACY: JVM_IR
// NO_SOURCE_DEBUG_EXTENSION
@@ -1 +0,0 @@
// IGNORE_BACKEND_LEGACY: JVM_IR
@@ -1,2 +1 @@
// USE_K2
// IGNORE_BACKEND_LEGACY: JVM_IR
@@ -1 +0,0 @@
// IGNORE_BACKEND_LEGACY: JVM_IR
@@ -1 +0,0 @@
// IGNORE_BACKEND_LEGACY: JVM_IR
@@ -1 +0,0 @@
// IGNORE_BACKEND_LEGACY: JVM_IR
@@ -1 +0,0 @@
// IGNORE_BACKEND_LEGACY: JVM_IR
@@ -1 +0,0 @@
// IGNORE_BACKEND_LEGACY: JVM_IR
@@ -1 +0,0 @@
// IGNORE_BACKEND_LEGACY: JVM_IR
@@ -1 +0,0 @@
// IGNORE_BACKEND_LEGACY: JVM_IR
@@ -1 +0,0 @@
// IGNORE_BACKEND_LEGACY: JVM_IR
@@ -1 +0,0 @@
// IGNORE_BACKEND_LEGACY: JVM_IR
@@ -1 +0,0 @@
// IGNORE_BACKEND_LEGACY: JVM_IR
@@ -1 +0,0 @@
// IGNORE_BACKEND_LEGACY: JVM_IR