Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Yasson » Marshalling error with nested class(Marshalling error on nested class with Optional attribute)
Marshalling error with nested class [message #1763695] Thu, 18 May 2017 16:04 Go to next message
Jean-François James is currently offline Jean-François JamesFriend
Messages: 5
Registered: May 2017
Junior Member
Hi, according to the specification (chapters 3.7.2 and 3.7.3) binding of nested classes, whether static or not, should work.
However, it doesn't work using Yasson 1.0.0-M2 with a nested class containing an Optional<LocalDate> attribute (see attached file).
Some precisions: declaring the nested Character class static doesn't change things, externalizing the Character class in a dedicated Java file make things work. Do I miss ST or shall I open a bug?
Re: Marshalling error with nested class [message #1763700 is a reply to message #1763695] Thu, 18 May 2017 18:10 Go to previous messageGo to next message
Ehsan Zaery Moghaddam is currently offline Ehsan Zaery MoghaddamFriend
Messages: 8
Registered: December 2016
Junior Member

Hi Jean-François James

It's not related to optional property, because it happens even if you remove that field. I think it's the same issue as mentioned in the following thread. Its because of the access level of your inner class, which based on spec should be public or protected.

https://www.eclipse.org/forums/index.php/t/1083501/
Re: Marshalling error with nested class [message #1763747 is a reply to message #1763700] Fri, 19 May 2017 09:32 Go to previous messageGo to next message
Jean-François James is currently offline Jean-François JamesFriend
Messages: 5
Registered: May 2017
Junior Member
Hi Hehsan, thank you for your answer, I've done additional tests and you're right. It works if the nested class is static and explictely declared public or protected. But there is still an issue if the class is not static. The reference to the enclosing class is implictely passed as a constructor parameter.
Hence, at runtime, Yasson cannot find a default noargs constructor and generates an error: " Can't create instance of a class: class lab.jefrajames.jsonb.NestedClassTest$Character, No default constructor found".
This Java behaviour is perfectly explained in this article.
Please find attached a modified version of my test case which illustrates that. Constructors of the inner class are displayed.
Re: Marshalling error with nested class [message #1763758 is a reply to message #1763747] Fri, 19 May 2017 10:24 Go to previous messageGo to next message
Ehsan Zaery Moghaddam is currently offline Ehsan Zaery MoghaddamFriend
Messages: 8
Registered: December 2016
Junior Member

Hmmm. That's a good point. I'm not sure if it could be considered as a bug. Maybe we need to update the spec or clarify the way it should be interpreted. I think Dmitry may already have an answer for this.

Regards
Ehsan
Re: Marshalling error with nested class [message #1763767 is a reply to message #1763758] Fri, 19 May 2017 11:38 Go to previous message
Jean-François James is currently offline Jean-François JamesFriend
Messages: 5
Registered: May 2017
Junior Member
I agree, it is not "a bug". Maybe it deserves a clarification in the specification ...

Regards.
JF
Previous Topic:How thread safe is a Jsonb instance?
Goto Forum:
  


Current Time: Tue Nov 20 00:29:28 GMT 2018

Powered by FUDForum. Page generated in 0.02203 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top