#471 Line Numbers are Wrong in the Case of Method Inlining

v4.7
open
None
5
2014-08-21
2013-04-05
No

I got such a crash report:
java.lang.NullPointerException
at com.acme.popcorn.s.a(SessionedModel.java:67)

the line 67 is:
if (isMain401(aDownloadTask)) {

where obviously is impossible to get a NPE.

I presume the method isMain401 got inlined. However all the instructions which got inlined have the same line number (the line number of invocation of the inlined method). They should have an appropriate line number from isMain401 method definition.

Discussion

  • Eric Lafortune

    Eric Lafortune - 2013-04-17

    If the inlined method originates from a different source file, the Java bytecode format can't represent those line numbers (the debug information of a class file can only represent a single source file). This is why those line numbers are erased.

    If the inlined method originates from the same source file, that actually isn't a problem. The line numbers can then be preserved and inserted in the proper location. However, the line number of the invocation will be lost. I'll consider this as an enhancement.

     
  • Eric Lafortune

    Eric Lafortune - 2013-04-17
    • assigned_to: Eric Lafortune
     
  • Marek Urbaniak

    Marek Urbaniak - 2013-04-18

    Thanks Eric, this is what I meant, inlining within the same file.

     
  • Chris Vaughan

    Chris Vaughan - 2013-12-24

    I've got a similar issue, or possibly a different use case for the same issue. I'm also using v4.7.

    Stack trace:
    Thread: main, Exception: java.lang.NullPointerException
    at com.blah.CardDetailsActivity.boolean access$1000(com.blah.CardDetailsActivity)(SourceFile:76)
    at com.blah.CardDetailsActivity$5.void onClick(android.view.View)(SourceFile:260)
    ...

    CardDetailsActivity line 76 is the class declaration:
    public class CardDetailsActivity extends BookingActivity {

    Line 260 is simply:
    if (isFormValid()) {

    isFormValid() is a private method which is only called in one place - from inside an anonymous inner class.

    I gather the access$1000(CardDetailsActivity) method is created by the compiler in order to allow the inner class to access its private method. From what I can tell, isFormValid() is being inlined into the access$1000(CardDetailsActivity) method.

    It would be great if the original line numbers could still be preserved in this case.

     

Log in to post a comment.