Bug 5142 - .jar binding: string constants with embedded newlines, numeric class names
Summary: .jar binding: string constants with embedded newlines, numeric class names
Status: RESOLVED FIXED
Alias: None
Product: Android
Classification: Xamarin
Component: Tools and Addins ()
Version: 4.1.x
Hardware: PC Mac OS
: Normal normal
Target Milestone: ---
Assignee: Atsushi Eno
URL:
Depends on:
Blocks:
 
Reported: 2012-05-17 10:21 UTC by Jonathan Pryor
Modified: 2012-05-21 04:44 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Scratch.Org.Json.zip (40.68 KB, application/zip)
2012-05-17 10:21 UTC, Jonathan Pryor
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Jonathan Pryor 2012-05-17 10:21:39 UTC
Created attachment 1905 [details]
Scratch.Org.Json.zip

.jar binding doesn't like binding constant fields that have embedded newlines.

To reproduce, bind json-org.jar from:

    http://www.docjar.com/jar_detail/json-org.jar.html

Or see the conveniently attached project. ;-)

The problem is that there are two fixups that are required in order to bind json-org.jar; from Transforms\Metadata.xml:

>  <remove-node path="/api/package[@name='org.json']/class[@name='HTTP']/field[@name='CRLF']" />
>  <remove-node path="/api/package[@name='org.json']/class[@name='Test.1Obj']" />

We can't bind the HTTP.CRLF field, because it has an embedded newline in it. This causes `generator` to produce:

    public const string Crlf = "
";

which makes the C# compiler angry. We should instead generate:

    public const string Crlf = "\u000d\u000a";

(We should probably unicode-encode any character outside the range 0x20 through 0x7f as well, though this might also break surrogate pairs...or can \uXXXX\uYYYY be used to do surrogate pairs properly?)

The second problem is the org.json.Test.1Obj class, which can't be bound because it starts with a number. Firstly, it shouldn't be bound (it's not public!). Secondly, any type that starts with a number should just be skipped, not bound.
Comment 1 Atsushi Eno 2012-05-21 03:27:01 UTC
String literal part is fixed.
Comment 2 Atsushi Eno 2012-05-21 04:44:41 UTC
Numeric class issue also fixed.