Re: [go-nuts] Re: x/mobile: Samples for reverse binding in gomobile

2020-02-04 Thread psyhonut
Hello, Jay.
Can I ask you some questions about gomobile reverse binding in private 
messaging?

On Thursday, September 12, 2019 at 3:23:24 PM UTC+3, Jay Sharma wrote:
>
> Hello Elias,
>
> *First of all, Thank you very much for help. :)*
>
>
> *After I remove the static from function it worked well. *
>
>
> *Thanks*
>
> On Thursday, September 12, 2019 at 4:31:05 PM UTC+5:30, Elias Naur wrote:
>>
>> On Thu Sep 12, 2019 at 2:35 AM Jay Sharma wrote: 
>> > 
>> > *Hello Elias,* 
>> > 
>> > *Following is my java file: * 
>> > 
>> > 
>> > package reversebinding; 
>> > 
>> > public class RBinding { 
>> >  public static String getStringFromJava() { 
>> > return "Hello from java !!"; 
>> > } 
>> > } 
>> > 
>> > 
>> > 
>>
>> Your Java method is declared as "static"; static methods are exported as 
>> regular functions in reverse bindings. Remove "static" and you might have 
>> better luck calling it. 
>>
>> > 
>> > *I tried the following in my go file : * 
>> > 
>> > 
>> > 
>> > import "Java/reversebinding/RBinding" 
>> > 
>> > 
>> > // creating object like this: 
>> > 
>> > javaObj := JavaAPI.New() 
>> > javaObj.GetStringFromJava() 
>> > 
>> > *But while building using the gomobile it is giving following error: * 
>> > JavaObj.GetStringFromJava undefined (type Java.Reversebinding_JavaAPI 
>> has 
>> > no field or method GetStringFromJava) 
>> > undefined: val 
>> > 
>> > 
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/c35486d8-c4e5-4223-9a96-9b29c98c4907%40googlegroups.com.


Re: [go-nuts] Re: x/mobile: Samples for reverse binding in gomobile

2019-09-12 Thread Jay Sharma
Hello Elias,

*First of all, Thank you very much for help. :)*


*After I remove the static from function it worked well. *


*Thanks*

On Thursday, September 12, 2019 at 4:31:05 PM UTC+5:30, Elias Naur wrote:
>
> On Thu Sep 12, 2019 at 2:35 AM Jay Sharma wrote: 
> > 
> > *Hello Elias,* 
> > 
> > *Following is my java file: * 
> > 
> > 
> > package reversebinding; 
> > 
> > public class RBinding { 
> >  public static String getStringFromJava() { 
> > return "Hello from java !!"; 
> > } 
> > } 
> > 
> > 
> > 
>
> Your Java method is declared as "static"; static methods are exported as 
> regular functions in reverse bindings. Remove "static" and you might have 
> better luck calling it. 
>
> > 
> > *I tried the following in my go file : * 
> > 
> > 
> > 
> > import "Java/reversebinding/RBinding" 
> > 
> > 
> > // creating object like this: 
> > 
> > javaObj := JavaAPI.New() 
> > javaObj.GetStringFromJava() 
> > 
> > *But while building using the gomobile it is giving following error: * 
> > JavaObj.GetStringFromJava undefined (type Java.Reversebinding_JavaAPI 
> has 
> > no field or method GetStringFromJava) 
> > undefined: val 
> > 
> > 
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/a6fec9a3-928c-4539-ba95-ac9dd453a7c0%40googlegroups.com.


Re: [go-nuts] Re: x/mobile: Samples for reverse binding in gomobile

2019-09-12 Thread Elias Naur
On Thu Sep 12, 2019 at 2:35 AM Jay Sharma wrote:
> 
> *Hello Elias,*
> 
> *Following is my java file: *
> 
> 
> package reversebinding;
> 
> public class RBinding {
>  public static String getStringFromJava() {
> return "Hello from java !!";
> }
> }
> 
> 
> 

