JIProlog

 

Write Java objects

1/10/2015 9:36:54 PM
Gravatar
Total Posts 8

Write Java objects

I didn't find a way to write Java objects returned by create_object/3 or invoke/4, is there one? If not, I think there should be, perhaps write/1 should take references.

1/11/2015 11:19:27 AM
Gravatar
Total Posts 11

Re: Write Java objects

What do you mean by "Write Java Objects"?

Do you mean calling toString() method or something else?

1/15/2015 4:29:28 AM
Gravatar
Total Posts 8

Re: Write Java objects

I meant calling System.out.println on them, but actually calling toString does the trick.

 

Thanks.

1/15/2015 9:37:49 AM
Gravatar
Total Posts 11

Re: Write Java objects

You should call the toString method by using invoke4 predicate:

JIP:-create_object('java.lang.String'('java.lang.String'), ['Hello World'], Handle).

Yes
Handle = #-
862545276

JIP:-invoke('#-862545276', toString, [], RetVal), get('java.lang.System', out, Out), invoke(Out, println('java.lang.Object'), ['#-862545276'], A).

Yes
RetVal = Hello World
Out = #6808118
A = []