Commit Graph

49 Commits

Author SHA1 Message Date
Andrey Uskov 4ad828f80f [JPS] Improved processing of broken caches
If serialized metadata version has evidently incorrect size the module
should be marked for rebuild prior to reading serialized version.

#KT-42194 Fixed
2021-09-21 10:41:12 +03:00
Alexander Udalov 8b44b69982 Minor, add definitelyNonNull type flag in metadata as a comment 2021-08-24 12:28:31 +02:00
nataliya.valtman f6b428f271 KT-34862 use abi snapshot instead of build history files
Use jar snapshot instead build history file to avoid using time stamps and support remote gradle cache
2021-06-22 07:48:14 +03:00
Denis.Zharkov 30eb9ad32f Add serialization/deserialization of definitely-not-null types
^KT-26245 In Progress
2021-04-09 13:06:31 +03:00
Alexander Udalov c4b2b7e0da Add underlying property name & type for inline class to kotlinx-metadata
#KT-45635 Fixed
2021-04-01 22:34:53 +02:00
Alexander Udalov ea01c97a8e Write underlying property name & type for inline class to metadata
This will be used in the compiler starting from 1.5.20 instead of the
currently used approach of looking for the single value parameter of the
primary constructor. The problem with the current approach is that
primary constructor can be private (since 1.4.30) and the property could
always be private. Relying on private declarations from metadata is
dangerous; for example lazy IR doesn't usually create stubs for private
declarations, and it didn't create stubs for private inline class
constructors before b5f9b1df, which led to the problem reported in
KT-44723.
2021-03-23 11:45:22 +01:00
Ilmir Usmanov 361ed117bb Value classes: Add isValue property to class descriptors
Reuse isInline flag in proto and IR.
Check metadata version on deserialization.
2020-11-27 23:52:05 +01:00
Alexander Udalov da69e3db7c kotlinx-metadata-jvm: report error on using metadata version < 1.4 in writers
The main reason for this change is that the current API for class
version requirements (`KmClass.versionRequirements`) makes it impossible
to support pre-1.4 metadata where this was stored incorrectly for nested
classes: with the "version requirement table" in the outer class, and
indexes into that table in nested classes. See KT-41011.

Other than this aspect, metadata of classes is basically the same in
pre-1.4 and 1.4, which means that if some kotlinx-metadata-jvm users
really need to serialize metadata of an earlier version and they don't
care about the version requirements issue, they can just use these new
bytes but write the earlier version (e.g. 1.1) to the class file.
Everything will work the same, except for the possible version
requirements issue mentioned above.

Note that metadata version 1.4 is still supported for
`KotlinModuleMetadata.Writer` though.

 #KT-41011 Fixed
2020-10-15 13:10:01 +02:00
Mads Ager 8d791ca98e [IR] Update naming, but not binary format for IrSetValue. 2020-10-06 21:47:29 +02:00
Dmitriy Novozhilov 36d2129fd3 Move common deserialization classes from :core:metadata modules 2020-09-11 10:08:37 +03:00
Dmitriy Novozhilov 1417fcecb8 Move more common parts from :compiler:descriptors.jvm 2020-09-11 10:08:36 +03:00
Dmitriy Novozhilov 5d4d07066b Move common deserialization components to :core:metadata and :core:metadata.jvm 2020-09-11 10:08:35 +03:00
Dmitriy Novozhilov 8d2e89a9ea Move ProtoEnumFlags to :core:metadata 2020-09-11 10:08:34 +03:00
Dmitriy Dolovov 3d9093583f Metadata: 'non-stable parameter names' flag for callables
^KT-34602
2020-07-27 23:11:30 +07:00
Roman Artemev 6a37955a36 [KLIB] Implement new linker based on IdSignature
- Remove klib dependency on metadata and uniqID
 - Refactored proto format to make it more effective and compact
  -- Use special encoding for some types of data (coordinates, flags, types)
  -- Remove symbols table
  -- Use packed proto list if it is possible
 - Remove extension from metadata
 - Remove special ids for function interfaces
 - Fix klib IO
 - Fix incremental cache
 - General code clean up
