What does $$ and means in java stacktrace?

后端 未结 1 573
逝去的感伤
逝去的感伤 2021-02-07 03:03

Many times I get stacktraces like this one (please see the arrow for the confusing line):

org.springframework.dao.DataIntegrityViolationException: could not exec         


        
1条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-07 03:26

    $ is an allowed character in class names.

    The name SimpleDetectorPersistenceService$$EnhancerBySpringCGLIB$$66303639 hints that it is a class which was dynamically generated at runtime by Spring framework using CGLIB.

    They use $$ and a numeric offset to make this class name unique to avoid conflicts with existing classes.

    The string () in the stracktrace too was generated by CGLIB:
    When CGLIB creates a class at runtime it uses as placeholder for the name of the source file. The stacktrace then simply prints this string instead of the real source file and line number.

    0 讨论(0)
提交回复
热议问题