209 Commits

Author SHA1 Message Date
Mikhail Glukhikh 11c006d14c Fix result in JavaUsageTest (poisoning is now OFF) 2024-03-15 11:33:10 +00:00
Mikhail Glukhikh a8bac70dec Revert "Temporary: comment the last check in JavaUsageTest (KT-66551)"
This reverts commit f2ec6d7495.
2024-03-15 11:33:10 +00:00
Leonid Startsev 75c87dd858 Update changelog and migration guide of kotlin-metadata-jvm
To accommodate for a future stable release as a part of Kotlin distribution.

See also: KT-63156, KT-63161, and KT-63219
2024-03-14 15:34:06 +00:00
Leonid Startsev cc343d7fb3 Add KmFlexibleTypeUpperBound.Companion and JVM_PLATFORM_TYPE_ID extension on it.
Because `public JvmTypeExtensionVisitor` was removed, a new place for `const val PLATFORM_TYPE_ID`
is required. It is logical to place it as a some kind of constant for Km node;
however, because it is platform-specific, there is a need for an empty
`KmFlexibleTypeUpperBound.Companion` in metadata common sources
and `public val KmFlexibleTypeUpperBound.Companion.PLATFORM_TYPE_ID`
extension in kotlin-metadata-jvm sources.

See also: KT-63156
2024-03-14 15:34:06 +00:00
Leonid Startsev 50331fb149 Remove all deprecated API from kotlin-metadata(-jvm).
This includes APIs such as:

- Visitors API
- Obsolete KotlinClassMetadata reading and writing API
- Extension and extension visitors API
- Flags and `class Flag` (a reduced version of it was moved to test sources)
- Various utility methods

Extensions mechanism got reworked with the removal of public visitors; it is
completely internal now with special accessors in kotlinx.metadata.internal
package.

Since `var KmClass.flags` is internal now (instead of being deprecated), special
utility functions with the name `_flagAccess` were added to internal package
for testing purposes.

^KT-63156 Fixed
2024-03-14 15:34:06 +00:00
Mikhail Glukhikh f2ec6d7495 Temporary: comment the last check in JavaUsageTest (KT-66551) 2024-03-13 20:38:45 +00:00
Leonid Startsev ed30221f42 Publish kotlin-metadata-jvm as a part of Kotlin distribution
and add a corresponding POM test.

#KT-63161 Fixed
2024-02-15 15:32:33 +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
Alexander Udalov 3f034e8b67 Enable lightweight lambdas (aka invokedynamic) since 2.0
#KT-45375 Fixed
 #KT-58173 Open
2024-02-08 19:46:18 +00:00
Leonid Startsev 4c7a79f8b9 Provided changelog for kotlinx-metadata-jvm 0.9.0 2024-01-11 14:10:20 +00:00
Leonid Startsev 22709bcb18 Add missing documentation to KmVersionRequirement.toString
so the documentation publishing to website will not fail.
2023-12-19 15:42:55 +00:00
Leonid Startsev 2405d644a3 Raise all deprecations in kotlinx-metadata-jvm to ERROR
as 0.8.0 had them as WARNINGs.

#KT-63157 Fixed
2023-12-19 15:39:14 +00:00
Ilya Gorbunov d2aae67e03 Replace kotlin-test project dependencies in the project
Use dependency helper function that chooses whether to take them
from the bootstrap repository or from a configuration of kotlin-test

KT-61969
2023-12-13 15:40:25 +00:00
Leonid Startsev af23706a9a Do not allow writing metadata versions that are too high
because a format may be incorrect for future compilers

#KT-64230 Fixed
2023-12-12 18:16:56 +00:00
Leonid Startsev 9933423a0b Add KmVersionRequirementKind.UNKNOWN
for cases when the version requirement cannot be read correctly (missing from the table).

It usually happens when we read the inner class' old metadata, which stored everything
in the outer class' table.

Fixes #KT-60870


Merge-request: KT-MR-13337
Merged-by: Leonid Startsev <leonid.startsev@jetbrains.com>
2023-12-12 08:47:41 +00:00
Leonid Startsev aff5b91da3 Provide changelog and migration guide for kotlinx-metadata-jvm 0.8.0 2023-12-08 13:12:50 +00:00
Alexander.Likhachev a19bd2ed2e [Build] Migrate most of the build logic from Project.buildDir usage
It's going to be deprecated in Gradle 8.3

There's currently no way to pass a `org.gradle.api.provider.Provider` to the JavaExec.systemProperty or Test.systemProperty. There's a workaround using `org.gradle.process.CommandLineArgumentProvider`, but I intentionally don't rework these calls as Gradle is going to allow passing providers to configure system properties: https://github.com/gradle/gradle/issues/12247#issuecomment-1568427242
^KTI-1473 In Progress
2023-12-07 18:31:06 +00:00
Leonid Startsev a035533316 Rename JvmMetadataVersion.CURRENT to JvmMetadataVersion.LATEST_STABLE_SUPPORTED. 2023-12-01 17:43:12 +00:00
Leonid Startsev 048802e143 Rework KotlinModuleMetadata to align it with KotlinClassMetadata:
- Public constructor with KmModule and JvmMetadataVersion
- make write() member function
2023-12-01 17:43:12 +00:00
Leonid Startsev 6e9a62c317 Update ReadMe.md in kotlinx-metadata with instructions for new
functions:

How to use readStrict(), transform(), write() and
JvmMetadataVersion.CURRENT
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
Leonid Startsev 477c668c80 Promote most deprecations in kotlinx-metadata-jvm to ERROR
because WARNING versions of them were already released at some point.

The following declarations were not promoted and have to be promoted later:

- KmProperty.hasGetter, .hasSetter
- Deprecations from readStrict/readLenient/write() rework

