Skip to content
This repository

1.6 backport: JRUBY-6810 #273

Merged
merged 1 commit into from over 1 year ago

3 participants

David Kellum Don't Add Me To Your Organization a.k.a The Travis Bot Charles Oliver Nutter
David Kellum

No description provided.

Charles Oliver Nutter Fix JRUBY-6810
YAML.load(YAML.dump(lambda{})) should raise TypeError

Proc should not define an allocator (#allocate should raise).
ab0fd82
Don't Add Me To Your Organization a.k.a The Travis Bot

This pull request passes (merged ab0fd82 into 9ded4e9).

Charles Oliver Nutter headius merged commit 5ae7300 into from August 27, 2012
Charles Oliver Nutter headius closed this August 27, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 2 authors.

Aug 26, 2012
Charles Oliver Nutter Fix JRUBY-6810
YAML.load(YAML.dump(lambda{})) should raise TypeError

Proc should not define an allocator (#allocate should raise).
ab0fd82
This page is out of date. Refresh to see the latest.
9  spec/regression/JRUBY-6810_proc_should_not_have_allocator_spec.rb
... ...
@@ -0,0 +1,9 @@
  1
+require 'rspec'
  2
+
  3
+describe "The Proc class" do
  4
+  it "should not be directly allocatable" do
  5
+    lambda do
  6
+      Proc.allocate
  7
+    end.should raise_error(TypeError)
  8
+  end
  9
+end
14  src/org/jruby/RubyProc.java
@@ -75,19 +75,9 @@ protected RubyProc(Ruby runtime, RubyClass rubyClass, Block.Type type, ISourcePo
75 75
         this(runtime, rubyClass, type);
76 76
         this.sourcePosition = sourcePosition;
77 77
     }
78  
-    
79  
-    private static ObjectAllocator PROC_ALLOCATOR = new ObjectAllocator() {
80  
-        public IRubyObject allocate(Ruby runtime, RubyClass klass) {
81  
-            RubyProc instance = new RubyProc(runtime, runtime.getProc(), Block.Type.PROC);
82  
-
83  
-            instance.setMetaClass(klass);
84  
-
85  
-            return instance;
86  
-        }
87  
-    };
88 78
 
89 79
     public static RubyClass createProcClass(Ruby runtime) {
90  
-        RubyClass procClass = runtime.defineClass("Proc", runtime.getObject(), PROC_ALLOCATOR);
  80
+        RubyClass procClass = runtime.defineClass("Proc", runtime.getObject(), ObjectAllocator.NOT_ALLOCATABLE_ALLOCATOR);
91 81
         runtime.setProc(procClass);
92 82
 
93 83
         procClass.index = ClassIndex.PROC;
@@ -136,7 +126,7 @@ public static IRubyObject newInstance(ThreadContext context, IRubyObject recv, I
136 126
             return block.getProcObject();
137 127
         }
138 128
         
139  
-        RubyProc obj = (RubyProc)((RubyClass) recv).allocate();
  129
+        RubyProc obj = new RubyProc(context.runtime, (RubyClass)recv, Block.Type.PROC);
140 130
         obj.setup(block);
141 131
         
142 132
         obj.callMethod(context, "initialize", args, block);
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.