Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

156
Visualizações
Does Kotlin generated byte code affect the method count?

For example, if I use

methodReference = ::method

rather than

methodReference = { method(it) }

decompiled code will contain getOwner, getName, getSignature methods in Java code, due to reflection. Do these methods counted against 64k limit ?

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

The methods are counted, only if they are not removed by proguard/R8

An example

  fun method(t : Any) {}
  val reference1: KFunction1<Any, Unit> = ::method
  val reference2: (Any) -> Unit = { method(it) }

For the reference1 the bytecode (decompiled to Java) would be:

   @NotNull
   final KFunction reference1 = new Function1((X)this) {
      // $FF: synthetic method
      // $FF: bridge method
      public Object invoke(Object var1) {.. }
      public final void invoke(@NotNull Object p1) {..}
      public final KDeclarationContainer getOwner() {..}
      public final String getName() {..}
      public final String getSignature() {..}
   };

for the lambda (or reference2) the equivalent java code is:

   @NotNull
   final Function1 reference2 = (Function1)(new Function1() {
      // $FF: synthetic method
      // $FF: bridge method
      public Object invoke(Object var1) {..}
      public final void invoke(@NotNull Object it) {..}
   });

So the difference is 4 +1 for method reference and 1 +1 for lambda, where +1 comes from the the bridge method invoke(t:Any)

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda