Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

1.6 backport: JRUBY-6810 #273

Merged
merged 1 commit into from

3 participants

@dekellum

No description provided.

@headius headius Fix JRUBY-6810
YAML.load(YAML.dump(lambda{})) should raise TypeError

Proc should not define an allocator (#allocate should raise).
ab0fd82
@travisbot

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

@headius headius merged commit 5ae7300 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 27, 2012
  1. @headius @dekellum

    Fix JRUBY-6810

    headius authored dekellum committed
    YAML.load(YAML.dump(lambda{})) should raise TypeError
    
    Proc should not define an allocator (#allocate should raise).
This page is out of date. Refresh to see the latest.
View
9 spec/regression/JRUBY-6810_proc_should_not_have_allocator_spec.rb
@@ -0,0 +1,9 @@
+require 'rspec'
+
+describe "The Proc class" do
+ it "should not be directly allocatable" do
+ lambda do
+ Proc.allocate
+ end.should raise_error(TypeError)
+ end
+end
View
14 src/org/jruby/RubyProc.java
@@ -75,19 +75,9 @@ protected RubyProc(Ruby runtime, RubyClass rubyClass, Block.Type type, ISourcePo
this(runtime, rubyClass, type);
this.sourcePosition = sourcePosition;
}
-
- private static ObjectAllocator PROC_ALLOCATOR = new ObjectAllocator() {
- public IRubyObject allocate(Ruby runtime, RubyClass klass) {
- RubyProc instance = new RubyProc(runtime, runtime.getProc(), Block.Type.PROC);
-
- instance.setMetaClass(klass);
-
- return instance;
- }
- };
public static RubyClass createProcClass(Ruby runtime) {
- RubyClass procClass = runtime.defineClass("Proc", runtime.getObject(), PROC_ALLOCATOR);
+ RubyClass procClass = runtime.defineClass("Proc", runtime.getObject(), ObjectAllocator.NOT_ALLOCATABLE_ALLOCATOR);
runtime.setProc(procClass);
procClass.index = ClassIndex.PROC;
@@ -136,7 +126,7 @@ public static IRubyObject newInstance(ThreadContext context, IRubyObject recv, I
return block.getProcObject();
}
- RubyProc obj = (RubyProc)((RubyClass) recv).allocate();
+ RubyProc obj = new RubyProc(context.runtime, (RubyClass)recv, Block.Type.PROC);
obj.setup(block);
obj.callMethod(context, "initialize", args, block);
Something went wrong with that request. Please try again.