Class | JavaClass::ClassFile::ClassMagic |
In: |
lib/javaclass/classfile/class_magic.rb
|
Parent: | Object |
The CAFEBABE magic of a class file. This just checks if CAFEBABE is here.
Author: | Peter Kofler |
CAFE_BABE | = | "\xCA\xFE\xBA\xBE" |
Check the class magic in the data beginning at position start (which is usually 0).
# File lib/javaclass/classfile/class_magic.rb, line 13 def initialize(data, start=0) @bytes = data[start..start+3] end
Return the value of the magic in this class.
# File lib/javaclass/classfile/class_magic.rb, line 23 def bytes @bytes.dup end
Check if this magic is valid and raise an ClassFormatError if not with an optional msg .
# File lib/javaclass/classfile/class_magic.rb, line 28 def check(msg='invalid java class magic') unless valid? raise(ClassFormatError, msg) end end