Your Java method is declared as "static"; static methods are exported as
regular functions in reverse bindings. Remove "static" and you might have
better luck calling it.

> 
> *I tried the following in my go file : *
> 
> 
> 
> import "Java/reversebinding/RBinding"
> 
> 
> // creating object like this: 
> 
> javaObj := JavaAPI.New()
> javaObj.GetStringFromJava()
> 
> *But while building using the gomobile it is giving following error: *
> JavaObj.GetStringFromJava undefined (type Java.Reversebinding_JavaAPI has 
> no field or method GetStringFromJava)
> undefined: val
> 
> 

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/BWXZ06VB2ULU.2HUEH0Y162LFV%40toolbox.


Re: [go-nuts] Re: x/mobile: Samples for reverse binding in gomobile

2019-09-12 Thread Jay Sharma

*Hello Elias,*

*Following is my java file: *


package reversebinding;

public class RBinding {
 public static String getStringFromJava() {
return "Hello from java !!";
}
}




*I tried the following in my go file : *



import "Java/reversebinding/RBinding"


// creating object like this: 

javaObj := JavaAPI.New()
javaObj.GetStringFromJava()

*But while building using the gomobile it is giving following error: *
JavaObj.GetStringFromJava undefined (type Java.Reversebinding_JavaAPI has 
no field or method GetStringFromJava)
undefined: val


*If I call using class name: it is working fine. but with object it is not 
working.*


*Can  you please provide your suggestion ? *

*Thanks.*


