Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type java.lang.Long mapping #40

Closed
ebasley opened this issue Jan 29, 2013 · 4 comments
Closed

Type java.lang.Long mapping #40

ebasley opened this issue Jan 29, 2013 · 4 comments

Comments

@ebasley
Copy link

ebasley commented Jan 29, 2013

Take a class Test like this :

public class Test {
public static void test(java.lang.Long a){
System.out.println("test1");
}
}

Try this :

var java=require('java')
java.classpath.push('./test.jar');
var Test = java.import('Test');
Test.testSync(java.newInstanceSync("java.lang.Long", 1));

Gives :

Error: Could not find method "test(java.lang.Integer)" on class "class Test".
Possible matches:
public static void Test.test(java.lang.Long)

done it with last build.

Regards.

@joeferner
Copy link
Owner

Just published a new version (v0.2.0) which keeps longs and long objects.

@ebasley
Copy link
Author

ebasley commented Feb 1, 2013

Thank you,

but when using v 0.2.0 with a Long as parameter, we have this message: "javaToV8: unhandled type: 0x003"

@ebasley
Copy link
Author

ebasley commented Feb 1, 2013

I spent this morning using the new version, and I'm afraid this is not the good solution because now we have to cast all long java objects to integer (intValue()) to use them in javascript, it's a long and dangerous task =>
java.newInstanceSync('java.lang.Long', 1) +1 => '11'
and at the end I had to uncomment your patch !!
I think it's very important to convert transparantly Long to Number, but then how to find the rigth method from JS to java when the last is using long parameters ?
Can't we image to explicitly cast, with something like Number#toLong() ?
Regards.

@joeferner
Copy link
Owner

OK, I think I came up with a better solution. I've published v0.2.1 with the fix. I've also updated the readme with an example and description of how to handle longs.

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

No branches or pull requests

2 participants