#KT-63157 In progress
2023-11-17 16:23:34 +00:00
Mikhail Glukhikh f90831398c K2: temporarily comment unstable part of FlagDelegatesTest.testDelegation
Related to KT-62581
2023-10-25 20:19:39 +00:00
Mikhail Glukhikh d42ae35624 K2: support DELEGATION member kind for properties #KT-62581 Fixed 2023-10-25 20:19:39 +00:00
Mikhail Glukhikh 19bf11f041 FlagDelegatesTest: accept K2 behavior for KT-62582 2023-10-25 20:19:39 +00:00
Dmitriy Novozhilov ef3d3a9724 [Metadata] Update tests according to KT-62580, KT-62581 and KT-62582 2023-10-18 07:59:27 +00:00
Dmitriy Novozhilov 6114e4f068 Fix compilation problems caused by migration to 2.0 2023-10-18 07:59:27 +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
Leonid Startsev 6e4d033f89 Promote deprecation on Flags API to ERROR
#KT-59440
2023-08-23 16:47:05 +00:00
Leonid Startsev 8b821e1feb Deprecate KmProperty.hasGetter(hasSetter) in favor of KmProperty.getter(setter)
as a follow-up of flag deprecation.

#KT-59440
2023-08-14 12:36:34 +00:00
Leonid Startsev f450122d63 Refactor MetadataExtensions.kt to remove extension visitors
This helps to completely get rid of Visitors API during reading and writing
of the JVM metadata.

Note: Klib writers still use .accept and left for future refactorings.

See also #KT-59442
2023-08-09 10:16:27 +00:00
Leonid Startsev b8e4b44b04 Promote DeprecationLevel on Visitors API to ERROR
Rewrite Readers.kt and Writers.kt to avoid using
Visitors API

Align KotlinCommonMetadata/KotlinModuleMetadata API with
KotlinClassMetadata one (it is necessary for restructured reading/writing)

#KT-59442 In Progress
2023-08-09 10:16:27 +00:00
Leonid Startsev a17cdfe338 Fix obsolete information in kotlinx-metadata-jvm ReadMe.md 2023-07-17 16:17:03 +00:00
Leonid Startsev 7c1c01156f Add missing delegation in KmDeclarationContainerVisitor.visitExtensions for consistency 2023-07-17 11:04:18 +00:00
Leonid Startsev 20368a9e40 Enable explicit API mode for kotlinx-metadata(-jvm)
Most of the declarations are made public as-is, except for some reader implementation details
and MetadataExtensions.INSTANCES.

Also added missing delegation in KmDeclarationContainerVisitor.visitExtensions

#KT-59182 Fixed
2023-07-17 11:04:18 +00:00
Leonid Startsev 5424c54fae Make changelog and migration guide for kotlinx-metadata-jvm:0.7.0 2023-07-11 15:56:07 +00:00
Leonid Startsev 0a573a803d Update and clarify documentation for kotlinx-metadata-jvm attributes:
- Review fixes
- Clarify KmClass.isData and enhance nodes documentaiton to mention extensions
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
Leonid Startsev 1a1cbcb321 Rework flags in kotlinx.metadata:
Introduce extensions for KmNodes to work with various modifiers instead of old Flags.SOMETHING.invoke(flags).
Provide Visibility, Modality, and Kind enums.
Introduce KmPropertyAccessorAttributes to replace KmProperty.getterFlags and KmProperty.setterFlags.
Deprecate nodes constructors which take flags but not flags itself (yet).
Adapt KotlinP to changes.

#KT-59440 Fixed
2023-06-27 15:12:46 +00:00
Leonid Startsev 3933242340 Deprecate KmModule.annotations because it is unused and always empty.
It used to store state of `-Xexperimental` Kotlin compilation flag,
but this feature was removed long ago.

#KT-59366 Fixed
2023-06-19 17:54:18 +00:00
Leonid Startsev b919a12274 Restructure KotlinClass(Module)Metadata.write/read:
- Write now returns result (Metadata or ByteArray) directly without re-wrapping it;
- annotationData/bytes is private to avoid unsoundness if external client corrupts it;
- .toXxx() do not throw exceptions anymore and deprecated. Exceptions are thrown only from read/write;
- Instead of toXxx(), properties like .kmClass should be used instead. They're initialized eagerly and return a view without copying.
- KotlinClassMetadata.Unknown is now a data object, as no useful information is exposed

#KT-59365 Fixed
2023-06-19 17:54:18 +00:00
Leonid Startsev 29b6595cfc Start file names with a capital letter according to codestyle
No ABI changes are introduced because file facades are automatically capitalized anyway.
2023-06-13 16:44:13 +00:00
Leonid Startsev 98f7ac044c Add Dokka configuration to kotlinx-metadata-jvm 2023-06-13 12:56:03 +00:00
Leonid Startsev 654874e30f Enhance kotlinx-metadata-jvm KDoc: add missing documentation, apply Grazie suggestions 2023-06-13 12:56:03 +00:00
Leonid Startsev 5088c9370d Add missing deprecation for KmExtensionType and experimentality for KmConstantValue 2023-06-13 12:56:03 +00:00
Leonid Startsev 0cfe2b04f5 Move KmModuleFragment to an internal.common package
because it is klib-related and can be read only with KotlinCommonMetadata.
2023-06-08 17:53:31 +00:00
Leonid Startsev c3d363d1b8 Throw exception instead of returning null from KotlinClass(Module)Metadata.read() 2023-06-08 17:53:31 +00:00
Leonid Startsev 1c629e748f Add JvmStatic + JvmOverloads to writing functions in KotlinClassMetadata
and KotlinModuleMetadata for easier use from Java.
2023-06-08 17:53:31 +00:00