libgdx icon indicating copy to clipboard operation
libgdx copied to clipboard

Whether to consider supporting serialization, as it is required for our project

Open kevinkwok326 opened this issue 3 years ago • 4 comments

Now we modify the open source and compile it ourself. Our modified file list as follows: libgdx :
gdx/utils/Array.java gdx/utils/Predicate.java

gdx-ai: gdx/ai/btree/BehaviorTree.java gdx/ai/btree/BranchTask.java gdx/ai/btree/Decorator.java gdx/ai/btree/LeafTask.java gdx/ai/btree/LoopDecorator.java gdx/ai/btree/SingleRunningChildBranch.java gdx/ai/btree/Task.java

Please select the affected platforms

  • [ ] Linux

kevinkwok326 avatar Jul 21 '22 03:07 kevinkwok326

You're fully allowed to modify libGDX under the terms of its license. You'll have to be more specific for what you mean by "supporting serialization," because libGDX does support serialization via JSON or XML, using classes present in libGDX. We don't use java.io.Serializable because its use is generally discouraged by Java experts, like Joshua Bloch: https://stackoverflow.com/a/53889695/786740

tommyettinger avatar Jul 21 '22 05:07 tommyettinger

Yes,Now our project is using java.io.Serializable. When I tried to use com.badlogic.gdx.utils.Json to serialize the object com.badlogic.gdx.ai.btree.BehaviorTree, StackOverflowError is occurred , maybe there is a circular dependency

kevinkwok326 avatar Jul 21 '22 08:07 kevinkwok326

I'm guessing something needs to be marked as transient to avoid a circular dependency, I just don't know what. Also, I can't merge PRs or commit to gdx-ai any more, and I don't know who can (and who cares about gdx-ai at all these days). Comments in gdx-ai suggest approaches that use Kryo ( https://github.com/EsotericSoftware/kryo ) for serialization.

tommyettinger avatar Jul 21 '22 08:07 tommyettinger

I'm guessing something needs to be marked as transient to avoid a circular dependency, I just don't know what. Also, I can't merge PRs or commit to gdx-ai any more, and I don't know who can (and who cares about gdx-ai at all these days). Comments in gdx-ai suggest approaches that use Kryo ( https://github.com/EsotericSoftware/kryo ) for serialization.

Thanks, i will try to use kryo

kevinkwok326 avatar Jul 21 '22 09:07 kevinkwok326