Commit Graph

56 Commits

Author SHA1 Message Date
Alexander Udalov 48b18f18d3 Restore explicit imports of Kotlin function types in Java
This is a follow-up to 738a84e259 and
d4965a4f3e. Optimize imports in all files
affected in those commits, drop temporary _.kt
2015-05-26 18:46:27 +03:00
Alexander Udalov 9ba6d91e2e Prepare JVM runtime for support of reflection on functions
Introduce abstract class FunctionReference, which is supposed to be a
superclass for all anonymous classes generated for function references. Each
anonymous subclass will have statically-generated symbol info, which will be
used by reflection to locate the symbol
2015-05-26 15:05:01 +03:00
Alexander Udalov 27ed098467 Introduce kotlin.jvm.internal.Lambda, superclass for all lambdas
It has its arity precomputed, as opposed to the future KFunctionImpl inheriting
from FunctionImpl, for which the computation of arity can take some time and so
it shouldn't be passed in the constructor and saved as a field
2015-05-26 15:04:54 +03:00
Alexander Udalov 738a84e259 Temporary hack to migrate functions to package kotlin.jvm.functions
Add a file in package 'kotlin.jvm.functions' to the project and replace
explicit imports of functions 'kotlin.Function{n}' to two imports 'kotlin.*'
and 'kotlin.jvm.functions.*', so that the codebase can be compiled both by the
old and by the new compiler
2015-05-26 15:04:34 +03:00
Alexander Udalov 88abcdbde5 Minor, remove workarounds for the fixed KT-5786 2015-04-29 01:03:55 +03:00
Alexander Udalov d2cd7b00bb Map intrinsic companion objects in JavaToKotlinClassMap
Get rid of multiple usages of IntrinsicObjects where JavaToKotlinClassMap was
already used, simplify code, and support loading of *CompanionObject as Kotlin
built-in companions from Java code.

Also fix a small bug where Boolean was considered a class with an intrinsic
companion in IntrinsicObjects, although it was not
2015-04-24 02:09:26 +03:00
Alexander Udalov a59fa5015e Merge KotlinToJavaTypesMap into JavaToKotlinClassMap
Also use this new Kotlin->Java mapping in RuntimeTypeMapper instead of
inheriting directly from JavaToKotlinClassMapBuilder
2015-04-24 02:09:05 +03:00
Alexander Udalov b956fb5eb0 Pull Java<->Kotlin primitive type mapping up to JavaToKotlinClassMapBuilder 2015-04-24 02:09:04 +03:00
Alexander Udalov 4b07ec11ea Change Class<?> parameter to ClassId in JavaToKotlinClassMap implementations 2015-04-24 02:09:04 +03:00
Alexander Udalov 0dec1eaaad Refactor RuntimeTypeMapper, extract IntrinsicObjects-related behavior
Make it similar to other JavaToKotlinClassMapBuilder implementations to be able
to get rid of that inheritance
2015-04-24 02:09:04 +03:00
Alexander Udalov ad02706294 Get rid of unnecessary map in RuntimeTypeMapper 2015-04-24 02:09:04 +03:00
Alexander Udalov 6182b3ff5c Prohibit Array::class, require type arguments for reified parameters 2015-04-09 19:46:47 +03:00
Alexander Udalov 87ef4ff7c5 Fix KClassImpl#toString to render Kotlin FQ name, not JVM one 2015-04-07 20:25:06 +03:00
Alexander Udalov 9c1e7f93d2 Reflection: refactor property construction and fix memory leak
Properties obtained by KClass.properties were having strong references to
descriptors (captured by closures, which are strongly retained by
DescriptorBasedProperty). Support initial value in lazy soft properties
2015-04-07 20:22:52 +03:00
Alexander Udalov 715641fb0d Call getMethod/getDeclaredMethod depending on visibility 2015-04-07 20:20:40 +03:00
Alexander Udalov 0202217135 Fix JVM signatures involving multi-dimensional array types
Apparently ASM's Type#getElementType returns the type of the array even if it's
multi-dimensional, so the loop was incorrect
2015-04-07 20:06:23 +03:00
Alexander Udalov 7e86d87133 Move built-in companion intrinsics to core to reuse in reflection 2015-04-07 20:06:23 +03:00
Stanislav Erokhin b703f59e04 Migrate kotlin sources, maven projects and stdlib to new lambda syntax 2015-04-07 13:08:53 +03:00
Alexander Udalov d2ef040bcb Fix occasional reflection test failure
The cache in moduleByClassLoader.kt contains weak references to instances of
RuntimeModuleData. However, prior to this change no one else had any _strong_
reference to the corresponding RuntimeModuleData: KClassImpl depends on the
ModuleDescriptor almost directly. Therefore the weak references were sometimes
garbage collected and a new module was constructed for a new reflection object,
which resulted in broken equality between two reflection objects.

