Sha256: 3824bcf2f6a35cbb27cdfa3c8965a3ab9dd94842a012e03ab15c9ed50b88db43

Contents?: true

Size: 954 Bytes

Versions: 1

Compression:

Stored size: 954 Bytes

Contents

# This is a custom classloader impl to allow loading classes with
# interdependencies by having findClass retrieve classes as needed from the
# collection of all classes generated by the target script.
module Mirah
  module Util
    class ClassLoader < java::security::SecureClassLoader
      def initialize(parent, class_map)
        super(parent)
        @class_map = class_map
      end

      def findClass(name)
        if @class_map[name]
          bytes = @class_map[name].to_java_bytes
          defineClass(name, bytes, 0, bytes.length)
        else
          raise java.lang.ClassNotFoundException.new(name)
        end
      end

      def loadClass(name, resolve)
        cls = findLoadedClass(name)
        if cls == nil
          if @class_map[name]
            cls = findClass(name)
          else
            cls = super(name, false)
          end
        end

        resolveClass(cls) if resolve

        cls
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mirah-0.0.8-java lib/mirah/util/class_loader.rb