Skip to content

Conversation

@liebo
Copy link

@liebo liebo commented Jan 16, 2014

ExportClosure can not return any exportable instance, dig into the source code, find it may be a typo.

ExportClosure can not return any exportable instance, dig into the source code, find it may be a typo.
@manolo
Copy link
Owner

manolo commented Jan 16, 2014

Thanks for the contribution, I have to dig into the issue to have a clearer idea about the problem.
Maybe a test for this issue, considering both exportclosures and other exportable cases?

@jcogilvie
Copy link

I found that this fix still didn't work for me; I had to return r (and not r.g) for my use case.

Basically the simple version of my test (which is contained in a bunch of domain-specific code that I can't share) is as follows:

@Export
public class SomeExportedObject {
    public string someField;
}

@Export
@ExportClosure
public interface IGetter {
     SomeExportedObject get(String arg);
}

@Export
public class GetterCaller {
    private IGetter getter;
    public GetterCaller(IGetter getter){
        this.getter = getter;
    }

    public void callGet(String arg){
        SomeExportedObject obj = getter.get(arg);
        String foo = obj.someField;  // this line is where the error happens 
    }
}

js code:

var mock = function(arg){
    var ret = new com.mypackage.SomeExportedObject();
    ret.someField = arg;
    return ret;
}
var getterCaller = new com.mypackage.GetterCaller();
getterCaller.callGet('hello world!');

With the version in @manolo repository, this yields (in chrome dev console):

obj is not defined

With the version in @liebo repository, instead, obj.someField exists, but is empty.

With the version in @svtdragon repository, obj.someField == 'hello world'.

(Worth noting: r.g has the right fields for a SomeExportedObject, but they are empty/default. r.g.g has the correct values-- r.g.g.someField == 'hello world!')

@liebo
Copy link
Author

liebo commented Sep 28, 2014

my code is something like this:
@export
@ExportClosure
public interface IGetter {
void doSomething(Expotable someExportableObject);
}
in javascript implemention of doSomething:r.g instead of r returns the correct wrapped exportable object.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants