What does a dollar with an index in a class name mean?

I am profiling a Java application and the largest number of allocated objects is named com.xyClassName$5 .

Both the netbeans profiler and yourkit use the same naming convention. I am losing how google name problem.

What is $5 after class name?

EDIT: It seems 5th is declared the fifth anonymous class. I used javap for the generated class to find the fifth anonymous class. The link found in How to match a compiled class name to an enum member in Java?

+6
source share
2 answers

com.xyClassName $ 5 means "the fifth anonymous inner class in com.xyClassName"

+19
source

Some links to help you. Also see the polygenic lubricant response

you get com.xyClassName $ 5 . when your class contains an anonymous inner class

  sample8.class sample8$1.class sample8$2.class sample8$klass.class sample8$klass$1.class 

Example

  public class sample8 { private class klass{ void vodka() { sample8 _s = new sample8() { }; } } sample8() { klass _k = new klass(); _k.vodka(); } public static void main(String args[]) { } sample8 _s = new sample8() { }; sample8 _s1 = new sample8() { }; } 
+1
source

Source: https://habr.com/ru/post/904150/


All Articles