No test added because it was rather hard to come up with (and, more
importantly, to support) a test case.
2015-03-30 19:44:19 +03:00
Alexander Udalov d59e1ad7ac Minor, add toString() to WeakClassLoaderBox for debug 2015-03-30 19:44:18 +03:00
Alexander Udalov 7e69a5ac9a Don't create KProperty instance for synthetic field
#KT-5759 Fixed
2015-03-23 16:30:26 +03:00
Alexander Udalov a5a60b6917 Move code from file named util.kt to meaningful place 2015-03-23 16:30:25 +03:00
Alexander Udalov 31554b9fa3 Introduce ClassId.getShortClassName() for convenience 2015-03-23 16:30:24 +03:00
Alexander Udalov 9cf0720925 Fix KClass.simpleName for local classes 2015-03-23 16:30:24 +03:00
Alexander Udalov 5d0af36432 Minor, pull equals/hashCode/toString up to DescriptorBasedProperty 2015-03-23 12:21:24 +03:00
Alexander Udalov e60c299def Fix warnings in module 'reflection.jvm', clarify some code 2015-03-23 12:21:17 +03:00
Dmitry Jemerov 50c4a88661 suppress documentation for HashPMap 2015-03-19 10:41:58 +01:00
Dmitry Jemerov e9ffd589fc @suppress for APIs in kotlin.reflect.jvm.internal 2015-03-19 10:33:31 +01:00
Alexander Udalov 593613609f Document JVM-specific reflection API 2015-03-17 23:39:15 +03:00
Alexander Udalov a4f9fe1eaa Filter out invisible fakes in KClass.properties
A user will rarely need those at the moment, and there's currently no other way
to let him filter out them by himself
2015-03-17 23:39:13 +03:00
Alexander Udalov d3abd54b06 Add 'val KClass.declaredProperties', make getProperties a property 2015-03-17 23:39:13 +03:00
Pavel V. Talanov 06916d98c6 default -> companion: replace all mentions of default and default object 2015-03-17 15:47:39 +03:00
Alexander Udalov 9d6f4e99a1 Move reflection interfaces to module 'builtins'
They are considered to be built-ins everywhere anyway
2015-03-16 20:29:39 +03:00
Andrey Breslav 7b9d0cfc4f Minor. Compilation fixed 2015-03-11 19:38:17 +03:00
Alexander Udalov b93b9bd565 Support KClass.simpleName and built-in class literals 2015-03-11 16:42:43 +03:00
Alexander Udalov b3cdd818f0 Support member extension properties, implement KClass.getExtensionProperties()
#KT-6570 Fixed
2015-03-11 16:42:38 +03:00
Alexander Udalov da209e673c Implement KClass.getProperties()
#KT-6570 In Progress
2015-03-11 16:42:37 +03:00
Alexander Udalov fdfd808d80 Remove KForeignMemberProperty and KClassOrigin, use KMemberPropertyImpl instead 2015-03-11 16:42:36 +03:00
Alexander Udalov ff0044f66a Use descriptors for reflection on extension properties 2015-03-11 16:42:34 +03:00
Alexander Udalov 1a618deeab Use descriptors for reflection on top level properties
This also allows to obtain a Field object from the package part (see
mapping.kt)
2015-03-11 16:42:33 +03:00
Alexander Udalov d1debf586c Support local classes in reflection 2015-03-11 16:42:32 +03:00
Alexander Udalov 64fdb18ad3 Use descriptors for reflection on class properties
- use ConcurrentHashMap as a cache of class loaders to module descriptors
- KClassImpl now has a lazy class descriptor and it manages property creation
  by looking (also lazily) for the property descriptor in the corresponding
  scope
- since deserialized descriptors have full information about where a JVM symbol
  is located and what signature it has, new tests will begin to pass where
  Kotlin model and Java reflection model differ, see classObjectVar.kt
2015-03-11 16:42:31 +03:00
Alexander Udalov ba0ea1515b Minor, simplify/optimize KClassImpl creation 2015-03-11 16:42:30 +03:00
Alexander Udalov ecde41d9ab Introduce ReflectProperties for lazy weak/soft property delegates
This class needs to be written in Java because no Kotlin classes can be used in
KClassImpl constructor (otherwise since each Kotlin class creates a KClassImpl
in its static initializer, this would result in infinite recursion)
2015-03-11 16:42:29 +03:00
Alexander Udalov 356f54b5df Initial support of descriptor loading at runtime 2015-03-11 16:42:15 +03:00
Alexander Udalov a8046020fb Rename kotlin.reflect.IllegalAccessException -> IllegalPropertyAccessException
The former name clashes with java.lang.IllegalAccessException and proved to be
inconvenient because it should always be qualified in the source.

Also use java.lang exception's message as kotlin.reflect exception's message
2015-03-07 02:32:15 +03:00
Alexander Udalov 9c5bcdc72a Prettify code in 'reflection.jvm'
Use stdlib instead of hand-written hacks, fix some warnings and unneeded !!
2015-03-07 02:31:00 +03:00
Alexander Udalov 245b16dccc Drop unneeded factory methods due to ABI version increase
Either ReflectionFactory or direct creation is now used instead
2015-02-16 20:19:14 +03:00
Alexander Udalov 17c930c84f Use abstract factory for reflection objects on JVM
Introduce an abstract factory class ReflectionFactory which is responsible for creating
reflection objects (KClass, KProperty, ...). The meaningful implementation is
located in "reflection.jvm" where KClassImpl/KPropertyImpl/... are accessible
and can be instantiated. The default implementation will be used in the lite
runtime with no reflection and will return nulls / throw exceptions there.

Put all functions, calls to which are generated by JVM back-end, in one place:
the class named Reflection which contains only static methods. Previously these
functions were scattered across different files in module "reflection.jvm".

The code using reflection may now be compiled against either runtime, but
reflection features will work if and only if reflection is accessible at
runtime
2015-02-16 20:19:13 +03:00
Alexander Udalov 21b2fa2509 Update copyrights to 2015 2015-01-13 01:15:18 +03:00