Skip to content

grumpyjames/stacktracer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Stacktracer

Suspicion:

  • Call paths in object oriented code should be acyclic

Problem:

  • Bawling at people to make things acyclic post-facto doesn't scale

Hope:

  • Automating the nagging by encoding anti-cycle thinking into an assertion might work better

Thus: Stacktracer - a library for analysing Java stack traces for circular call paths.

Example usage

Capture a stack:

final List<StackTraceElement> stackTrace = StackTrace.getStackTrace();

Transform it to include just the elements you like:

final StackTransformer transformer = 
    after(klass(TestFramework.class)).and(before(PublisherProxy.class))
final List<StackTraceElement> transformed = transformer.apply(stackTrace);

Scan a stack trace for cycles:

final CycleReport report = CycleDetectors.scanForCycles(transformed);
for (final String klassName: report.classNamesThatCycled()) {
    System.out.println("Found a cycle that visits " + klassName + " at least twice!");
}

About

A library for detecting cycles in stack traces

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published