question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Google Gson JSON library translates, but tests cases fail.

See original GitHub issue

I am trying to get Gson through j2objc such that I can use it from my iOS project. I have downloaded version 2.3 and all main and test sources translate correctly. However, when running the tests, I get the error message shown in the end of this post.

The github repository foens/gson-2.3-j2objc-test includes a script runJ2objcTests.sh that when executed downloads j2objc, translates all the sources and executes the tests. It should be easy to reproduce the below error:

JUnit version 4.10
...Oct 17 11:16:39 foenss-Mac.local Tests[16153] <Notice>: Loaded time zone names for "" in 53ms (53ms in ICU)
Oct 17 11:16:39 foenss-Mac.local Tests[16153] <Notice>: Loaded time zone names for "en_US" in 26ms (25ms in ICU)
E..E..E..E.Error: signal 11:
0   Tests                               0x000000010ef9c094 signalHandler + 39
1   libsystem_platform.dylib            0x00007fff8ac785aa _sigtramp + 26
2   ???                                 0x0000000000000000 0x0 + 0
3   Tests                               0x000000010ecbeab7 -[ComGoogleGsonStreamJsonReader doPeek] + 1415
4   Tests                               0x000000010ecbe1c4 -[ComGoogleGsonStreamJsonReader peek] + 68
5   Tests                               0x000000010ec7119d -[ComGoogleGsonGson fromJsonWithComGoogleGsonStreamJsonReader:withJavaLangReflectType:] + 109
6   Tests                               0x000000010ec70ec0 -[ComGoogleGsonGson fromJsonWithJavaIoReader:withJavaLangReflectType:] + 96
7   Tests                               0x000000010ec70d7b -[ComGoogleGsonGson fromJsonWithNSString:withJavaLangReflectType:] + 123
8   Tests                               0x000000010ec70c3d -[ComGoogleGsonGson fromJsonWithNSString:withIOSClass:] + 93
9   Tests                               0x000000010ec0953c -[ComGoogleGsonDefaultInetAddressTypeAdapterTest testInetAddressSerializationAndDeserialization] + 348
10  CoreFoundation                      0x00007fff8ccaf9ac __invoking___ + 140
11  CoreFoundation                      0x00007fff8ccaf814 -[NSInvocation invoke] + 308
12  Tests                               0x000000010ef985cf -[JavaLangReflectMethod invokeWithId:withNSObjectArray:] + 535
13  Tests                               0x000000010ebc415d -[JunitFrameworkTestCase runTest0WithJavaLangReflectMethod:] + 125
14  Tests                               0x000000010ebc3fc9 -[JunitFrameworkTestCase runTest] + 243
15  Tests                               0x000000010ebc3e3e -[JunitFrameworkTestCase runBare] + 47
16  Tests                               0x000000010eba5080 -[JunitFrameworkTestResult runProtectedWithJunitFrameworkTest:withJunitFrameworkProtectable:] + 88
17  Tests                               0x000000010eba4fe2 -[JunitFrameworkTestResult runWithJunitFrameworkTestCase:] + 108
18  Tests                               0x000000010eba6830 -[JunitFrameworkTestSuite runWithJunitFrameworkTestResult:] + 226
19  Tests                               0x000000010ebb356f -[OrgJunitRunnersParentRunner runChildrenWithOrgJunitRunnerNotificationRunNotifier:] + 293
20  Tests                               0x000000010ebb39b1 -[OrgJunitRunnersParentRunner runWithOrgJunitRunnerNotificationRunNotifier:] + 177
21  Tests                               0x000000010ebae464 -[OrgJunitRunnerJUnitCore runWithOrgJunitRunnerRunner:] + 217
22  Tests                               0x000000010ebae118 -[OrgJunitRunnerJUnitCore runMainWithOrgJunitInternalJUnitSystem:withNSStringArray:] + 879
23  Tests                               0x000000010ebadc81 +[OrgJunitRunnerJUnitCore runMainAndExitWithOrgJunitInternalJUnitSystem:withNSStringArray:] + 81
24  CoreFoundation                      0x00007fff8ccaf9ac __invoking___ + 140
25  CoreFoundation                      0x00007fff8ccaf814 -[NSInvocation invoke] + 308
26  Tests                               0x000000010ef985cf -[JavaLangReflectMethod invokeWithId:withNSObjectArray:] + 535
27  Tests                               0x000000010ef9c24c main + 386
28  libdyld.dylib                       0x00007fff851955fd start + 1

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:12

github_iconTop GitHub Comments

1reaction
Qatacommented, Feb 17, 2015

Has there been any progress on these issues?

0reactions
tomballcommented, Mar 25, 2015

Most tests pass now, and the ones that fail do so look to be for reasons unrelated to Gson. For example, several tests in DefaultDateTypeAdapterTest failed because one date string returns the UTC timezone, while the comparison string lists GMT+00:00, which is the same as UTC. You can file separate bugs for any failing tests if they bother you, but my recommendation is to use Gson now in your app and report any bugs it finds instead.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Detecting Real Faults in the Gson Library Through Search ...
The test cases fail in the same manner as the human-written cases, but not for the same reason. The failing tests pass strings...
Read more >
How to prevent Gson from expressing integers as floats
In my case, I have Strings and Integers within my JSON, but I do not have any doubles, so this doesn't pose a...
Read more >
Gson failure in end-to-end tests - Blog - Paweł Chudzik
Idea was to use a different serialization library in tests to be sure everything works as expected and nothing is lost (or unexpectedly...
Read more >
Gson - How to convert Java object to / from JSON - Mkyong.com
But i have to say that the File Reader and Writer need to be closed to work properly. When your create them inside...
Read more >
Gson User Guide - Google Sites
The Gson instance does not maintain any state while invoking Json operations. So, you are free to reuse the same object for multiple...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found