From 9643320e239220814c498040a8a1700ad33138f6 Mon Sep 17 00:00:00 2001 From: Charles Oliver Nutter Date: Thu, 25 Apr 2024 13:12:48 -0500 Subject: [PATCH] Always unwrap old initialize methods 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 #8148 --- .../main/java/org/jruby/java/proxies/ConcreteJavaProxy.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/org/jruby/java/proxies/ConcreteJavaProxy.java b/core/src/main/java/org/jruby/java/proxies/ConcreteJavaProxy.java index 759b5e1d06b..edb4f69e799 100644 --- a/core/src/main/java/org/jruby/java/proxies/ConcreteJavaProxy.java +++ b/core/src/main/java/org/jruby/java/proxies/ConcreteJavaProxy.java @@ -211,7 +211,7 @@ public static class StaticJCreateMethod extends JavaMethodNBlock { StaticJCreateMethod(RubyModule implClass, Constructor 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 @@ -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