dragome-sdk icon indicating copy to clipboard operation
dragome-sdk copied to clipboard

Need full support java 8 closure

Open nicolaichuk opened this issue 8 years ago • 7 comments

Repost from https://github.com/xpenatan/gdx-dragome-backend/issues/25

We can read on this page https://github.com/dragome/dragome-sdk :

Java 8 ready. Build your pages using lambda expressions, default methods, streams

but I have this synthetic code:

====================================================

Supplier.java

public interface Supplier<T> {
	public T get();
}

ObjectPool.java

public class ObjectPool<T> {
	private final Supplier<T> supplier;

	private ObjectPool(final Supplier<T> supplier) {
		this.supplier = supplier;
	}

	public T get() {
		return supplier.get();
	}

	public static <T> ObjectPool<T> create(final Supplier<T> supplier) {
		return new ObjectPool<>(supplier);
	}

}

NodeOverlapCallback.java

public abstract class NodeOverlapCallback {
	public abstract void processNode();
}

MyNodeOverlapCallback.java

public class MyNodeOverlapCallback extends NodeOverlapCallback {
    @Override
    public void processNode() {
       // DO SOMETHING
    }
}

====================================================

Now if i do like this:

final ObjectPool<MyNodeOverlapCallback> myNodeCallbacks = ObjectPool.create(
    new Supplier<MyNodeOverlapCallback>() {
        @Override
        public MyNodeOverlapCallback get() {
            return new MyNodeOverlapCallback();
        }
    });
    
final MyNodeOverlapCallback myNodeCallback = myNodeCallbacks.get();
myNodeCallback.processNode();

All work well after dragome js codegen

But if i do like this:

final ObjectPool<MyNodeOverlapCallback> myNodeCallbacks = ObjectPool.create( 
    () -> new MyNodeOverlapCallback()
);

final MyNodeOverlapCallback myNodeCallback = myNodeCallbacks.get();
myNodeCallback.processNode();

Browser write javascript error that myNodeCallback is null;

But both implimentation work correct as java code.

nicolaichuk avatar Feb 27 '17 15:02 nicolaichuk

@nicolaichuk: Could you please create a test to reproduce the issue?

fpetrola avatar Mar 08 '17 17:03 fpetrola

Ok. I try do it when will have free time.

nicolaichuk avatar Mar 08 '17 17:03 nicolaichuk

@fpetrola, i add test suite for this issue.

nicolaichuk avatar Mar 30 '17 09:03 nicolaichuk

great, thanks!

fpetrola avatar Mar 30 '17 12:03 fpetrola

@fpetrola, when do you plane fix this issue?

nicolaichuk avatar Apr 28 '17 10:04 nicolaichuk

I think we could fix it for this milestone: https://github.com/dragome/dragome-sdk/milestone/5

fpetrola avatar May 08 '17 17:05 fpetrola

@fpetrola

ping...

nicolaichuk avatar Aug 18 '17 12:08 nicolaichuk