From 95c73a66795d729c7cc3a37a1c9ad420d9008f2c Mon Sep 17 00:00:00 2001 From: Charles Oliver Nutter Date: Fri, 10 Jan 2020 08:19:09 -0600 Subject: [PATCH] Revert "Do not cache the struct layout in the metaclass" This reverts commit 21a8a8cc9d36b1d15e82cbec1015a50aea7d9137. Per ffi/ffi#734, the behavior that broke this caching is now deprecated and will be removed in ffi 2.0. --- core/src/main/java/org/jruby/ext/ffi/Struct.java | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/core/src/main/java/org/jruby/ext/ffi/Struct.java b/core/src/main/java/org/jruby/ext/ffi/Struct.java index c07fee37eef..b51e385e1ad 100644 --- a/core/src/main/java/org/jruby/ext/ffi/Struct.java +++ b/core/src/main/java/org/jruby/ext/ffi/Struct.java @@ -112,14 +112,8 @@ static final StructLayout getStructLayout(Ruby runtime, IRubyObject structClass) throw runtime.newRuntimeError("no valid struct layout for " + ((RubyClass) structClass).getName()); } - // FIXME: This cache breaks repeat layouts against the same class, since the first layout - // gets cached. It broke struct_spec.rb where it reopens PairLayout in two successive specs, - // but has never been reported to JRuby as a bug. This may be a case worth preventing with - // a hard error, to avoid the need to constantly re-retrieve the layout. - -// // Cache the layout on the Struct metaclass for faster retrieval next time -// ((RubyClass) structClass).setFFIHandle(layout); - + // Cache the layout on the Struct metaclass for faster retrieval next time + ((RubyClass) structClass).setFFIHandle(layout); return (StructLayout) layout; } catch (ClassCastException ex) {