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' } 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)