Skip to content

Commit

Permalink
Revert "Do not cache the struct layout in the metaclass"
Browse files Browse the repository at this point in the history
This reverts commit 21a8a8c.

Per ffi/ffi#734, the behavior that broke this caching is now
deprecated and will be removed in ffi 2.0.
  • Loading branch information
headius committed Jan 10, 2020
1 parent 3d0cb54 commit 95c73a6
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions core/src/main/java/org/jruby/ext/ffi/Struct.java
Expand Up @@ -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) {
Expand Down

0 comments on commit 95c73a6

Please sign in to comment.