Giter Site home page Giter Site logo

Comments (9)

nmorel avatar nmorel commented on July 29, 2024

The only available way is to use a mixin annotation on java.lang.Object.

Though, I should be able to add a global configuration in AbstractConfiguration.

from gwt-jackson.

butlnor avatar butlnor commented on July 29, 2024

Thanks.

I tried with just Object, but then I got too many errors and warnings, which otherwise don't happen (if I annotate some tens of classes, which I use and don't want to use their setters and getters). We have many really complex classes, which were initially not meant for JSON, so it's likely their fault. It's my responsibility to fix them.

However, stack overflow happens, if an object has itself as a field, like the linked lists or trees do have.

from gwt-jackson.

butlnor avatar butlnor commented on July 29, 2024

I meant stack overflow while GWT is rebinding at the startup, not at runtime.

Caused by: java.lang.StackOverflowError: null
at com.google.gwt.dev.util.collect.HashMap.keyHashCode(HashMap.java:640)
at com.google.gwt.dev.util.collect.HashMap.getKeyIndex(HashMap.java:767)
at com.google.gwt.dev.util.collect.HashMap.findKey(HashMap.java:696)
at com.google.gwt.dev.util.collect.HashMap.get(HashMap.java:463)
at com.google.gwt.dev.javac.typemodel.JPackage.findTypeImpl(JPackage.java:108)
at com.google.gwt.dev.javac.typemodel.JPackage.findType(JPackage.java:47)
at com.google.gwt.dev.javac.typemodel.JPackage.findType(JPackage.java:42)
at com.google.gwt.dev.javac.typemodel.TypeOracle.findType(TypeOracle.java:387)
at com.google.gwt.dev.javac.typemodel.TypeOracle.findType(TypeOracle.java:68)
at com.google.gwt.dev.javac.StandardGeneratorContext.tryCreate(StandardGeneratorContext.java:830)
at com.github.nmorel.gwtjackson.rebind.AbstractCreator.getPrintWriter(AbstractCreator.java:93)
at com.github.nmorel.gwtjackson.rebind.AbstractBeanJsonCreator.create(AbstractBeanJsonCreator.java:156)
at com.github.nmorel.gwtjackson.rebind.AbstractCreator.getJsonSerializerFromType(AbstractCreator.java:244)
at com.github.nmorel.gwtjackson.rebind.AbstractCreator.getJsonSerializerFromType(AbstractCreator.java:258)
at com.github.nmorel.gwtjackson.rebind.AbstractCreator.getJsonSerializerFromType(AbstractCreator.java:258)
at com.github.nmorel.gwtjackson.rebind.AbstractCreator.getJsonSerializerFromType(AbstractCreator.java:258)
...

from gwt-jackson.

nmorel avatar nmorel commented on July 29, 2024

I don't understand how you get a stackoverflow. Do you have an example ?

You also changed the auto detection for field to detect more than public fields ?

from gwt-jackson.

butlnor avatar butlnor commented on July 29, 2024

I wrote this:

@JsonAutoDetect(
    fieldVisibility = Visibility.ANY, 
    creatorVisibility = Visibility.ANY, 
    getterVisibility = Visibility.NONE, 
    setterVisibility = Visibility.NONE, 
    isGetterVisibility = Visibility.NONE)
private static class FieldsOnlyMixin {
}

@Override
protected void configure() {
    addMixInAnnotations(Object.class, FieldsOnlyMixin.class);
}

from gwt-jackson.

butlnor avatar butlnor commented on July 29, 2024

However, regarding the stack overflow, it's strange. I made a copy of the problematic class, to find which field or method causes problems, but the copy worked. So it seems it has something to do with the type hierarchy, as many other classes extend this one. Will try to analyze and will inform you soon.

The class and it's hierarchy is too complex to send it as an example. It has one String id field, and parent of the same type as the object, but many methods, which start with "get" or "is".

Thanks for all the info.

from gwt-jackson.

butlnor avatar butlnor commented on July 29, 2024

I found a reason for stack overflow. It happens with parameterized classes that use themselves as a parameter, like:

interface IdentifiableEntity<T extends IdentifiableEntity<T>>

from gwt-jackson.

nmorel avatar nmorel commented on July 29, 2024

Thanks, I'll look into it!

from gwt-jackson.

nmorel avatar nmorel commented on July 29, 2024

You can now configure the default behaviour via a global configuration. Watch this wiki page to find how to add your custom configuration.

from gwt-jackson.

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.