Android Question Error compiling in debug mode.

vecino

Well-Known Member
Licensed User
Longtime User
Hello, when I'm going to compile in debug mode I get this message:
B4A Version: 8.30
Parsing code. (1.01s)
Compiling code. (1.70s)
Compiling layouts code. (0.06s)
Organizing libraries. (0.00s)
Generating R file. (0.10s)
Compiling debugger engine code. Error
B4A line: 1669
End Sub
javac 1.8.0_131
shell\src\conkex\preventa\acimportacion_subs_0.java:6695: error: code too large for try statement
catch (Exception e0) {
^
1 error
This happens today. Yesterday did not happen.
Compiling in release mode works fine.
With other projects it works well.
What can I look for?
Thank you
 

npsonic

Active Member
Licensed User
It just saying that you have too much stuff in your Try Catch statement.
Split it to multiple Try Catch statements to get rid of the problem.
 
Upvote 0

vecino

Well-Known Member
Licensed User
Longtime User
Is there a maximum number of "try catch" in debug mode?
Why does it work in release mode?
Why yesterday worked, and not today?
Thank you.
 
Upvote 0

npsonic

Active Member
Licensed User
No, but there is limit how much code you can put inside one try catch statement and one sub.
Maybe you add something into try catch statement or the that specific sub and went over the limit?

This is what Erel posted few years ago, so it's more like limit of how much code there can be in one sub.
There is a Java limit of 64kb of bytecode per method.

Don't know why it works with release and not with debug, but if I guess I would say that when compiled in release something is left out that is only needed in debug and size goes under the limit.
Erel knows for sure answer for this.
 
Upvote 0

vecino

Well-Known Member
Licensed User
Longtime User
Thanks so much for the explanation.
To test, I have eliminated some "try catch" and it worked well.
It really is a problem for me.
 
Upvote 0

vecino

Well-Known Member
Licensed User
Longtime User
This error happens when you have very large subs. A common case is when a developer mixes the data and the program code.
Hello, yes, the problem occurs in a sub of more than a thousand lines.
A text file is read to import data into a database.
It is a loop that reads line by line and is entered in each table, according to a prefix.
What can I do to optimize the code?
B4X:
Do While cLin <> Null
  cLin = Reader.ReadLine
  cLin = cLin.Replace(",",".")
  Select cPrefijo
    Case cFAMim:   
      c1 = cLin.SubString2(0,7)
      c2 = cLin.SubString2(7,37)
      Try
        globales.DBconex.ExecNonQuery2("insert into '" & cTabla & "' values (?,?)",Array As String(c1,c2))
      Catch
        Log(cTabla&": "&LastException.Message)
      End Try
    Case cCLIim:
      c1  = cLin.SubString2(0,10)
      c2  = cLin.SubString2(10,40)
      c3  = cLin.SubString2(40,70)
      c4  = cLin.SubString2(70,100)
      c5  = cLin.SubString2(100,130)
      c6  = cLin.SubString2(130,144)
      c7  = cLin.SubString2(144,164)
      c8  = cLin.SubString2(164,184)
      c9  = cLin.SubString2(184,185)
      c10 = cLin.SubString2(185,186)
      Try
        globales.DBconex.ExecNonQuery2("insert into '" & cTabla & "' values (?,?,?,?,?,?,?,?,?,?)",Array As String(c1,c2,c3,c4,c5,c6,c7,c8,c9,c10))
      Catch
        Log(cTabla&": "&LastException.Message)
      End Try
    Case cPENim:
And so, more than a thousand lines.
 
Upvote 0
Top