Search This Blog

Loading...

Saturday, May 15, 2010

IDEA candy - Analyze external stack trace

Table of contents




Foreword



I've been IDEA user for more than five years but still discover new nice features with it. The rate of that discovering is increased since I've become IDEA developer because I work with people that implemented those features and, more importantly, use them in every day programming. So, I'm starting to blog about IDEA candies that are new to me.



Usage



I encounter the following use-case rather often - someone reports a problem and provides its stack-trace. IDEA allows to view it with convenient facility to directly navigate to target source code location.

Let me illustrate that. Suppose you want to help to solve a problem - e.g. this forum thread contains stack trace:


java.lang.ArrayIndexOutOfBoundsException: -1
at org.springframework.core.MethodParameter.getParameterType(MethodParameter.java:154)
at org.springframework.core.convert.TypeDescriptor.getType(TypeDescriptor.java:190)
at org.springframework.core.convert.TypeDescriptor.isTypeAssignableTo(TypeDescriptor.java:525)
at org.springframework.core.convert.TypeDescriptor.isMap(TypeDescriptor.java:283)
at org.springframework.expression.spel.ast.Indexer.getValueInternal(Indexer.java:92)
at org.springframework.expression.spel.ast.CompoundExpression.getValueInternal(CompoundExpression.java:57)
at org.springframework.expression.spel.ast.SpelNodeImpl.getValue(SpelNodeImpl.java:93)
at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:71)
at net.youngdev.springutils.expression.SpELUtilsTest.testGetValue(SpELUtilsTest.java:37)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)


You can copy the stack trace to the clipboard and view it at IDEA:

Open 'Analyze stacktrace' dialog via 'Main Menu -> Analyze -> Analyze Stacktrace':



Paste target stack trace and press 'Ok' button:



Check that analysed stack trace appears at 'Debug' panel - it contains clickable links to the source code (if source file for corresponding class is configured for the project):



You can also see that IDEA folds infrastructure calls (reflection processing, groovy internal processing etc) as well.

0 comments:

Post a Comment