Code Monkey home page Code Monkey logo

Comments (3)

kostaskougios avatar kostaskougios commented on July 25, 2024

I can't really tell, never tried it. The library uses reflection to find all field members of a class. Then it recursively deep clones them. How do you get a reference to a native object and where do you store it? Is that reference a specific java type?

from cloning.

JLLeitschuh avatar JLLeitschuh commented on July 25, 2024

This is an example of what I want to clone:
https://github.com/bytedeco/javacpp-presets/blob/master/opencv/src/main/java/org/bytedeco/javacpp/opencv_core.java
This object extends Pointer defined here:
https://github.com/bytedeco/javacpp/blob/master/src/main/java/org/bytedeco/javacpp/Pointer.java
This seems to keep fields with references to the memory addresses somewhere in the object. I suppose if you clone it this object will still be pointing to the same object so this won't work.

from cloning.

kostaskougios avatar kostaskougios commented on July 25, 2024

They seem to use longs to point to the mem address as you say. So cloner will just copy the long number and point to the same address. But you can impl IFastCloner for Pointer.class and register that with cloner and provide your own cloning impl for it - if you have a way to copy the memory those longs point to.

from cloning.

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.