Skip to content

Commit

Permalink
Delays UnboundMethod class creation.
Browse files Browse the repository at this point in the history
  • Loading branch information
yokolet committed Jul 20, 2012
1 parent 91c08bb commit ae1a887
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
12 changes: 5 additions & 7 deletions src/org/jruby/Ruby.java
Expand Up @@ -1289,9 +1289,6 @@ private void initCore() {

processModule = getProcess();

if (profile.allowClass("UnboundMethod")) {
RubyUnboundMethod.defineUnboundMethodClass(this);
}
if (profile.allowModule("Signal")) {
RubySignal.createSignal(this);
}
Expand Down Expand Up @@ -1375,6 +1372,7 @@ private void initClassCreatorMap() {
classCreatorMap.put("Stat", this.getClass().getMethod("getFileStat"));
classCreatorMap.put("Process", this.getClass().getMethod("getProcess"));
classCreatorMap.put("Time", this.getClass().getMethod("getTime"));
classCreatorMap.put("UnboundMethod", this.getClass().getMethod("getUnboundMethod"));

classCreatorMap.put("Encoding", this.getClass().getMethod("getEncoding"));

Expand Down Expand Up @@ -1912,11 +1910,11 @@ public RubyClass getMethod() {
}

public RubyClass getUnboundMethod() {
if (unboundMethodClass == null && profile.allowClass("UnboundMethod")) {
unboundMethodClass = RubyUnboundMethod.defineUnboundMethodClass(this);
}
return unboundMethodClass;
}
void setUnboundMethod(RubyClass unboundMethodClass) {
this.unboundMethodClass = unboundMethodClass;
}
}

public RubyClass getMatchData() {
if (matchDataClass == null && profile.allowClass("MatchData")) {
Expand Down
3 changes: 1 addition & 2 deletions src/org/jruby/RubyUnboundMethod.java
Expand Up @@ -67,11 +67,10 @@ public static RubyUnboundMethod newUnboundMethod(
return newMethod;
}

public static RubyClass defineUnboundMethodClass(Ruby runtime) {
static RubyClass defineUnboundMethodClass(Ruby runtime) {
// TODO: NOT_ALLOCATABLE_ALLOCATOR is probably ok here. Confirm. JRUBY-415
RubyClass newClass =
runtime.defineClass("UnboundMethod", runtime.getMethod(), ObjectAllocator.NOT_ALLOCATABLE_ALLOCATOR);
runtime.setUnboundMethod(newClass);

newClass.index = ClassIndex.UNBOUNDMETHOD;
newClass.setReifiedClass(RubyUnboundMethod.class);
Expand Down

0 comments on commit ae1a887

Please sign in to comment.