-
-
Notifications
You must be signed in to change notification settings - Fork 938
Expand file tree
/
Copy pathOneShotClassLoader.java
More file actions
34 lines (28 loc) · 930 Bytes
/
OneShotClassLoader.java
File metadata and controls
34 lines (28 loc) · 930 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package org.jruby.util;
/**
* Represents a class loader designed to load exactly one class.
*/
public class OneShotClassLoader extends ClassLoader implements ClassDefiningClassLoader {
static {
registerAsParallelCapable();
}
public OneShotClassLoader(JRubyClassLoader parent) {
super(parent);
}
public OneShotClassLoader(ClassLoader parent) {
super(parent);
}
public Class<?> defineClass(String name, byte[] bytes) {
Class<?> cls = super.defineClass(name, bytes, 0, bytes.length, ClassDefiningJRubyClassLoader.DEFAULT_DOMAIN);
resolveClass(cls);
return cls;
}
@Override
public Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException {
return super.loadClass(name, resolve);
}
@Override
public boolean hasDefinedClass(String name) {
return super.findLoadedClass(name) != null;
}
}