141 Commits

Author SHA1 Message Date
Sonya Valchuk b6d73fc6ac jvm-abi-gen: use asm flag to skip debug info 2024-03-13 21:31:19 +00:00
Sonya Valchuk 9518416bdb jvm-abi-gen: remove parts of the SMAP used only in stripped methods 2024-03-13 21:31:19 +00:00
Alexander Udalov 9d1d01d1eb jvm-abi-gen: Minor, deduplicate newField/newMethod calls 2024-02-28 10:19:45 +00:00
Vladimir Tagakov d2792533b8 jvm-abi-gen: Remove internal declarations from ABI
#KT-65690 Fixed
2024-02-28 10:19:45 +00:00
Dmitriy Novozhilov acf2296590 [Test] Regenerate tests after two previous commits 2024-02-16 12:48:24 +00:00
Leonid Startsev 09e89db82f Change kotlinx- to kotlin- in kotlin-metadata-jvm and related projects
Change package, artifact group, artifact name, and Gradle module name to
kotlin-metadata and kotlin-metadata-jvm, respectively.

In Kotlin 2.0, kotlin-metadata-jvm library is promoted to stable, and is
a part of Kotlin distribution now.

Note that kotlinx-metadata-klib is left with org.jetbrains.kotlinx group, artifact name and package
because -klib part is considered not stable and for internal use. Since it is still published via Sonatype,
it should have kotlinx group. Therefore, it will have both classes from kotlin.metadata and kotlinx.metadata packages. This is not a problem, because we already had kotlinx.metadata split package between -jvm and -klib before.

#KT-63219 Fixed
2024-02-15 15:32:33 +00:00
Vladimir Tagakov 11d3ead975 jvm-abi-gen: Remove effectively private classes from ABI
#KT-64590 Fixed
2024-02-08 15:19:50 +00:00
Vladimir Tagakov dab9ac3b1c jvm-abi-gen: Allow disabling class members sorting in abi.jar
#KT-64589
2024-02-02 16:29:19 +00:00
Vladimir Tagakov 91002eacda jvm-abi-gen: Remove data class copy fun from ABI along with constructor
#KT-64591 Fixed
2024-01-25 12:03:47 +00:00
Vladimir Tagakov 06095e86ca jvm-abi-gen: remove SourceDebugExtension if no inline functions present
#KT-65072 Fixed
2024-01-22 19:00:10 +00:00
Vladimir Tagakov ad9c100137 Sort class members in jvm-abi-gen
#KT-64589 Fixed
2024-01-16 20:03:29 +00:00
Alexander Udalov 1a46b053f2 jvm-abi-gen: minor, refactor debug info and body removing visitors
Co-authored-by: Vladimir Tagakov <vtagakov@lyft.com>
2024-01-16 20:03:29 +00:00
Dmitrii Gridin b6d373d8e5 Update copyright to 2024 2024-01-05 13:43:17 +00:00
Alexander Udalov fe1e2b8b34 jvm-abi-gen: Support removeDebugInfo option
This option removes debug info, such as:
- SourceFile attribute on classes
- LocalVariableTable, LineNumberTable, SourceDebugExtension attributes
  on inline functions
- @SourceDebugExtension annotation on inline functions

 #KT-33020 Fixed
2023-12-07 20:50:01 +00:00
Leonid Startsev a035533316 Rename JvmMetadataVersion.CURRENT to JvmMetadataVersion.LATEST_STABLE_SUPPORTED. 2023-12-01 17:43:12 +00:00
Leonid Startsev 721af75f40 Provide a separate class for representing metadata version in kotlinx-metadata
Separate class allows encapsulating comparison, equality, and structure of version parts.
It also makes more sense from API standpoint than plain `IntArray`.
2023-12-01 17:43:11 +00:00
Leonid Startsev f101e5a336 Unify write() method and make it a member of KotlinClassMetadata
To make sure that the correct version and flags are preserved during metadata transformation,
they are now stored inside KotlinClassMetadata.
Such change also makes it possible to make write() a member function of KotlinClassMetadata, further simplifying API.
Also, it allows tracking whether readStrict or readLenient was used to read metadata and prohibit writing accordingly.

Also provide transform() method as a shortcut for readStrict+write.

