Java Question Wrap lib from pure Kotlin

Pendrush

Well-Known Member
Licensed User
Longtime User
I'm trying to wrap simple library from pure Kotlin including wrapper. I have succeeded, but I have some question.

This is Kotlin code:
Java:
package com.example.wrapper

import anywheresoftware.b4a.BA
import anywheresoftware.b4a.BA.ShortName
import anywheresoftware.b4a.BA.Events
import anywheresoftware.b4a.BA.DependsOn
import anywheresoftware.b4a.BA.Version
import com.example.mylib.TestLib

@ShortName("LibTest")
@BA.Permissions(values=["android.permission.ACCESS_FINE_LOCATION"])
@Events(values = ["TestEvent"])
@DependsOn(values = ["mylib-release.aar", "kotlin-stdlib-1.3.71", "annotations-13.0"])
@Version(1.0f)

public open class Wrapper {

    val a = TestLib()
    fun Initialize() {
    }

    fun HelloWorld(): String {
        return a.stringTest()
    }
}


This is Java code returned from bytecode (decompile) from Tools->Kotlin->Show Kotlin Bytecode, then click on Decompile button:
Java:
package com.example.wrapper;

import anywheresoftware.b4a.BA.ShortName;
import anywheresoftware.b4a.BA.Version;
import com.example.mylib.TestLib;
import kotlin.Metadata;
import org.jetbrains.annotations.NotNull;

@ShortName("LibTest")
@Version(1.0F)
@Metadata(
   mv = {1, 1, 16},
   bv = {1, 0, 3},
   k = 1,
   d1 = {"\u0000 \n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\u000e\n\u0000\n\u0002\u0010\u0002\n\u0000\b\u0017\u0018\u00002\u00020\u0001B\u0005¢\u0006\u0002\u0010\u0002J\u0006\u0010\u0007\u001a\u00020\bJ\u0006\u0010\t\u001a\u00020\nR\u0011\u0010\u0003\u001a\u00020\u0004¢\u0006\b\n\u0000\u001a\u0004\b\u0005\u0010\u0006¨\u0006\u000b"},
   d2 = {"Lcom/example/wrapper/Wrapper;", "", "()V", "a", "Lcom/example/mylib/TestLib;", "getA", "()Lcom/example/mylib/TestLib;", "HelloWorld", "", "Initialize", "", "wrapper_release"}
)
public class Wrapper {
   @NotNull
   private final TestLib a = new TestLib();

   @NotNull
   public final TestLib getA() {
      return this.a;
   }

   public final void Initialize() {
   }

   @NotNull
   public final String HelloWorld() {
      return this.a.stringTest();
   }
}


If you look closely this part is missing in decompiled Java code:
Java:
import anywheresoftware.b4a.BA.Events
import anywheresoftware.b4a.BA.DependsOn

@BA.Permissions(values=["android.permission.ACCESS_FINE_LOCATION"])
@Events(values = ["TestEvent"])
@DependsOn(values = ["mylib-release.aar", "kotlin-stdlib-1.3.71", "annotations-13.0"])


I can add this part manually, but question is why some imports and some annotations is missing?

EDIT:
Annotations and imports also missing in bytecode, here is bytecode:


PS.
My test lib work flawlessly in B4a, written and wrapped in pure Kotlin for B4a.
 
Last edited:
Cookies are required to use this site. You must accept them to continue using the site. Learn more…