I do not believe that you can (at least not use object references for your "next" and "prev" pointers) for the reason you quote: Object addresses are officially opaque. Although we could access the bits of the link, the JVM can move objects in memory (for example, when managing memory), and although I do not immediately find the specification for it, I believe that it is allowed to handle this by changing it (literally every update goes field and such where the old link is used, giving it a new link). Therefore, if we converted the object reference to long (for example), and then XOR'd, that with another object reference converted to long , if any object is moved (how can they do this), as soon as any of them is XOR 'back and converted back to an object reference, it may already be invalid.
Therefore, I think you need to use something other than object references for pointers, such as indexes, in a large array of object references, after which I am sure that you have lost the memory advantage in the XOR linked list.
source share