Class: DubyClassLoader
- Inherits:
-
javajava::securityjava::security::SecureClassLoader
- Object
- javajava::securityjava::security::SecureClassLoader
- DubyClassLoader
- Defined in:
- lib/duby.rb
Overview
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.
Instance Method Summary collapse
- #findClass(name) ⇒ Object
-
#initialize(parent, class_map) ⇒ DubyClassLoader
constructor
A new instance of DubyClassLoader.
- #loadClass(name, resolve) ⇒ Object
Constructor Details
#initialize(parent, class_map) ⇒ DubyClassLoader
Returns a new instance of DubyClassLoader.
80 81 82 83 |
# File 'lib/duby.rb', line 80 def initialize(parent, class_map) super(parent) @class_map = class_map end |
Instance Method Details
#findClass(name) ⇒ Object
85 86 87 88 89 90 91 92 |
# File 'lib/duby.rb', line 85 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 |
#loadClass(name, resolve) ⇒ Object
94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/duby.rb', line 94 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 |