These are chat archives for JetBrains/kotlin

18th
Sep 2015
Aliaksei Zhynhiarouski
@aliaksei-lithium
Sep 18 2015 08:33

Hi guys, try to embed Kotlin into Karaf OSGI bundle. My Example: A have an app bundle. If I just embed Kotlin dependencies into it - it all works great. But when try to share this dependencies between several modules, have a problem. My solution, in one api module try embed kotlin like this, and then use as provided dependency in others

 <dependencies>
        <dependency>
            <groupId>org.jetbrains.kotlin</groupId>
            <artifactId>kotlin-stdlib</artifactId>
            <version>${kotlin.version}</version>
        </dependency>
        <dependency>
            <groupId>org.jetbrains.kotlin</groupId>
            <artifactId>kotlin-runtime</artifactId>
            <version>${kotlin.version}</version>
        </dependency>
        <dependency>
            <groupId>org.jetbrains.kotlin</groupId>
            <artifactId>kotlin-reflect</artifactId>
            <version>${kotlin.version}</version>
            <scope>runtime</scope>
        </dependency>
 </dependencies>
 <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <extensions>true</extensions>
                <configuration>
                    <instructions>
                        <Bundle-Version>${project.version}</Bundle-Version>
                        <Embed-Dependency>
                            kotlin.*,
                            *;scope=compile|runtime
                        </Embed-Dependency>
                        <Export-Package>
                            kotlin.*
                        </Export-Package>
                    </instructions>
                </configuration>
            </plugin>

Then when install this bundle get follow exceptions

Caused by: java.lang.NullPointerException: no base type
        at org.apache.webbeans.portable.AbstractAnnotated.<init>(AbstractAnnotated.java:68)
        at org.apache.webbeans.portable.AbstractAnnotatedMember.<init>(AbstractAnnotatedMember.java:54)
        at org.apache.webbeans.portable.AbstractAnnotatedCallable.<init>(AbstractAnnotatedCallable.java:47)
        at org.apache.webbeans.portable.AnnotatedMethodImpl.<init>(AnnotatedMethodImpl.java:46)
        at org.apache.webbeans.portable.AnnotatedTypeImpl.init(AnnotatedTypeImpl.java:93)

Try to debugg AbstractAnnotated and get null(after javaMember.getGenericReturnType()) here http://grepcode.com/file/repo1.maven.org/maven2/org.apache.openwebbeans/openwebbeans-impl/1.1.4/org/apache/webbeans/portable/AnnotatedMethodImpl.java?av=f#46
where javaMember=public final java.lang.Object kotlin.concurrent.ConcurrentPackage$sam$Callable$32a83445.call() and declaringType=Base Type : class kotlin.concurrent.ConcurrentPackage$sam$Callable$32a83445,Type Closures : null,Annotations : [@kotlin.jvm.internal.KotlinSyntheticClass(version=[0, 25, 0], abiVersion=25, kind=SAM_WRAPPER)]