2020-02-14 18:22:16 +03:00
Mikhail Zarechenskiy f7ce1c669b FIC: Introduce isFun property for descriptors and proto 2020-01-17 19:35:06 +03:00
Alexey Tsvetkov 6e9cd85b54 Exclude some proto messages from proto comparison in IC 2019-11-08 14:14:58 +03:00
Alexey Tsvetkov 28e6219b0b Fix proto comparison for fields mapped to type table 2019-11-08 14:14:58 +03:00
nikita.movshin 65244b4bea Update copyright.
Change the copyright from "JetBrains s.r.o." to
"JetBrains s.r.o. and Kotlin Project contributors"
Update only 2 lines copyright.
2019-04-23 20:09:22 +03:00
Alexander Udalov 76e133014b Minor, explain why we don't store array type arguments in ::class in proto 2019-02-26 19:09:42 +01:00
Alexander Udalov 1ee1d15b91 Support annotations on property accessors in JS/common metadata
#KT-14529 Fixed
2018-10-24 18:17:12 +02:00
Mikhail Zarechenskiy 7d2bc5c0f6 Properly load top-level constant initializers from multifile classes
Before Kotlin 1.3-M2 we didn't write `has_field` flag for constants
 inside multifile classes. Now we write and rely on this when
 trying to load constant initializers, which is totally fine for
 binaries that were compiled with the 1.3-M2 or newer version.
 Unfortunately, constant initializers will not be loaded for old binaries.

 One way is to avoid relying on this flag, but then we'll get other
 problems (e.g. 3345dc81fd).

 Therefore, for binaries that were compiled with at least 1.3-M2 version,
 we'll rely on the flag, otherwise, we won't.
2018-09-17 16:21:02 +03:00
Alexander Udalov 8c942752e8 Write flags to .kotlin_module files since metadata version 1.4
This value will be used for flags like pre-release (KT-21256) and other
similar info
2018-09-10 14:12:17 +03:00
Alexander Udalov f90303315d Support array class literals in annotation serializer/deserializer
Note that this change brings an incompatibility: `Array<Foo>::class`
will be seen as `Foo::class` by the old deserializer. We consider this
OK because the compiler never had any logic that relied on reading class
literal arguments correctly (otherwise it wouldn't have worked because
it could only see `Array<*>::class` before this commit), and the support
of annotations on types in JVM reflection is only available in the
upcoming 1.3 release (KT-16795)

 #KT-22069 Fixed
2018-09-06 14:40:06 +03:00
Alexander Udalov afd53c9870 Revert metadata version reading advancement for JS/Common
This commit reverts 59e2101a25 partially,
leaving only the implementation of KT-25972 for JVM. The reason is that
we can't fully commit to stabilizing JS (and .kotlin_metadata) binary
metadata formats so much as to postpone any changes done to it for a
whole release year time. It's likely that we will need to update JS
metadata format incompatibly pretty soon, and with the scheme where we
can read the "current + 1" version, it'd require advancing the metadata
version by 2, which would break the nice property that the metadata
version (since Kotlin 1.4) is equal to the version of the compiler that
produced it.

See KT-25972
2018-08-27 13:14:09 +02:00
Alexander Udalov 9c68f2be36 Advance metadata versions and JVM bytecode version
JVM versions are increased in order to differentiate pre-1.3-M2 .class
files where signatures mentioning inline classes were not mangled. Other
versions are increased in case something similar will need to be
detected
2018-08-24 13:01:53 +02:00
Alexander Udalov 59e2101a25 Support reading binary metadata of the next major release
Already existing tests testRequireKotlinInNestedClassesAgainst14{,Js}
now check that there's no error when loading a module/class with
metadata version 1.4.0

 #KT-25972 Fixed
2018-08-21 17:12:02 +02:00
Alexander Udalov ddb398645b Reformat modules 'metadata' and 'metadata.jvm', fix some inspections 2018-08-16 15:08:18 +02:00
Alexander Udalov c011bf61fe Support multiple version requirements on single element 2018-08-13 11:02:35 +02:00
Alexander Udalov 871b896a21 Add internal compiler argument to change metadata version
Will be used in tests to check how we behave on binaries produced by a
"future" compiler
2018-07-18 17:59:37 +02:00
Alexander Udalov cfc0f5e453 Support correct way of writing/loading version requirement table
Tests are added in subsequent commits.

KT-25120 Fixed
2018-07-18 17:59:37 +02:00
Mikhail Zarechenskiy 0c6757a8b0 Write is_unsigned flag into metadata for an annotation arguments
Instead of adding new kind of types, we'll use flag to disambiguate
 usual types from unsigned ones, this approach has two advantages:
 - less changes in the metadata format
 - it allows naturally extend format for unsigned arrays,
  which will be supported later

 #KT-25310 Fixed
 #KT-25273 Fixed
