Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does a $ prefix in a java classname mean?

Tags:

java

I have a stacktrace for an app that includes the following nugget:

com.google.inject.internal.util.$ComputationException

What does the $ in front of the class name indicate?

like image 781
emmby Avatar asked Dec 16 '22 04:12

emmby


2 Answers

In the Java internals, the $ character is considered a valid identifier character just like letters or numbers. However, it's usually used internally by the compiler when generating things like inner classes.

From the Java Language Specification:

The Java letters include uppercase and lowercase ASCII Latin letters A-Z (\u0041-\u005a), and a-z (\u0061-\u007a), and, for historical reasons, the ASCII underscore (_, or \u005f) and dollar sign ($, or \u0024). The $ character should be used only in mechanically generated source code or, rarely, to access preexisting names on legacy systems.

like image 131
Greg Hewgill Avatar answered Dec 31 '22 13:12

Greg Hewgill


It means that ComputationException is contained within another class or otherwise not publicly visible.

See http://www.retrologic.com/innerclasses.doc7.html .

like image 37
Borealid Avatar answered Dec 31 '22 12:12

Borealid