Skip to content

Commit

Permalink
Always unwrap old initialize methods
Browse files Browse the repository at this point in the history
If these are delegated or wrapped by profiling, we will fail type
comparisons later on. Those comparisons are fragile, but for now
this is the simplest fix.

Fixes jruby#8148
  • Loading branch information
headius committed Apr 25, 2024
1 parent e50cdc1 commit 9643320
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ public static class StaticJCreateMethod extends JavaMethodNBlock {
StaticJCreateMethod(RubyModule implClass, Constructor<? extends ReifiedJavaProxy> javaProxyConstructor, DynamicMethod oldinit) {
super(implClass, PUBLIC, "__jcreate_static!");
this.withBlock = javaProxyConstructor;
this.oldInit = oldinit;
this.oldInit = oldinit == null ? oldinit : oldinit.getRealMethod(); // ensure we don't use a wrapper (jruby/jruby#8148)
}

@Override
Expand Down Expand Up @@ -374,7 +374,7 @@ public SplitCtorData splitInitialized(RubyClass base, IRubyObject[] args, Block
final String name = base.getClassConfig().javaCtorMethodName;
final CacheEntry methodEntry = base.searchWithCache(name);
final boolean isLateral = isClassOrIncludedPrependedModule(methodEntry.sourceModule, base);
DynamicMethod method = methodEntry.method;
DynamicMethod method = methodEntry.method.getRealMethod(); // ensure we don't use a wrapper (jruby/jruby#8148)
if (method instanceof StaticJCreateMethod) method = ((StaticJCreateMethod) method).oldInit;

// jcreate is for nested ruby classes from a java class
Expand Down

0 comments on commit 9643320

Please sign in to comment.