From 879cc63ed5fa14fc363725d39c0b4d919b25ddbf Mon Sep 17 00:00:00 2001 From: cooked Date: Fri, 27 Dec 2024 12:30:19 +0000 Subject: [PATCH 1/2] Update javassist to 3.30.2 --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 97a3cd6..59544be 100644 --- a/build.gradle +++ b/build.gradle @@ -47,7 +47,7 @@ repositories { dependencies { testImplementation 'junit:junit:4.5' testImplementation 'org.hamcrest:hamcrest-core:1.3' - implementation 'org.javassist:javassist:3.19.0-GA' + implementation 'org.javassist:javassist:3.30.2-GA' implementation 'com.lmax:disruptor:3.3.0' } From dff7b0ddf6df8f55e35e8136a840fa8dd8e99bfc Mon Sep 17 00:00:00 2001 From: cooked Date: Fri, 27 Dec 2024 13:47:45 +0000 Subject: [PATCH 2/2] Generate classes in our own package to support java 21 --- .../disruptor/bytecode/ArgumentHolderGenerator.java | 4 ++-- .../bytecode/GeneratedRingBufferProxyGenerator.java | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/lmax/tool/disruptor/bytecode/ArgumentHolderGenerator.java b/src/main/java/com/lmax/tool/disruptor/bytecode/ArgumentHolderGenerator.java index e3a51b1..1861e43 100644 --- a/src/main/java/com/lmax/tool/disruptor/bytecode/ArgumentHolderGenerator.java +++ b/src/main/java/com/lmax/tool/disruptor/bytecode/ArgumentHolderGenerator.java @@ -50,7 +50,7 @@ public ArgumentHolderGenerator(final ClassPool classPool) public void createArgumentHolderClass(final Class proxyInterface) { - final CtClass ctClass = makeClass(classPool, "_argumentHolder_" + proxyInterface.getSimpleName() + "_" + getUniqueIdentifier()); + final CtClass ctClass = makeClass(classPool, "com.lmax.tool.disruptor.bytecode._argumentHolder_" + proxyInterface.getSimpleName() + "_" + getUniqueIdentifier()); parameterTypeCounts = helper.getParameterTypeCounts(proxyInterface); createFields(ctClass); @@ -61,7 +61,7 @@ public void createArgumentHolderClass(final Class proxyInterface) { ctClass.addConstructor(CtNewConstructor.defaultConstructor(ctClass)); makePublicFinal(ctClass); - generatedClass = ctClass.toClass(); + generatedClass = ctClass.toClass(ArgumentHolderGenerator.class); } catch (CannotCompileException e) { diff --git a/src/main/java/com/lmax/tool/disruptor/bytecode/GeneratedRingBufferProxyGenerator.java b/src/main/java/com/lmax/tool/disruptor/bytecode/GeneratedRingBufferProxyGenerator.java index bdc96dc..0290d48 100644 --- a/src/main/java/com/lmax/tool/disruptor/bytecode/GeneratedRingBufferProxyGenerator.java +++ b/src/main/java/com/lmax/tool/disruptor/bytecode/GeneratedRingBufferProxyGenerator.java @@ -158,7 +158,7 @@ private T generateProxy(final Class proxyInterface, final RingBuffer methodToInvokerMap, final OverflowStrategy overflowStrategy, final ArgumentHolderGenerator argumentHolderGenerator) { - final CtClass ctClass = makeClass(classPool, "_proxy" + proxyInterface.getSimpleName() + '_' + + final CtClass ctClass = makeClass(classPool, "com.lmax.tool.disruptor.bytecode._proxy" + proxyInterface.getSimpleName() + '_' + getUniqueIdentifier()); addInterface(ctClass, proxyInterface, classPool); @@ -179,7 +179,7 @@ private T instantiateProxy(final CtClass ctClass, final RingBuffer methodToInvokerMap, final C final Invoker invoker = methodToInvokerMap.get(method); createField(ctClass, "private final " + invoker.getClass().getName() + " _" + - invoker.getClass().getName() + " = new " + invoker.getClass().getName() + "();"); + invoker.getClass().getName().replace(".", "_") + " = new " + invoker.getClass().getName() + "();"); } } @@ -303,7 +303,7 @@ private void createRingBufferPublisherMethod(final CtClass ctClass, final Method methodSrc.append("holder.").append(holderField).append(" = ").append((char) ('a' + i)).append(";"); } - methodSrc.append("proxyMethodInvocation.setInvoker(_").append(invoker.getClass().getName()). + methodSrc.append("proxyMethodInvocation.setInvoker(_").append(invoker.getClass().getName().replace(".", "_")). append(");\n"). append("}\n"). append("catch(Throwable t){t.printStackTrace();}\n"). @@ -332,7 +332,7 @@ private void handleOverflowStrategy(final OverflowStrategy overflowStrategy, fin @SuppressWarnings("unchecked") private Invoker generateInvoker(final Class proxyInterface, final Method method, final ArgumentHolderGenerator argumentHolderGenerator) { - final StringBuilder invokerClassName = new StringBuilder("_invoker").append(proxyInterface.getSimpleName()). + final StringBuilder invokerClassName = new StringBuilder("com.lmax.tool.disruptor.bytecode._invoker").append(proxyInterface.getSimpleName()). append(method.getName()).append('_').append(getUniqueIdentifier()); final Class[] parameterTypes = method.getParameterTypes(); @@ -378,7 +378,7 @@ private Invoker generateInvoker(final CtClass ctClass, final StringBuilder metho { ctClass.addMethod(CtMethod.make(methodSrc.toString(), ctClass)); ctClass.addConstructor(CtNewConstructor.defaultConstructor(ctClass)); - final Class generatedClass = ctClass.toClass(); + final Class generatedClass = ctClass.toClass(GeneratedRingBufferProxyGenerator.class); return (Invoker) generatedClass.newInstance(); } catch (CannotCompileException e)