Commit Graph

151 Commits

Author SHA1 Message Date
Alexander Udalov 1036506b25 Introduce new string table optimized for JVM class files
This format of the string table allows to reduce the size of the Kotlin
metadata in JVM class files by reusing constants already present in the
constant pool. Currently the string table produced by JvmStringTable is not
fully optimized in serialization (in particular, the 'substring' operation
which will be used to extract type names out of generic signature, is not used
at all), but the format and its complete support in the deserialization
(JvmNameResolver) allows future improvement without changing the binary version
2015-09-29 16:26:28 +03:00
Alexander Udalov 7d5bd3cf50 Simplify storage of JVM signatures in binary metadata
Store the whole method & field descriptor strings. Moving these strings to
separate annotation arguments later will allow to reuse them with the ones in
the constant pool, presumably allowing to save lots of space (up to 10%)
2015-09-29 16:26:25 +03:00
Alexander Udalov 5477570066 Extract interface out of NameResolver 2015-09-29 16:26:24 +03:00
Alexander Udalov 4a8d2b73d3 Remove deprecated stuff unused after M13 2015-09-22 18:22:55 +03:00
Denis Zharkov 9c4564a5a6 Get rid of deprecated annotations and modifiers in project code 2015-09-18 09:34:27 +03:00
Denis Zharkov 23ddf42981 Use JvmStatic in reflection instead of decapitalized 2015-09-18 09:34:25 +03:00
Alexander Udalov b1d9e5c961 Minor, improve exception message for reflection on built-ins 2015-09-15 13:11:16 +03:00
Michael Nedzelsky 5e35161d99 explicit internal modifier for some members of core/reflection.jvm in order to avoid generating documentaion 2015-09-08 02:04:09 +03:00
Michael Bogdanov 0de83b6f4c Default module name extraction 2015-09-07 16:29:15 +03:00
Michael Bogdanov b58479a169 TEST_MODULE_NAME extraction 2015-09-07 16:29:15 +03:00
Michael Bogdanov 974095313c Catch NoSuchFieldException 2015-09-07 16:29:11 +03:00
Michael Bogdanov 606b39698c Kotlin module name extraction 2015-09-07 16:29:11 +03:00
Michael Bogdanov 2ca9b3ae0e Code clean 2015-09-07 16:29:10 +03:00
Michael Bogdanov 9f0662468f Lazy module name propagation 2015-09-07 16:28:56 +03:00
Michael Bogdanov e83ec1017b Reflection support 2015-09-07 16:28:51 +03:00
Alexander Udalov df935f5bb7 Support reflection on lambdas and function expressions
Write a special annotation containing the bytes for the Callable protobuf
message and deserialize it at runtime properly

 #KT-9005 Fixed
2015-09-03 21:43:58 +03:00
Valentin Kipyatkov 4321969ba5 Restored properties "java" and "kotlin" in package kotlin.reflect.jvm but made them hidden 2015-09-03 15:55:57 +03:00
Yan Zhulanow 55b2029b3c Remove FIELD target from jvmStatic and platformStatic annotations 2015-09-02 20:36:48 +03:00
Yan Zhulanow e0c85cba23 Fix platformStatic in reflection-jvm 2015-08-31 15:33:09 +03:00
Yan Zhulanow 3624c4e5dc Use target priorities to split annotations to different descriptors 2015-08-31 15:33:05 +03:00
Alexander Udalov fb09c91714 Minor, rename PlatformStatic* -> JvmStatic* in reflection 2015-08-29 18:42:09 +03:00
Alexander Udalov a1097f7081 Add val KClass.staticProperties: Collection<KProperty0<*>>
To get static fields from Java classes
2015-08-29 18:37:41 +03:00
Alexander Udalov 593937d302 Support KCallable.callBy with map of parameters to arguments
callBy is able to handle optional parameters.

 #KT-8827 Fixed
2015-08-29 18:37:40 +03:00
Alexander Udalov 0d62680f63 Support KParameter.isOptional
#KT-8825 Fixed
2015-08-29 18:37:39 +03:00
Alexander Udalov fd97383f8a Fix mapping of jvmStatic functions
#KT-8800 Fixed
2015-08-29 18:37:38 +03:00
Alexander Udalov 9a8cf23ed4 Support KClass.companionObject and companionObjectInstance
#KT-7636 Fixed
2015-08-29 18:37:32 +03:00
Alexander Udalov 94d45f35d4 Support KClass.nestedClasses 2015-08-29 17:59:45 +03:00
Alexander Udalov 7c28a2e732 Support KClass.defaultType 2015-08-28 21:22:11 +03:00
Alexander Udalov ea8fe56704 Include property type to KProperty.toString 2015-08-28 21:11:31 +03:00
Alexander Udalov d36ef90dd6 Provide equals/hashCode/toString for KParameter implementation
Two KParameter instances are equal iff their backing descriptors are equal and
their callables are equal
2015-08-28 21:11:30 +03:00
Alexander Udalov d4825cf4f0 Support KParameter.kind: instance, extension receiver, or value 2015-08-28 21:11:22 +03:00
Alexander Udalov a73d02418d Introduce additional API for introspecting functions
memberFunctions, declaredMemberFunctions, staticFunctions, etc.

 #KT-8797 Fixed
