javabridj

BridJ - Pointer.pointerToAddress(long peer) has been deprecated


There is an example called TaskbarListDemo.java in BridJ repo on GitHub. When I try to compile in Netbeans with the .jar library downloaded from Maven (version 0.7.0), the method Pointer.pointerToAddress(long peer) used in this example in line 100 is deprecated.

What is the correct method to use in that case? The docs doesn't explain anything about it. There are these options available (doesn't mark as deprecated):

public static <P> Pointer<P> pointerToAddress(long peer, PointerIO<P> io)
public static <P> Pointer<P> pointerToAddress(long peer, Class<P> targetClass, Pointer.Releaser releaser)
public static <P> Pointer<P> pointerToAddress(long peer, Type targetType, Pointer.Releaser releaser)
public static Pointer<?> pointerToAddress(long peer, long size, Pointer.Releaser releaser)
public static <P> Pointer<P> pointerToAddress(long peer, long size, PointerIO<P> io, Pointer.Releaser releaser)

Thanks a lot!


Solution

  • Disclaimer: I really don't know if this solution is beautiful, but it works and it solves the "deprecated" issue:

    Releaser nopReleaser = new Releaser() {
        @Override
        public void release(Pointer<?> pointer) {
            // NOP
        }
    };
    hwnd = Pointer.pointerToAddress(hwndVal, Integer.class, nopReleaser);