logo       

Re: Meta Characters \t \n \r in String Literal: msg#00100

lang.groovy.user

Subject: Re: Meta Characters \t \n \r in String Literal

I think I'm seeing something similar using Groovy Version: 1.0-beta-7
JVM: 1.4.2_05-b04

'cmd /c dir /b /s \\myProjectName\\trunk\\*.java'.execute()
behaves differently from:
"cmd /c dir /b /s \\myProjectName\\trunk\\*.java"'.execute()

Based on my limited understanding of groovy, I thought those two
statements would work the same, but they don't. In the process of
trying to figure out what I was doing wrong I compiled both versions
and ran the .class through Jad. I noticed an extra slash being
inserted before the "trunk" in second example. The output from Jad is
as follows:

InvokerHelper.invokeNoArgumentsMethod("cmd /c dir /b /s
\\myProjectName\\trunk\\*.java", "execute");

and

InvokerHelper.invokeNoArgumentsMethod("cmd /c dir /b /s
\\myProjectName\\\trunk\\*.java", "execute"); // notice the extra
slash before "trunk"

When I looked at the .class with a hex editor, I noticed there was a
tab character in place of the 't' in trunk in the second example, so I
think Jad is decompiling properly.

Interestingly, when I tried:

"cmd /c dir /b /s \\myProjectName\\\trunk\\*.java"'.execute()

the output is the same in the second example above:

InvokerHelper.invokeNoArgumentsMethod("cmd /c dir /b /s
\\myProjectName\\\trunk\\*.java", "execute");

Is this behavior expected?

thanks,
Jason



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise