Android Question error: code too large

Marco Maria Vilucchi

Active Member
Licensed User
hi,
I have a caompilation error:


Compilazione del codice Java prodotto. Error
javac 1.8.0_191
src\com\mamavi\slimup\ciclorisultante.java:13926: error: code too large
public void resume(BA ba, Object[] result) throws Exception{
^
1 error

I don't know what means
I saw in the forum same error for try catch but I haven't this code in this module

someone can help me?
thanks in advance
Marcom
 

Marco Maria Vilucchi

Active Member
Licensed User
CicloRisultante is a module of over 13000 intructions.

I added 5 loop like this:

B4X:
            For i=1 To 34
                If Main.cardtrat5(i)<>Cols(i+2) Then
                    trattamenticomecard=False
                End If
            Next
whithout these lines app works.
These lines are in a sub with 100 instructions.

I temporarily solved by breaking the sub into two subs, but I don't know if it is the right solution
 

agraham

Expert
Licensed User
The rather unhelpful "code too large" error means that the Java bytecode emitted by the compiler has hit some size limit. It might be too many lines in a method, it might be the size of a class if this is a class module. I am a bit surprised that a recent Java compiler cannot cope with this, are you using a 32-bit JDK?
 

emexes

Well-Known Member
Licensed User
The rather unhelpful "code too large" error means that the Java bytecode emitted by the compiler has hit some size limit. It might be too many lines in a method, it might be the size of a class if this is a class module.
There is a 64kB limit on method code size. Can't find the original reference right now, but it was a problem in this thread as well:

https://www.b4x.com/android/forum/threads/best-way-to-get-15k-integers-from-spreadsheet-to-b4j.107941/#post-674937

But I can't imagine 100 lines getting anywhere near that limit.
These lines are in a sub with 100 instructions.
 

Erel

Administrator
Staff member
Licensed User
Breaking the sub into multiple subs is the correct solution. It will also be simpler to maintain the code.

It is strange that it happens in a 100 lines sub. As the sub is a resumable sub it makes the generated code larger.
 

udg

Expert
Licensed User
Not to mention trailing zeroes :)

Interestingly, we're talking about 1's and 0's ... eheheh
 
Top