Details
-
Type:
Bug
-
Status:
Open
-
Priority:
Major
-
Resolution: Unresolved
-
Affects Version/s: 1.5.6
-
Fix Version/s: 3.0
-
Component/s: None
-
Labels:None
-
Environment:Windows XP
-
Number of attachments :
Description
Sample program and output. The closure and the method both call 'outer'
which calls 'inner', but the closure does NOT trace the call to 'outer'
See comments, including Jochen "blackdrag" Theodorou's at
http://www.nabble.com/implementing-GroovyInterceptable-behaves-differently-in-closures-and-methods-td19072057.html
************program output
Entering shouldTraceOuterAndInnerClosure
Entering inner
Leaving inner
Leaving shouldTraceOuterAndInnerClosure
Entering shouldTraceOuterAndInnerMethod
Entering outer
Entering inner
Leaving inner
Leaving outer
Leaving shouldTraceOuterAndInnerMethod
*************end program output
****************code starts
import org.codehaus.groovy.runtime.StringBufferWriter
import org.codehaus.groovy.runtime.InvokerHelper
class Traceable implements GroovyInterceptable {
private static int indent = 1
Writer writer = new PrintWriter(System.out)
Object invokeMethod(String name, Object args)
}
class Whatever extends Traceable {
int outer()
int inner()
{ return 1 }def shouldTraceOuterAndInnerClosure =
{ return outer() }int shouldTraceOuterAndInnerMethod() { return outer() }
}
def log = new StringBuffer()
def traceMe = new Whatever(writer : new StringBufferWriter(log))
traceMe.shouldTraceOuterAndInnerClosure()
traceMe.shouldTraceOuterAndInnerMethod()
println log.toString()
****************program ends*************
Issue Links
- depends upon
-
GROOVY-2503
MOP 2.0 design inflluencing issues
-