Bumped into 64KB limitation for methods in Java

I took quite an unusual approach in my library. Lots of generic traits and lots of givens. When I get an error that a given couldn’t be found the text output into the console is huge. Perhaps it could be the reason of the problem I’ve got now. The generated code exceeds 64 KB limitation for methods in Java.

[error] Generated bytecode for method 'net.mem_memov.binet.hexagon.ClusterOfTwoSuite.$anonfun$6$$anonfun$1$$anonfun$1$$anonfun$1$$anonfun$1$$anonfun$1$$anonfun$1$$anonfun$2$$anonfun$1$$anonfun$1$$anonfun$1$$anonfun$1$$anonfun$1$$anonfun$1$$anonfun$1$$anonfun$1$$anonfun$1' is too large. Size: 68688 bytes. Limit is 64KB

My methods are not that large. I tried to pinpoint the problematic one by hand and came to the conclusion that the whole library gets merged into one method. Because the method that I found was a couple of lines long.

I’m wondering is there a way out of this. It seems I have to rewrite lots of files. Has anyone been confronted with the 64KB problem?

My repository is here if you would wish to have a look.

1 Like

I solved the issue with the help of @Aly in Discord. Just added => before each argument:

  given [DOT, NETWORK, SELF_REFERENCE, SUCCESSOR, SUCCESSOR_REFERENCE](using
    => GetPredecessorFields[DOT, SELF_REFERENCE, SUCCESSOR_REFERENCE],
    => IsReferencedByPredecessor[SUCCESSOR, SUCCESSOR_REFERENCE],
    => Follow[SUCCESSOR, NETWORK, Predecessor[DOT]],
    => ToPredecessor[SUCCESSOR, Predecessor[DOT]],
    => ReplaceIfInSameLocation[Predecessor[DOT]],
    => ReadSuccessorOption[SUCCESSOR_REFERENCE, NETWORK, SUCCESSOR]
  ): Rearrange[Predecessor[DOT], NETWORK, SUCCESSOR] with
1 Like

How would that generate so much bytecode?