Skip to content

Instantly share code, notes, and snippets.

@headius
Created May 4, 2015 16:49
Show Gist options
  • Save headius/204a219637e900a08c16 to your computer and use it in GitHub Desktop.
Save headius/204a219637e900a08c16 to your computer and use it in GitHub Desktop.
diff --git a/core/src/main/java/org/jruby/RubyModule.java b/core/src/main/java/org/jruby/RubyModule.java
index 71fbb4a..b77a5cf 100644
--- a/core/src/main/java/org/jruby/RubyModule.java
+++ b/core/src/main/java/org/jruby/RubyModule.java
@@ -483,6 +483,9 @@ public class RubyModule extends RubyObject {
// 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++;
}
@@ -491,6 +494,9 @@ public class RubyModule extends RubyObject {
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment