Skip to content

Commit

Permalink
Bail out of recursively-namespaced modules when calculating name.
Browse files Browse the repository at this point in the history
Fixes #2314.
  • Loading branch information
headius committed May 4, 2015
1 parent cb4e52e commit 5305b14
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions core/src/main/java/org/jruby/RubyModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,9 @@ private String calculateName() {
// First, we count the parents
int parentCount = 0;
for (RubyModule p = getParent() ; p != null && p != objectClass ; p = p.getParent()) {
// Break out of cyclic namespaces like C::A = C2; C2::A = C (jruby/jruby#2314)
if (p == this) break;

parentCount++;
}

Expand All @@ -491,6 +494,9 @@ private String calculateName() {
int i = parentCount - 1;
int totalLength = name.length() + parentCount * 2; // name length + enough :: for all parents
for (RubyModule p = getParent() ; p != null && p != objectClass ; p = p.getParent(), i--) {
// Break out of cyclic namespaces like C::A = C2; C2::A = C (jruby/jruby#2314)
if (p == this) break;

String pName = p.getBaseName();

// This is needed when the enclosing class or module is a singleton.
Expand Down

0 comments on commit 5305b14

Please sign in to comment.