Are class object handles passed by reference when used are class method arguments?

Are class object handles always passed by reference when used are class method arguments?
Or does one need to qualify the formal argument as ref, or perhaps inout?

Concrete example I am working on: I have class function

function int to_gp(uvm_tlm_generic_payload gp)

which maps my (transaction) class attributes to generic payload.

I will generally want to call super.to_gp(gp) where my class extends from some base class that already implements to_gp for its base class attributes.
Let’s assume I do a gp = new in the to_gp function of that base class, then set the gp object’s data and data_length etc. I would now expect that in the derived class the new gp object survives the supr.to_gp call so that I can access its data and other contents. But I get a null object access.

I have tried with ref but run into some issues from which I have yet to conclude what;s going on, and I am just trying now inout but that seems counter intuitive.

I am firing off this question since I actually would like to know from an expert - I did not readily find an answer in the LRM.

Thanks - Hans

In reply to HvdS:

Hans, See this response as well as the link it contains.

In reply to dave_59:

Hi Dave,
From the response and embedded link I get that I should not need to use ref for my case as I described. Interestingly though, when not using it I get a null object, when using it, it appears to work. Aside, this is with VCS.

In the other response it does state that you almost never need to use ref with class object handles. So I thought to. Any my use case does not seem to be a case for which this is an exception, right?

So still puzzled about the behavior I am seeing.

Hans

In reply to HvdS:

Hard to answer without seeing more code, but if you are constructing a class handle inside a function that you want to pass out as a function argument, use an output direction, not a ref.