Getting object code for module in on_init

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Getting object code for module in on_init

Hans Elias B. Josephsen
I am trying to get the object code for a module while inside the `on_init` function of that module.

Normally I would use `code:get_object_code(Module)`, but it seems like the .beam file might not have been written to disk yet at that point.

Yet, code in that module is running, so it must be located somewhere.

Is there any way to get the object code of the module itself while in that stage?
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: Getting object code for module in on_init

Björn Gustavsson-4
On Sun, Mar 10, 2019 at 3:40 PM Hans Elias B. Josephsen
<[hidden email]> wrote:
>
> I am trying to get the object code for a module while inside the `on_init` function of that module.

Do you mean an `on_load` function?

> Normally I would use `code:get_object_code(Module)`, but it seems like the .beam file might not have been written to disk yet at that point.

Works fine for me from an `on_load` function.

/Björn

--
Björn Gustavsson, Erlang/OTP, Ericsson AB
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions