You need to sign in to do that
Don't have an account?
Jim Cripe
Bug: Apex parser doesn't allow string constants to end with backslash
The Apex parser has a bug that won't allow a backslash to end string constants.
Try "System.debug('\\');" to see the problem.
The compiler thinks the string is unterminated and gives compile error "line breaks not allowed in string literals".
I have a workaround:
String DirectoryPath = '\\\\test\\file\\path';
String BackSlash = '\\this'; //Try to remove 'this' from the string and try to run to see the bug
BackSlash = BackSlash.replace('this', ''); //Hack to be able to build backslash terminated character string
DirectoryPath = DirectoryPath + ( DirectoryPath.EndsWith(BackSlash) ? '' : BackSlash );
System.debug(DirectoryPath);
Try "System.debug('\\');" to see the problem.
The compiler thinks the string is unterminated and gives compile error "line breaks not allowed in string literals".
I have a workaround:
String DirectoryPath = '\\\\test\\file\\path';
String BackSlash = '\\this'; //Try to remove 'this' from the string and try to run to see the bug
BackSlash = BackSlash.replace('this', ''); //Hack to be able to build backslash terminated character string
DirectoryPath = DirectoryPath + ( DirectoryPath.EndsWith(BackSlash) ? '' : BackSlash );
System.debug(DirectoryPath);
I got this email on 6/24 regarding the case:
--------------------
Thank you for contacting Salesforce.com Technical Support.
I would like to inform you that the support you are requesting requires higher level of expertise.
Please contact our developer team at http://developer.salesforce.com and submit a query.
If you have any questions or concerns do not hesitate to contact us at 1-800-667-6389 for further information.
Kind regards,
<blanked support person's name>
salesforce.com
-------------------
When I logged in to developer, I found the case was closed, and when I called to find out what to do, I was told to submit to the issue to the discussion boards.
I informed the technician that I had already done that and sent him the URL to the original posting.
He is going to try to get someone to look into the issue.
It took eleven days to get this far?! : (
Message Edited by Jim Cripe on 06-24-2008 12:40 PM
I apologize for the run around we gave you and thank you for not giving up on us. A bug has been created: #191851.
I just tested in our Sandbox1 that has been updated to Winter '09.
Doing this, (execute anonymous):
System.debug('\\');
Will get this error:
Compile error at line 1 column -1
line breaks not allowed in string literals
Is there any estimated time for this bug to be fixed?
I didn't get any word back from SF on the fix though.
Doing this (execute Anonymous):
System.debug('\\');
Now gets this:
Anonymous execution was successful.
20081117230815.478:AnonymousBlock: line 1, column 1: Anonymous
20081117230815.478:AnonymousBlock: line 1, column 1: System.debug(String)
20081117230815.478:AnonymousBlock: line 1, column 1: \
But can a string literal span multiple source lines?
string xmlString = '<xml>\
<child /> \
<\xml>';
Unfortunately, not.