Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does $$ and <generated> mean in Java stacktrace?

Tags:

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

org.springframework.dao.DataIntegrityViolationException: could not execute statement; SQL [n/a]; constraint [PRIMARY]; nested exception is org.hibernate.exception.ConstraintViolationException: could not execute statement                 at org.springframework.orm.hibernate5.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:164)                 at org.springframework.orm.hibernate5.HibernateTransactionManager.convertHibernateAccessException(HibernateTransactionManager.java:741)                 at org.springframework.orm.hibernate5.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:589)                 at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:761)                 at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:730)                 at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:485)                 at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:291)                 at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)                 at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)                 at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:653) --------->      at com.panpwr.admin.services.detector.SimpleDetectorPersistenceService$$EnhancerBySpringCGLIB$$66303639.saveComplexRuleAndActionTemplates(<generated>)                 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)                 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)                 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ... ... ... 

What does the $$ sign mean, and what is the 'generated' in this line? com.panpwr.admin.services.detector.SimpleDetectorPersistenceService$$EnhancerBySpringCGLIB$$66303639.saveComplexRuleAndActionTemplates(<generated>)

And why does it only say the executed method but not the line number in it?

like image 764
user1028741 Avatar asked Nov 09 '15 08:11

user1028741


People also ask

How is stack trace generated?

The stack trace contains all invocations from the start of a thread until the point it's generated. This is usually a position at which an exception takes place. When printed out, the generation point shows up first, and method invocations leading to that point are displayed underneath.

What is stack trace in Java with example?

What's a Java Stack Trace? A stack trace, also called a stack backtrace or even just a backtrace, is a list of stack frames. These frames represent a moment during an application's execution. A stack frame is information about a method or function that your code called.

How do you read a stack trace?

To read this stack trace, start at the top with the Exception's type - ArithmeticException and message The denominator must not be zero . This gives an idea of what went wrong, but to discover what code caused the Exception, skip down the stack trace looking for something in the package com.

What is exception stack trace?

A trace of the method calls is called a stack trace. The stack trace listing provides a way to follow the call stack to the line number in the method where the exception occurs. The StackTrace property returns the frames of the call stack that originate at the location where the exception was thrown.


1 Answers

$ 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 (<generated>) in the stracktrace too was generated by CGLIB:
When CGLIB creates a class at runtime it uses <generated> 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.

like image 184
wero Avatar answered Oct 10 '22 16:10

wero