Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move generated class packages to enable java 21 support #23

Merged
merged 2 commits into from
Dec 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ private <T> T generateProxy(final Class<T> proxyInterface, final RingBuffer<Prox
final Map<Method, Invoker> 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);
Expand All @@ -179,7 +179,7 @@ private <T> T instantiateProxy(final CtClass ctClass, final RingBuffer<ProxyMeth
{
try
{
return instantiate(ctClass.toClass(), new Class[]{RingBuffer.class, DropListener.class,
return instantiate(ctClass.toClass(GeneratedRingBufferProxyGenerator.class), new Class[]{RingBuffer.class, DropListener.class,
MessagePublicationListener.class}, ringBuffer, dropListener, messagePublicationListener);
}
catch (CannotCompileException e)
Expand Down Expand Up @@ -250,7 +250,7 @@ private void createFields(final Map<Method, Invoker> 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() + "();");
}
}

Expand Down Expand Up @@ -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").
Expand Down Expand Up @@ -332,7 +332,7 @@ private void handleOverflowStrategy(final OverflowStrategy overflowStrategy, fin
@SuppressWarnings("unchecked")
private <T> Invoker generateInvoker(final Class<T> 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();
Expand Down Expand Up @@ -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)
Expand Down
Loading