views:

106

answers:

3

I am trying to profile an application and I have a lot of instances of type sim.core.EndPoint$2

When I inspect those instances I verify they are not of type sim.core.EndPoint, they seem to be an EndPoint with a few more things that shouldn't be there.

What does a dollar sign mean after the name of a type in visualVM?

Thank you.

+2  A: 

That means it's an anonymous inner class defined in EndPoint.java.

By the way, ClassName$AnotherName is a convention for specifying inner classes in JVM.

Look which anonumous classes does EndPoint define.

alamar
Well, it can't be. Because I have only one inner class inside EndPoint.java, EndPointStats, and EndPoint$2 seem to have things completely unrelated with Stats, like fields related to task scheduling etc. Thank you for your help.
simao
Can you paste EndPoint.java somewhere?
alamar
+1  A: 

It is most certainly a compiler artifact (something hidden to you but necessary for this to work).

If it is not an anonymous class, it may be the way for the anonymous object to refer to the enclosing class. Do you have any final objects on the "outside" that you refer to from within your anonoymous class?

Thorbjørn Ravn Andersen
Actually I do start a new anonymous sim.core.Task class which uses an EndPoint declared "outside" as final. So the $2 refers to this sim.core.Task?
simao
No, it most likely refers to the EndPoint. The Java compiler uses trickery to allow your anonymous class to get to the final even though it is in another class.
Thorbjørn Ravn Andersen
A: 

Thank you alamar and Thorbjørn, I found out the issue thanks to your comments. I marked alamar's answer as accepted because I think it directly answers the question although Thorbjørn did help me find a solution.

I had a loop that was creating anonymous Tasks inside an EndPoint.

simao