How do I return value from java RPC

Hello,
I wanted to return value from java RPC but I only get original value.
I call from ESL:

REAL _r
_r := 100
CALLJ [E.Test] Sqrt(_r) SYNC ON SELF.EVH

I got it to java

public D2Real Sqrt(D2Real r) {
  return new D2Real(Math.sqrt(r));
}

But value of _r in ESL is still 100.

Good morning. Java parameters are IN-OUT parameters. You have to set new value to the object that you have received as parameter.

public void Sqrt(D2Real r) {
  r.setVal(Math.sqrt(r));
}

Returned value is ignored.
You also cannot assign new value to different object such as:

public void Sqrt(D2Real r) {
  r = new D2Real(Math.sqrt(r)); // this wouldn't work either
}