Coder Social home page Coder Social logo

In Java 7, the Throwable type contains java.util.Collections$UnmodifiableRandomAccessList, which does not allow a null constructor arg about json-io HOT 4 CLOSED

GoogleCodeExporter avatar GoogleCodeExporter commented on May 27, 2024
In Java 7, the Throwable type contains java.util.Collections$UnmodifiableRandomAccessList, which does not allow a null constructor arg

from json-io.

Comments (4)

GoogleCodeExporter avatar GoogleCodeExporter commented on May 27, 2024
Here's a modified JsonReader that dumbly handles this particular case by 
creating a new ArrayList when it detects a constructor arg of type List, along 
with accompanying test TestJsonReaderWriter.testException. Several other common 
java types could be handled like this, although it's sort of plugging holes in 
the dike.

Original comment by [email protected] on 23 Sep 2013 at 9:10

Attachments:

from json-io.

GoogleCodeExporter avatar GoogleCodeExporter commented on May 27, 2024
I will review and likely add / update with your changes.  I understand what you 
mean by "like plugging holes in the dike."  Java needs a C-style malloc() for 
objects, at least when you are performing serialization.   I will likely add 
some other "popular" classes (Collections, Map, String, Date, etc.) the usual 
suspects that end up as 'fields' on data transfer (model) classes.  Good find 
and thanks for providing a solution / test.

Original comment by [email protected] on 24 Sep 2013 at 3:07

  • Changed state: Accepted

from json-io.

GoogleCodeExporter avatar GoogleCodeExporter commented on May 27, 2024
Hi

I also have this issue on a simple pojo with JDK7

I have a simple bean with string name, int amount, int total and boolean 
accepted with a default empty constructor and getter and setter for each 
property.

I can serialise this type to a JSON String fine but when I try to deserialise I 
get the exact same exception as Erick.

I am trying to use the library in a REST service so when deserialising there 
can be an array of types needed by the java REST service and this library 
seemed just what I was looking for.

Any resolution to this would be greatly appreciated.

Regards

Steve


Original comment by [email protected] on 26 Sep 2013 at 10:52

from json-io.

GoogleCodeExporter avatar GoogleCodeExporter commented on May 27, 2024
This issue has been addressed.  The code now tries the default constructor 
(public, private, protected, or package friendly).  If that does not work (or 
there is no constructor that takes no arguments, or the no-arg constructor 
throws an exception), then it tries construction with defaults for primitivies 
and null for non-primities, for all constructors.  If that does not work, it 
tries defaults for primitives, and non-null values for a wide range of common 
classes (Collection, String, Date, Timezone, etc).  A new test case has been 
added for this.

Original comment by [email protected] on 27 Sep 2013 at 11:00

  • Changed state: Done

from json-io.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.