Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added information on the beam_renamer.

  • Loading branch information...
commit c2af0f6c6a463ab875922e09c16a63b5854f47a1 1 parent 7655f35
@klajo authored
Showing with 36 additions and 0 deletions.
  1. +36 −0 README
View
36 README
@@ -0,0 +1,36 @@
+This is a collection of various hacks
+=====================================
+
+Well, not a very large right now, since there's only one hack here,
+but still... :-)
+
+beam_renamer
+------------
+
+The idea behind `beam_renamer` is to be able to load an erlang module
+(which is already compiled) under a different name. Normally, there's
+an error message if one does that:
+
+ 1> {x, Bin, _} = code:get_object_code(x).
+ {x,<<...>>,...}
+ 2> code:load_binary(y, "y.beam", Bin).
+ {error,badfile}
+
+ =ERROR REPORT==== 8-Nov-2009::22:01:24 ===
+ Loading of y.beam failed: badfile
+
+ =ERROR REPORT==== 8-Nov-2009::22:01:24 ===
+ beam/beam_load.c(1022): Error loading module y:
+ module name in object code is x
+
+This is where `beam_renamer` comes in handy. It'll rename the module
+by replacing the module name *within* the beam file.
+
+ 1> {x, Bin0, _} = code:get_object_code(x).
+ {x,<<...>>,...}
+ 2> Bin = beam_renamer:rename(Bin0, y).
+ <<...>>
+ 2> code:load_binary(y, "y.beam", Bin).
+ {module,y}
+
+See the comments in the source code for more details.
Please sign in to comment.
Something went wrong with that request. Please try again.