Related to: #KT-59441
2023-12-01 17:43:11 +00:00
Leonid Startsev 36703ff9ae Implement strict and lenient modes for Kotlin metadata reading
In strict mode, an exception will be thrown when inconsistent metadata is encountered. In lenient mode, the reader will attempt to handle the inconsistent metadata by ignoring certain inconsistencies. This is a solution to a problem of reading metadata 'from the future' that is not allowed by default, but desired in certain cases. See updated ReadMe for details.

Also fix problem with Strict Semantics flag.

#KT-57922 Fixed
#KT-59441 Fixed
2023-12-01 17:43:11 +00:00
Alexander.Likhachev 357d12fc8e [Build] Move JUnit dependencies into the version catalog
The `kotlin-test` dependencies are left untouched as changing them affects publications, thus these versions are independent from the used inside our build
#KTI-1349 In Progress
2023-09-06 22:47:33 +00:00
Alexander Udalov 7f5bc94117 Jvm-abi-gen: do not treat KmProperty.hasConstant as part of ABI
... for non-const properties.

The meaning of this flag for non-const properties is in reality not
well-established, and it can vary from one release to another. In
particular, it's different in K2.

This commit has two parts:
1) The test (added in 5891617674) about clinit is changed. Original
   motivation was to check that presence or absence of `<clinit>` is not
   a part of the ABI. However, in addition to that, the test also
   involuntarily checked that the aforementioned "hasConstant" flag for
   the property y/Object.y is the same in both cases (which I believe
   was not the intention) because these tests check that Kotlin metadata
   is _exactly the same_ after applying jvm-abi-gen. So I've changed it
   to be more straightforward: one version declares an obvious constant,
   while another declares an obvious non-constant. After this change,
   the test started to fail (even on K1) because the value of the
   "hasConstant" flag was different between two versions.
2) Remove "hasConstant" flag for non-const properties when transforming
   metadata via jvm-abi-gen. This fixes the test and assures it won't
   fail when the project is migrated to LV 2.0.

 #KT-60849 Fixed
2023-08-10 20:24:17 +00:00
Leonid Startsev 283f816320 Use source-version of kotlinx-metadata-jvm for embedding
Embedding published version while using source one can lead to runtime errors like NoClassDefFound
if a new (not yet published) declaration was used in implementation.
2023-06-27 15:12:46 +00:00
Leonid Startsev b15da7c63a Deprecate old kotlinx-metadata flags API:
Flag, Flag constants, Flags typealias, flagsOf() function, and
Flag accessors in nodes (such as KmClass.flags, KmClass.jvmFlags, KmProperty.setterFlags, etc)

#KT-59440
2023-06-27 15:12:46 +00:00
Alexander Udalov ecc1f9fb0b Update to kotlinx-metadata-jvm 0.6.2
Migrate to the new API in kotlin-reflect build script, remove obsolete
workarounds.
2023-06-27 14:32:15 +00:00
Alexander Udalov 5451477eb0 Minor, remove useLegacyAbiGen test mode
Legacy jvm-abi-gen was removed in KT-55375.
2023-06-27 14:32:15 +00:00
Alexander Udalov 4ac6f01d31 Add ReplaceWithSupertypeAnonymousTypeTransformer to light analysis tests
To make these tests behave closer to kapt, since kapt is the primary use
case for the light analysis mode.

AbstractLightAnalysisModeTest compares the text dump of bytecode
obtained with full analysis and light analysis, removing things like
anonymous/synthetic entities. In the light analysis mode anonymous
objects in supertypes are always approximated, and in the full analysis
mode they are always present as is in signatures. So we're transforming
the text dump in the same way, by approximating anonymous objects in
signatures (more precisely, in return types of methods and fields) to
the supertype.
2023-06-22 17:10:51 +02:00
Sebastian Sellmair 5d0bf2de24 [CLI] Restore K2JVMCompilerArguments.classpath and javaModulePath
to support IDEs < 2023.2

Reverts:
- 9dcd40d7b7
- fb66764c4d

KTIJ-25227
2023-04-18 09:18:10 +00:00
Sebastian Sellmair 9dcd40d7b7 [CLI] K2JVMCompilerArguments: Model classpath as Array<String>
to allow interning individual file-path arguments on the IDE

KTIJ-24976
2023-04-06 16:03:03 +00:00
Alexander Udalov f4b4922a13 Use new ClassGeneratorExtension EP in jvm-abi-gen 2023-03-13 13:53:07 +01:00
Alexander Udalov 9f269b83aa Remove "legacy" mode of jvm-abi-gen plugin
#KT-55375 Fixed
2023-03-10 12:24:50 +00:00
Pavel Mikhailovskii 4c7f8ba196 KT-56457 Annotate Enum.entries with @NotNull 2023-02-09 20:13:56 +00:00
Dmitriy Novozhilov 88efa6bfb6 Update tests after switching to LV 1.9 2023-01-30 09:29:57 +00:00
Alexander Udalov ef208d9eac Throw if kotlinx-metadata-jvm version in jvm-abi-gen is too low 2023-01-25 23:24:05 +01:00
Alexander Likhachev 87db928b2d [IC] Support precise output backup for jvm-abi-gen plugin
#KT-49785 In Progress
2023-01-17 22:15:53 +00:00
Alexander Udalov 3197a118ab Update jvm-abi-gen to kotlinx-metadata-jvm's Km* node API 2023-01-17 22:00:30 +01:00
Alexander Udalov 5ef372aab5 Update jvm-abi-gen to kotlinx-metadata-jvm 0.6.0 2023-01-17 21:59:54 +01:00
Mikhail Glukhikh 0c4a0360ac Deserialization/class reading: pass chosen JvmMetadataVersion whenever possible 2023-01-16 18:16:07 +01:00
Vyacheslav Gerasimov 1fa7c7119b Build: Fix caching of some ShadowJar tasks in the project
To be cacheable relocated shadow jars should not include manifest with
build number. Instead, we repack relocated shadow jar in default jar
task with proper manifest.
2023-01-04 16:31:48 +00:00
Alexander Udalov 3c4b5529af Update year to 2023 in COPYRIGHT_HEADER.txt
This commit is the result of changing the year to 2023 in
COPYRIGHT_HEADER.txt and running all `generate*` tasks in
`generators/build.gradle.kts`.
2023-01-02 22:52:15 +01:00
Alexander Udalov b4ffa56ea4 Deprecate legacy mode of jvm-abi-gen
#KT-54756 Fixed
2022-12-28 21:06:34 +00:00
pyos 34a49b3f56 jvm-abi-gen: only keep relevant InnerClasses from current module
If a class is not referenced by the ABI class file, its InnerClasses
entry should only be kept if it's the current class or a descendant
of the current class.
2022-12-28 14:42:33 +01:00
pyos d6fdd6734e jvm-abi-gen: sort inner classes 2022-12-28 14:42:33 +01:00
pyos 26a7ac6d92 jvm-abi-gen: keep InnerClass attributes for all referenced types
^KT-55233 Fixed
2022-12-28 14:42:33 +01:00
Alexander Udalov 0d8d91f803 Remove unsafe cast function usages from compiler plugins 2022-12-06 19:44:56 +00:00
Alexander Udalov beb3759f5a Add jvm-abi-gen test on inline class with private ctor
KT-54897
2022-11-11 16:28:37 +00:00
Leonid Startsev 474ef921d8 Use standard @Deprecated in place of special opt-in annotation
Remove @DeprecatedVisitor
2022-11-10 13:30:10 +00:00
Leonid Startsev 471882b743 Introduce @DeprecatedVisitor; mark up visitor-related declarations with it.
Provide convenient JVM writing API.

Get rid of ExperimentalUnsignedTypes.
2022-11-10 13:30:09 +00:00
pyos a30d19b655 jvm-abi-gen: consider private type aliases to be public API
They can be referenced from public declarations right now.

^KT-54500 Fixed
2022-10-31 22:13:21 +01:00
Alexander Udalov 97f63d539c Remove tests on jvm-abi-gen with old JVM backend
#KT-48532 Fixed
2022-09-16 00:16:31 +02:00
Vladimir Sukharev c8864369fd Use main class as test generator name
Merge-request: KT-MR-7031
Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
2022-09-09 12:51:18 +00:00
Alexander Udalov e83819e682 Minor, remove obsolete directives from jvm-abi-gen tests
Language version 1.6 was needed in these tests to enable annotation
instantiation, but that feature is now enabled by default.
2022-09-09 14:32:36 +02:00