module JavaClass::Dsl::Loader

Load the classfiles and create the JavaClassHeader. This module ties together all ClassFile and Classpath modules.

Author

Peter Kofler

Public Instance Methods

disassemble(data) click to toggle source

Read and disassemble the given class inside data (byte data). Might throw a ClassFile::ClassFormatError if the classfile is not valid. This creates a ClassFile::JavaClassHeader .

# File lib/javaclass/dsl/loader.rb, line 35
def disassemble(data)
  ClassFile::JavaClassHeader.new(data)
end
load_cp(classname, classpath) click to toggle source

Read and disassemble the given class classname from classpath .

# File lib/javaclass/dsl/loader.rb, line 23
def load_cp(classname, classpath)
  begin
    disassemble(classpath.load_binary(classname))
  rescue ClassFile::ClassFormatError => ex
    ex.add_classname(classname, classpath.to_s)
    raise ex
  end
end
load_fs(filename) click to toggle source

Read and disassemble the given class from filename (full file name).

# File lib/javaclass/dsl/loader.rb, line 13
def load_fs(filename)
  begin
    disassemble(File.open(filename, 'rb') { |io| io.read.freeze } )
  rescue ClassFile::ClassFormatError => ex
    ex.add_classname(filename)
    raise ex
  end
end