On Thursday, September 12, 2019 at 1:14:21 PM UTC+5:30, Jay Sharma wrote:
>
> Hello Elias,
>
> Following are the lines from proposals:
> Creating new Java instances 
>
> To create a new instance of a Java class, use the New function defined in 
> the class package. For example:
>
> import ( 
> "Java/java/lang/Object" "Java/java/lang"
> ) 
>
> func NewObject() lang.Object { 
> return Object.New() 
> }
>
> *How can I modify it for my class ? *
>
> I know, It is too much to ask. I got confused. 
>
> *Thanks for your help.*
>
>  
>
>
> On Wednesday, September 11, 2019 at 9:41:13 PM UTC+5:30, Elias Naur wrote:
>>
>> On Wed Sep 11, 2019 at 7:20 AM Jay Sharma wrote: 
>> > 
>> > 
>> > *Now, I want to create object of this class in go and want to call 
>> method 
>> > using that object from go. * 
>> > 
>> > I was checking your proposal (https://github.com/golang/go/issues/16876) 
>>
>> > but could not able to make it. :( 
>>
>> The proposal suggests calling the generated New method on the object. 
>> Did you try that? If so, what went wrong? 
>>
>> -- elias 
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/36a1de11-0a4b-478c-94b2-a01d8f2f4fc4%40googlegroups.com.


Re: [go-nuts] Re: x/mobile: Samples for reverse binding in gomobile

2019-09-12 Thread Jay Sharma
Hello Elias,

Following are the lines from proposals:
Creating new Java instances 

To create a new instance of a Java class, use the New function defined in 
the class package. For example:

import ( 
"Java/java/lang/Object" "Java/java/lang"
) 

func NewObject() lang.Object { 
return Object.New() 
}

*How can I modify it for my class ? *

I know, It is too much to ask. I got confused. 

*Thanks for your help.*

 


On Wednesday, September 11, 2019 at 9:41:13 PM UTC+5:30, Elias Naur wrote:
>
> On Wed Sep 11, 2019 at 7:20 AM Jay Sharma wrote: 
> > 
> > 
> > *Now, I want to create object of this class in go and want to call 
> method 
> > using that object from go. * 
> > 
> > I was checking your proposal (https://github.com/golang/go/issues/16876) 
>
> > but could not able to make it. :( 
>
> The proposal suggests calling the generated New method on the object. 
> Did you try that? If so, what went wrong? 
>
> -- elias 
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/3de11f3c-62e5-4136-bf34-29e703085b98%40googlegroups.com.


Re: [go-nuts] Re: x/mobile: Samples for reverse binding in gomobile

2019-09-11 Thread Elias Naur
On Wed Sep 11, 2019 at 7:20 AM Jay Sharma wrote:
> 
> 
> *Now, I want to create object of this class in go and want to call method 
> using that object from go. *
> 
> I was checking your proposal (https://github.com/golang/go/issues/16876) 
> but could not able to make it. :(

The proposal suggests calling the generated New method on the object.
Did you try that? If so, what went wrong?

-- elias

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/BWXAZ4Z6L5WG.6AV43I4ZQQCC%40testmac.


Re: [go-nuts] Re: x/mobile: Samples for reverse binding in gomobile

2019-09-11 Thread Jay Sharma
*Thank you very much Elias : with your suggestion it is working fine.*

Just last query:

Currently, I called *static method* of my java class: 

package reversebinding; 

public class RBinding { 
  public static String getStringFromJava() { 
  return "Hello from java !!"; 
 } 
 } 


*Now, I want to create object of this class in go and want to call method 
using that object from go. *

I was checking your proposal (https://github.com/golang/go/issues/16876) 
but could not able to make it. :(
Can you please help me , how to do that?

*Thanks*.


On Wednesday, September 11, 2019 at 4:36:20 PM UTC+5:30, Elias Naur wrote:
>
> On Wed Sep 11, 2019 at 3:51 AM Jay Sharma wrote: 
> > 
> > 
> > I have one doubt when we build using gomobile in that I am giving the 
> > classpath to my .class java file. 
> > *Will it be included in .aar or I have to include that .class file along 
> > with .aar in my android application. * 
> > 
>
> The class file is not automatically included, that wasn't clear from my 
> earlier 
> reply. Please include the class file in your project and try my suggestion 
> to 
> call your code from Java. 
>
> -- elias 
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/a486225f-f2f9-49d3-856c-11495c8dce78%40googlegroups.com.


Re: [go-nuts] Re: x/mobile: Samples for reverse binding in gomobile

2019-09-11 Thread Elias Naur
On Wed Sep 11, 2019 at 3:51 AM Jay Sharma wrote:
> 
> 
> I have one doubt when we build using gomobile in that I am giving the 
> classpath to my .class java file. 
> *Will it be included in .aar or I have to include that .class file along 
> with .aar in my android application. *
> 

The class file is not automatically included, that wasn't clear from my earlier
reply. Please include the class file in your project and try my suggestion to
call your code from Java.

-- elias

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/BWX4HNJBFFHC.1LTPFNFL2HB48%40themachine.


Re: [go-nuts] Re: x/mobile: Samples for reverse binding in gomobile

2019-09-11 Thread Jay Sharma
Hi Elias,

The provided logs: 
2019-09-10 16:36:54.199 9400-9430/com.sample  E/GoLog: 2019/09/10 11:06:54 
test.go:134: testFunction [Test]
2019-09-10 16:36:54.199 9400-9430/com.sample  E/GoLog: 2019/09/10 11:06:54 
test.go:136: [Test] Now going to call a java system function 
(System.CurrentTimeMillis())..
2019-09-10 16:36:54.200 9400-9434/com.sample  E/GoLog: 2019/09/10 11:06:54 
test.go:138: [Test] Called java function return value is:  1568113614199

*In this you can see I am able to call System.CurrentTimeMillis() and 
printing in logs.*

*This is the next line of code where I am trying to call my own class java 
function from go: *
2019-09-10 16:36:54.200 9400-9434/com.sample  E/GoLog: 2019/09/10 11:06:54 
test.go:140: [Test] Now going to call my java function

After this log I am actually calling like this: 
*RBinding.getStringFromJava() and it is crashing. *


I have one doubt when we build using gomobile in that I am giving the 
classpath to my .class java file. 
*Will it be included in .aar or I have to include that .class file along 
with .aar in my android application. *

Thanks.


On Tuesday, September 10, 2019 at 8:55:47 PM UTC+5:30, Elias Naur wrote:
>
> On Tue Sep 10, 2019 at 4:26 AM Jay Sharma wrote: 
> > --=_Part_1258_983331168.1568114760099 
> > Content-Type: text/plain; charset="UTF-8" 
> > 
> > Hello @elias, 
> > 
> > I tried the following: 
> > 
> > 1. Created a java class : 
> > 
> > package reversebinding; 
> > 
> > public class RBinding { 
> >  public static String getStringFromJava() { 
> > return "Hello from java !!"; 
> > } 
> > } 
> > 
> > 2. Generated the .class file for this file. 
> > 
> > 3. Generated the android binding using gomobile tool and used 
> > -classpath="Path to my .class file" 
> > 
> > 4. Binding is generated successfully. 
> > 
> > *But when I used that generated (.aar) file in my android app and tried 
> to 
> > trigger the api it is crashing; * 
> > 
> > 2019-09-10 16:36:54.199 9400-9430/com.sample  E/GoLog: 2019/09/10 
> 11:06:54 
> > test.go:134: testFunction [Test] 
> > 2019-09-10 16:36:54.199 9400-9430/com.sample  E/GoLog: 2019/09/10 
> 11:06:54 
> > test.go:136: [Test] Now going to call a java system function 
> > (System.CurrentTimeMillis()). 
> > 2019-09-10 16:36:54.200 9400-9434/com.sample  E/GoLog: 2019/09/10 
> 11:06:54 
> > test.go:138: [Test] Called java function return value is:  1568113614199 
> > 2019-09-10 16:36:54.200 9400-9434/com.sample  E/GoLog: 2019/09/10 
> 11:06:54 
> > test.go:140: [Test] Now going to call my java function. 
> > 2019-09-10 16:36:54.203 9400-0/com.sample  E/Go: panic: runtime error: 
> > invalid memory address or nil pointer dereference 
> > 2019-09-10 16:36:54.203 9400-0/com.sample  E/Go: [signal SIGSEGV: 
> > segmentation violation code=0x1 addr=0x0 pc=0x7568010708] 
> > 2019-09-10 16:36:54.203 9400-0/com.sample  E/Go: goroutine 17 [running, 
> > locked to thread]: 
> > 2019-09-10 16:36:54.203 9400-0/com.sample  E/Go: 
> > test.testFunction(0x400738) 
> > 2019-09-10 16:36:54.203 9400-0/com.sample  E/Go: 
> > /home/test/2019/test/test.go:141 +0x190 
> > 2019-09-10 16:36:54.203 9400-0/com.sample  E/Go: 
> > main.proxytest__testFunction(...) 
> > 2019-09-10 16:36:54.203 9400-0/com.sample com.sample E/Go: 
> > /tmp/gomobile-work-071468276/src/gobind/go_testmain.go:199 
> > 2019-09-10 16:36:54.203 9400-0/com.sample  E/Go: 
> > 
> main._cgoexpwrap_5427a26f9204_proxytest__testFunction(0x8020080280200802) 
> > 2019-09-10 16:36:54.203 9400-0/com.sample  E/Go: _cgo_gotypes.go:606 
> > +0x1c 
> > 2019-09-10 16:36:54.204 9400-9423/com.sample  A/libc: Fatal signal 6 
> > (SIGABRT), code -6 in tid 9423 (Thread-2) 
> > 
>
> The error is arguably not very helpful. Are you sure there is not another 
> error 
> before the nil pointer exception? In any case, did you ensure that the 
> .class 
> is included in the Android apk? An easy check is to try to call your 
> method 
> from Java before trying from Go. 
>
> -- elias 
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/a5d988ed-b057-49e5-b419-6a7302e7bdd2%40googlegroups.com.


Re: [go-nuts] Re: x/mobile: Samples for reverse binding in gomobile

2019-09-10 Thread Elias Naur
On Tue Sep 10, 2019 at 4:26 AM Jay Sharma wrote:
> --=_Part_1258_983331168.1568114760099
> Content-Type: text/plain; charset="UTF-8"
> 
> Hello @elias,
> 
> I tried the following:
> 
> 1. Created a java class : 
> 
> package reversebinding;
> 
> public class RBinding {
>  public static String getStringFromJava() {
> return "Hello from java !!";
> }
> }
> 
> 2. Generated the .class file for this file. 
> 
> 3. Generated the android binding using gomobile tool and used 
> -classpath="Path to my .class file"
> 
> 4. Binding is generated successfully. 
> 
> *But when I used that generated (.aar) file in my android app and tried to 
> trigger the api it is crashing; *
> 
> 2019-09-10 16:36:54.199 9400-9430/com.sample  E/GoLog: 2019/09/10 11:06:54 
> test.go:134: testFunction [Test]
> 2019-09-10 16:36:54.199 9400-9430/com.sample  E/GoLog: 2019/09/10 11:06:54 
> test.go:136: [Test] Now going to call a java system function 
> (System.CurrentTimeMillis()).
> 2019-09-10 16:36:54.200 9400-9434/com.sample  E/GoLog: 2019/09/10 11:06:54 
> test.go:138: [Test] Called java function return value is:  1568113614199
> 2019-09-10 16:36:54.200 9400-9434/com.sample  E/GoLog: 2019/09/10 11:06:54 
> test.go:140: [Test] Now going to call my java function.
> 2019-09-10 16:36:54.203 9400-0/com.sample  E/Go: panic: runtime error: 
> invalid memory address or nil pointer dereference
> 2019-09-10 16:36:54.203 9400-0/com.sample  E/Go: [signal SIGSEGV: 
> segmentation violation code=0x1 addr=0x0 pc=0x7568010708]
> 2019-09-10 16:36:54.203 9400-0/com.sample  E/Go: goroutine 17 [running, 
> locked to thread]:
> 2019-09-10 16:36:54.203 9400-0/com.sample  E/Go: 
> test.testFunction(0x400738)
> 2019-09-10 16:36:54.203 9400-0/com.sample  E/Go: 
> /home/test/2019/test/test.go:141 +0x190
> 2019-09-10 16:36:54.203 9400-0/com.sample  E/Go: 
> main.proxytest__testFunction(...)
> 2019-09-10 16:36:54.203 9400-0/com.sample com.sample E/Go: 
> /tmp/gomobile-work-071468276/src/gobind/go_testmain.go:199
> 2019-09-10 16:36:54.203 9400-0/com.sample  E/Go: 
> main._cgoexpwrap_5427a26f9204_proxytest__testFunction(0x8020080280200802)
> 2019-09-10 16:36:54.203 9400-0/com.sample  E/Go: _cgo_gotypes.go:606 
> +0x1c
> 2019-09-10 16:36:54.204 9400-9423/com.sample  A/libc: Fatal signal 6 
> (SIGABRT), code -6 in tid 9423 (Thread-2)
> 

The error is arguably not very helpful. Are you sure there is not another error
before the nil pointer exception? In any case, did you ensure that the .class
is included in the Android apk? An easy check is to try to call your method
from Java before trying from Go.

-- elias

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/BWWFDRSGTVCY.3RJOHGGDYAVUF%40toolbox.


Re: [go-nuts] Re: x/mobile: Samples for reverse binding in gomobile

2019-09-10 Thread Jay Sharma
Just one more information: 

I am calling from my go code like this: 
RBinding.GetStringFromJava()

On Tuesday, September 10, 2019 at 4:56:00 PM UTC+5:30, Jay Sharma wrote:
>
> Hello @elias,
>
> I tried the following:
>
> 1. Created a java class : 
>
> package reversebinding;
>
> public class RBinding {
>  public static String getStringFromJava() {
> return "Hello from java !!";
> }
> }
>
> 2. Generated the .class file for this file. 
>
> 3. Generated the android binding using gomobile tool and used 
> -classpath="Path to my .class file"
>
> 4. Binding is generated successfully. 
>
> *But when I used that generated (.aar) file in my android app and tried to 
> trigger the api it is crashing; *
>
> 2019-09-10 16:36:54.199 9400-9430/com.sample  E/GoLog: 2019/09/10 11:06:54 
> test.go:134: testFunction [Test]
> 2019-09-10 16:36:54.199 9400-9430/com.sample  E/GoLog: 2019/09/10 11:06:54 
> test.go:136: [Test] Now going to call a java system function 
> (System.CurrentTimeMillis()).
> 2019-09-10 16:36:54.200 9400-9434/com.sample  E/GoLog: 2019/09/10 11:06:54 
> test.go:138: [Test] Called java function return value is:  1568113614199
> 2019-09-10 16:36:54.200 9400-9434/com.sample  E/GoLog: 2019/09/10 11:06:54 
> test.go:140: [Test] Now going to call my java function.
> 2019-09-10 16:36:54.203 9400-0/com.sample  E/Go: panic: runtime error: 
> invalid memory address or nil pointer dereference
> 2019-09-10 16:36:54.203 9400-0/com.sample  E/Go: [signal SIGSEGV: 
> segmentation violation code=0x1 addr=0x0 pc=0x7568010708]
> 2019-09-10 16:36:54.203 9400-0/com.sample  E/Go: goroutine 17 [running, 
> locked to thread]:
> 2019-09-10 16:36:54.203 9400-0/com.sample  E/Go: 
> test.testFunction(0x400738)
> 2019-09-10 16:36:54.203 9400-0/com.sample  E/Go: 
> /home/test/2019/test/test.go:141 +0x190
> 2019-09-10 16:36:54.203 9400-0/com.sample  E/Go: 
> main.proxytest__testFunction(...)
> 2019-09-10 16:36:54.203 9400-0/com.sample com.sample E/Go: 
> /tmp/gomobile-work-071468276/src/gobind/go_testmain.go:199
> 2019-09-10 16:36:54.203 9400-0/com.sample  E/Go: 
> main._cgoexpwrap_5427a26f9204_proxytest__testFunction(0x8020080280200802)
> 2019-09-10 16:36:54.203 9400-0/com.sample  E/Go: _cgo_gotypes.go:606 
> +0x1c
> 2019-09-10 16:36:54.204 9400-9423/com.sample  A/libc: Fatal signal 6 
> (SIGABRT), code -6 in tid 9423 (Thread-2)
>
> *Can you please provide you opinion. Let me know if any other information 
> is needed. *
>
> Thanks
>
>
> On Monday, September 9, 2019 at 5:40:25 PM UTC+5:30, Elias Naur wrote:
>>
>> On Mon Sep 9, 2019 at 3:09 AM Jay Sharma wrote: 
>> > 
>> > *Next I want to try with my own classes in java.. I want to define 
>> class 
>> > and call it from go. * 
>> > *Can you please suggest, in that case how to build with gomobile ?* 
>> > 
>>
>> I think you can use the -classpath option to gomobile. 
>>
>> -- elias 
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/9957ce97-b649-4733-9b46-2232f88c55a3%40googlegroups.com.


Re: [go-nuts] Re: x/mobile: Samples for reverse binding in gomobile

2019-09-10 Thread Jay Sharma
Hello @elias,

I tried the following:

1. Created a java class : 

package reversebinding;

public class RBinding {
 public static String getStringFromJava() {
return "Hello from java !!";
}
}

2. Generated the .class file for this file. 

3. Generated the android binding using gomobile tool and used 
-classpath="Path to my .class file"

4. Binding is generated successfully. 

*But when I used that generated (.aar) file in my android app and tried to 
trigger the api it is crashing; *

2019-09-10 16:36:54.199 9400-9430/com.sample  E/GoLog: 2019/09/10 11:06:54 
test.go:134: testFunction [Test]
2019-09-10 16:36:54.199 9400-9430/com.sample  E/GoLog: 2019/09/10 11:06:54 
test.go:136: [Test] Now going to call a java system function 
(System.CurrentTimeMillis()).
2019-09-10 16:36:54.200 9400-9434/com.sample  E/GoLog: 2019/09/10 11:06:54 
test.go:138: [Test] Called java function return value is:  1568113614199
2019-09-10 16:36:54.200 9400-9434/com.sample  E/GoLog: 2019/09/10 11:06:54 
test.go:140: [Test] Now going to call my java function.
2019-09-10 16:36:54.203 9400-0/com.sample  E/Go: panic: runtime error: 
invalid memory address or nil pointer dereference
2019-09-10 16:36:54.203 9400-0/com.sample  E/Go: [signal SIGSEGV: 
segmentation violation code=0x1 addr=0x0 pc=0x7568010708]
2019-09-10 16:36:54.203 9400-0/com.sample  E/Go: goroutine 17 [running, 
locked to thread]:
2019-09-10 16:36:54.203 9400-0/com.sample  E/Go: 
test.testFunction(0x400738)
2019-09-10 16:36:54.203 9400-0/com.sample  E/Go: 
/home/test/2019/test/test.go:141 +0x190
2019-09-10 16:36:54.203 9400-0/com.sample  E/Go: 
main.proxytest__testFunction(...)
2019-09-10 16:36:54.203 9400-0/com.sample com.sample E/Go: 
/tmp/gomobile-work-071468276/src/gobind/go_testmain.go:199
2019-09-10 16:36:54.203 9400-0/com.sample  E/Go: 
main._cgoexpwrap_5427a26f9204_proxytest__testFunction(0x8020080280200802)
2019-09-10 16:36:54.203 9400-0/com.sample  E/Go: _cgo_gotypes.go:606 
+0x1c
2019-09-10 16:36:54.204 9400-9423/com.sample  A/libc: Fatal signal 6 
(SIGABRT), code -6 in tid 9423 (Thread-2)

*Can you please provide you opinion. Let me know if any other information 
is needed. *

Thanks


On Monday, September 9, 2019 at 5:40:25 PM UTC+5:30, Elias Naur wrote:
>
> On Mon Sep 9, 2019 at 3:09 AM Jay Sharma wrote: 
> > 
> > *Next I want to try with my own classes in java.. I want to define class 
> > and call it from go. * 
> > *Can you please suggest, in that case how to build with gomobile ?* 
> > 
>
> I think you can use the -classpath option to gomobile. 
>
> -- elias 
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/ecc0ab8e-2f04-4f76-af41-664af8c1041a%40googlegroups.com.


Re: [go-nuts] Re: x/mobile: Samples for reverse binding in gomobile

2019-09-09 Thread Elias Naur
On Mon Sep 9, 2019 at 3:09 AM Jay Sharma wrote:
> 
> *Next I want to try with my own classes in java.. I want to define class 
> and call it from go. *
> *Can you please suggest, in that case how to build with gomobile ?*
> 

I think you can use the -classpath option to gomobile.

-- elias

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/BWVGLNVRYFPP.2S3AHD3ABK0VZ%40toolbox.


[go-nuts] Re: x/mobile: Samples for reverse binding in gomobile

2019-09-06 Thread Elias Naur


fredag den 6. september 2019 kl. 13.29.33 UTC+2 skrev Jay Sharma:
>
> Hello All,
>
> *I can not see any samples for reverse binding (Calling function from go 
> layer of java layer) in gomobile.*
>
>
>
There is the original proposal:

https://github.com/golang/go/issues/16876

There is also some example code in

https://github.com/golang/mobile/blob/master/bind/testdata/classes.go

-- elias

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/5f00b73e-eb21-4076-8508-6df651245519%40googlegroups.com.