Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Meanings of dollar sign in Java method descriptor?

For example, its part of the Jikes RVM stack.

at [0x70cfba90, 0x708cfaa4] Lorg/apache/lucene/index/SegmentInfos; 
       **access$000**(Ljava/lang/String;)V
at [0x70cfbb04, 0x708b55c8] Lorg/apache/lucene/index/SegmentInfos$
       FindSegmentsFile; run()Ljava/lang/Object; at line 554
at [0x70cfbb24, 0x708c4a8d] Lorg/apache/lucene/index/SegmentInfos; 
       read(Lorg/apache/lucene/store/Directory;)V at line 272

'access' should be a method name. But I checked the class source code and its interfaces, there is no method there called 'access'. I couldn't find an answer on Google, since Google hates all kinds of punctuations. Can anyone help here? Thanks very much.

like image 789
qinsoon Avatar asked Sep 28 '11 04:09

qinsoon


People also ask

What is '$' in Java?

First, in Java '$' is a valid symbol for variable names and you can just use it for whatever you like: making your code cla$$ier, denoting that variables are private under a code convention, etc. Second, '$' is used as a separator character for the Java compiler to specify when a class is declared under another class.

Why is dollar sign used in Java?

The getSymbol(Locale locale) is the method of Java Currency class which is used to get the symbol of invoking currency for the specified locale. For example, for the US Dollar if the specified local is US, the symbol is "$" otherwise, it may be "US$".

What does the dollar sign mean in Java stack trace?

The nested classes are distinguished from the higher-level nested classes and from the top-level class by using the dollar sign character ($). So, technically, the "simple" name of the second nested class is StackTrace$FirstNested$SecondNested.

Can a variable name start with dollar sign?

Variables: A name can't start with a numeral, but a numeral can occur anywhere else. dollar sign ('$') is an illegal character.


1 Answers

Quoted from the article linked by @birryree:

A private member m of a class C may be used by another class D, if one class encloses the other, or if they are enclosed by a common class. Since the virtual machine does not know about this sort of grouping, the compiler creates a local protocol of access methods in C to allow D to read, write, or call the member m. These methods have names of the form access$0, access$1, etc. They are never public. Access methods are unique in that they may be added to enclosing classes, not just inner classes.

like image 96
2 revs Avatar answered Nov 01 '22 08:11

2 revs