Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does number .access$XXXX stand for?

Tags:

java

I've got a string in a stack, such as "at alexei.ATable$IndexOfATable.access$1400(ATable.java:80)"

And i'm interesting, what is the number 1400? Inner class IndexOfATable has only 3 fields, not 1400.

Intresting, Why the number 1400 is so big?

debug:
Exception in thread "main" java.lang.NullPointerException
    at alexei.ATable$IndexOfATable.compareTwoRows(ATable.java:181)
    at alexei.ATable$IndexOfATable.access$1400(ATable.java:80)
    at alexei.ATable.updateIndex(ATable.java:501)
    at alexei.ATable.addRow(ATable.java:361)
    at learn.Base.main(Base.java:18)
Java Result: 1
like image 549
Dumas45 Avatar asked May 25 '13 08:05

Dumas45


1 Answers

It's a synthetic method that the compiler generates in order to deal with the inner class. The Java bytecode doesn't have the concept of an inner class, so when it's compiled it performs various tricks to "fake" the presence of one at runtime. In this particular case, the access$XXX class of methods are generally associated with providing a reference to the outer class from the inner one. Such synthetic entities are signs of this. (You can usually spot them by the presence of a dollar in the class / method name.)

Why the number 1400 is so big?

It's a purely arbitrary identifier that only the compiler needs to know about (and thus chooses.) As long as it's unique within the application, it could be anything (technically speaking, it doesn't even have to be a number.)

As for where the problem lies, have a look at the line given by the top most stack trace: ATable.java:181.

like image 102
Michael Berry Avatar answered Sep 27 '22 18:09

Michael Berry