2015-08-28 21:11:21 +03:00
Alexander Udalov ebe4a8ec89 Provide equals/hashCode/toString for KType implementation 2015-08-28 21:11:20 +03:00
Alexander Udalov 30967baca8 Minor, rename extension property to avoid name clash 2015-08-28 21:11:00 +03:00
Denis Zharkov 4a3fbcc16e Make project compilable after fixes about generic nullability 2015-08-28 18:50:26 +03:00
Alexander Udalov 8d9618348d Move .java and .kotlin extension properties to kotlin.jvm
Delete the old ones in package kotlin.reflect.jvm because otherwise the code
using those functions will become red in a lot less meaningful way (overload
resolution ambiguity) than if they're deleted (unresolved import)

Based on the work originally done by @dnpetrov

 #KT-8380 Fixed
2015-08-27 08:19:50 +03:00
Alexander Udalov 9f7cb752db Minor, rename KCallableContainerImpl -> KDeclarationContainerImpl
Also rename DeclarationContainerImpl -> ClassBasedDeclarationContainer and make
non-public
2015-08-24 01:29:57 +03:00
Dmitry Jemerov 341f09afd3 rename platformStatic to jvmStatic 2015-08-21 16:59:05 +02:00
Zalim Bashorov bcacef7bb9 Move all NoLookupLocation instances to the one place to make them more discoverable and close constructor 2015-08-18 12:34:17 +03:00
Zalim Bashorov 0ca9c6fd40 Introduce NoLookupLocation and some new constants to classify LookupLocation.NO_LOCATION usages 2015-08-18 12:21:30 +03:00
Alexander Udalov 0d0ccfef8c Refactor and simplify FunctionCaller 2015-08-07 00:55:44 +03:00
Alexander Udalov d3e39812cb Support mapping of KType to j.l.reflect.Type 2015-08-07 00:55:35 +03:00
Alexander Udalov 49b689f883 Do not allow to assign null to a non-null property via reflection
This was already working for accessor-based properties because the assertions
were already generated into corresponding accessors, but for fields we must
manually check the value against null
2015-08-07 00:55:33 +03:00
Alexander Udalov 3091f2af3b Report argument number mismatch nicely on wrong 'call()' invocation
The default Java reflection message in such case is not very helpful: "wrong
number of arguments"
2015-08-07 00:55:32 +03:00
Alexander Udalov 9c522b4d49 Refactor property calls in reflection, fix some corner cases
- compute a FunctionCaller instance for getter and setter so that "call" only
  delegates to that FunctionCaller's "call", in the same way it's done in
  KFunctionImpl
- use RuntimeTypeMapper.mapPropertySignature to get the exact origin and
  signature of a property and its accessors. This makes unwrapFakeOverride call
  unnecessary and also fixes some cases like private Java fields
- temporarily drop custom range checks, will be re-added soon
2015-08-07 00:55:30 +03:00
Alexander Udalov a91729e041 Fix isAccessible for property accessors 2015-08-07 00:55:30 +03:00
Alexander Udalov 6878453d44 Support KClass.objectInstance for objects and companion objects 2015-08-03 23:33:21 +03:00
Alexander Udalov 2eb5201575 Introduce KAnnotatedElement and val annotations: List<Annotation> 2015-08-03 23:32:23 +03:00
Alexander Udalov a0cc313156 Support class reference expression for reified type parameters
Also make KClass::java an intrinsic property.

Based on the work by @dnpetrov

 #KT-6976 Fixed
2015-07-30 12:18:28 +03:00
Alexander Udalov 628bb774fd Support class reference expressions without kotlin-reflect.jar in classpath
Currently not much you can do with them, but in the future '.java' extension
property will allow to get the Class instance from it.

Also introduce codegen tests with stdlib but without reflection in the
classpath.

Based on the work by @dnpetrov
2015-07-30 12:18:28 +03:00