2018-07-09 20:06:05 +03:00
Alexander Udalov 50c515deca Do not serialize constructors for anonymous objects
The only client of this data is reflection, and since anonymous objects
do not have constructors in the source code, they shouldn't in
reflection as well

 #KT-20442 Fixed
2018-07-02 18:49:08 +02:00
Alexander Udalov 9309570752 Fix serialization of type parameters inner generic class
The call to `createTopLevel` instead of `create` (which creates
serializers for outer classes properly, with correct type parameter
contexts) caused MetadataSerializer to write type parameter metadata
incorrectly.  For example, in the following case:

    class A<E> {
        inner class B<T, E> { ... }
    }

A's type parameter E would get id 0, and B's type parameters T and E
would get ids 0 and 1. This is a problem because ids are supposed to be
unique for each class including its outer classes, and deserializer,
decompiler and stub builder rely on this assumption.

JVM metadata is unaffected because `create` is called correctly there,
see MemberCodegen#generateKotlinClassMetadataAnnotation

 #KT-24944 Fixed
2018-06-21 14:45:45 +02:00
Alexander Udalov b8722ad213 Fail with KotlinReflectionInternalError on non-found local delegated property
Instead of IndexOutOfBoundsException from the protobuf internals which
was thrown when loading extension with a non-existing index out of the
list of all extensions (KT-23413)
2018-06-14 11:07:26 +02:00
Alexander Udalov ffa6b6233b Minor, make BinaryVersion.numbers private
Use BinaryVersion.toArray instead, as in all other usages
2018-05-16 17:16:22 +02:00
Alexander Udalov 1b15619457 Move BinaryVersion to metadata, JVM versions to metadata.jvm
To be used in kotlinx-metadata
2018-05-16 17:16:22 +02:00
Alexander Udalov e4062f6447 Add kotlinx-metadata library for handling Kotlin metadata
#KT-23198
2018-05-16 17:16:21 +02:00
Alexander Udalov 52a9cc06e0 Remove StringTable.serializeTo, add JvmProtoBufUtil.writeData
StringTable.serializeTo was effectively only used for JvmStringTable,
but was declared in StringTable because of the usage in
DescriptorSerializer.serialize (which, in turn, was only used from JVM
codegen)
2018-04-23 18:42:33 +02:00
Alexander Udalov 7bac9b62c7 Reformat VersionRequirement and move to 'metadata' 2018-04-23 18:42:33 +02:00
Alexander Udalov 13df75ef74 Minor, extract isInstanceType to protoTypeTableUtil 2018-03-26 17:21:08 +02:00
Alexander Udalov f7a3182982 Minor, add default value to contract expression flags 2018-03-26 17:21:07 +02:00
Alexander Udalov e21c73229c Throw exceptions explicitly in protoTypeTableUtil
Previously, if both type and typeId messages were missing (for example,
ProtoBuf.Function.returnType/returnTypeId) because of some bug, the
behavior was unpredictable because a type with id 0 from the type table
would be returned, which could be a completely irrelevant type. This is
an incorrect situation and we should report a diagnostic instead.
Temporarily throw an exception instead, since this only affects how the
compiler works on bad metadata
2018-03-14 12:25:23 +01:00
Alexander Udalov 0a78fe8ae3 Move some serialization helpers to metadata/metadata.jvm 2018-03-14 12:25:22 +01:00
Alexander Udalov 407de206a3 Minor corrections in proto schemas, mostly in comments
Also set up code style for the protobuf plugin
2018-03-14 12:25:19 +01:00
Alexander Udalov 3f3e05a9d2 Move essential metadata-related classes to 'metadata' and 'metadata.jvm' 2018-03-14 12:25:16 +01:00
Alexander Udalov 88dea9aa70 Move NameResolver to module 'metadata' and J2K
Also move NameResolverImpl to 'metadata' and JvmNameResolver to
'metadata.jvm'
2018-03-14 12:25:16 +01:00
Alexander Udalov 27ad4f7d5d Move ProtoBuf classes to package org.jetbrains.kotlin.metadata 2018-03-14 12:25:10 +01:00
Alexander Udalov 575a388b11 Move core protobuf schemas to 'metadata' and 'metadata.jvm' 2018-03-14 12:25:09 +01:00