Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.0-beta-4
-
None
-
None
-
Windows, Groovy 1.0-Beta3 and Groovy 1.0-Beta4-SNAPSHOT
Description
MarkupBuilder doesn't appear to allow references to variables inside of markup. Test case:
import groovy.xml.MarkupBuilder
class Bean {
String b
}
t = new Bean()
t.b = "hello"
println t.b
println "test: ${t.b}"
xml = new MarkupBuilder()
root = xml.foo {
bar {
// works
baz("test")
// fails
baz(t.b)
// fails
baz("${t.b}")
}
}
Output with 1.0-Beta 3:
hello
test: hello
<foo>
<bar>
<baz>test</baz>
<t />Caught: groovy.lang.MissingMethodException: No such method: bar for cla
ss: test$2 with arguments: [test$3@bfc8e0]
groovy.lang.MissingMethodException: No such method: bar for class: test$2 with a
rguments: [test$3@bfc8e0]
at groovy.lang.MetaClass.invokeStaticMethod(MetaClass.java:291)
at groovy.lang.MetaClass.invokeMethod(MetaClass.java:247)
at groovy.lang.MetaClass.invokeMethod(MetaClass.java:188)
at groovy.lang.Closure.invokeMethod(Closure.java:100)
at org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:117)
at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.
java:98)
at test$2.doCall(test.groovy)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at groovy.lang.Closure.call(Closure.java:186)
at groovy.lang.Closure.call(Closure.java:164)
at groovy.util.BuilderSupport.doInvokeMethod(BuilderSupport.java:129)
at groovy.util.BuilderSupport.invokeMethod(BuilderSupport.java:85)
at org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:117)
at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.
java:98)
at test.run(test.groovy:12)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at groovy.lang.MetaClass.doMethodInvoke(MetaClass.java:765)
at groovy.lang.MetaClass.invokeMethod(MetaClass.java:214)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at groovy.lang.MetaClass.doMethodInvoke(MetaClass.java:765)
at groovy.lang.MetaClass.invokeMethod(MetaClass.java:214)
at org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:130)
at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.
java:98)
at test.invokeMethod(test.groovy)
at org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:117)
at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.
java:98)
at org.codehaus.groovy.runtime.InvokerHelper.runScript(InvokerHelper.jav
a:311)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at groovy.lang.MetaClass.doMethodInvoke(MetaClass.java:765)
at groovy.lang.MetaClass.invokeStaticMethod(MetaClass.java:279)
at org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:124)
at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.
java:98)
at test.main(test.groovy)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at groovy.lang.MetaClass.doMethodInvoke(MetaClass.java:765)
at groovy.lang.MetaClass.invokeStaticMethod(MetaClass.java:279)
at org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:124)
at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.
java:98)
at groovy.lang.GroovyShell.run(GroovyShell.java:171)
at groovy.lang.GroovyShell.main(GroovyShell.java:85)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.codehaus.classworlds.Launcher.launchStandard(Launcher.java:410)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:344)
at org.codehaus.classworlds.Launcher.main(Launcher.java:474)
I also get the same results with an embedded version of 1.0-Beta 4.