Reformatted code using IntelliJ

This commit is contained in:
Finn
2025-10-04 00:08:37 +02:00
parent f883167a16
commit 46fc997ae5
6 changed files with 19 additions and 36 deletions

View File

@@ -21,7 +21,6 @@ public class CallTracker<A extends Annotation> extends GenericReflectClass<A> {
public CallTracker(CallInterceptor interceptor) {
super();
atomicClass.set(this.persistentClass);
}
@@ -31,8 +30,7 @@ public class CallTracker<A extends Annotation> extends GenericReflectClass<A> {
new AgentBuilder.Default()
.type(any()) // instrument all classes, you can restrict here
.transform((builder, type, classLoader, module, protectionDomain) ->
builder.visit(Advice.to(CallInterceptor.class).on(isMethod()))
).installOn(inst);
builder.visit(Advice.to(CallInterceptor.class).on(isMethod()))).installOn(inst);
}
public abstract static class CallInterceptor {
@@ -44,15 +42,12 @@ public class CallTracker<A extends Annotation> extends GenericReflectClass<A> {
@Advice.OnMethodEnter
static void intercept(@Advice.Origin Method method) {
for (CallInterceptor interceptor : interceptors) {
StackTraceElement[] stack = Thread.currentThread().getStackTrace();
if (stack.length <= 3)
return;
if (stack.length <= 3) return;
StackTraceElement caller = stack[3];
interceptor.onCall(method, caller);
}

View File

@@ -38,45 +38,34 @@ public class ProtocolInfoProcessing extends AnnotationProcessor<ProtocolInfo> {
@Override
public void onCall(Method method, @Nullable StackTraceElement callerMethod) {
ProtocolVersion.ProtocolSide side, callerSide;
Object o;
if ((o = methodGetByName(callerMethod.getMethodName())) != null)
callerSide = ((Method) o).getAnnotation(ProtocolInfo.class).protocolSide();
else if ((o = typeHasAnnotation(callerMethod.getClassName())) != null)
callerSide = ((Class<?>) o).getAnnotation(ProtocolInfo.class).protocolSide();
else
return;
else return;
if (methodReferences.get().contains(method))
side = method.getAnnotation(ProtocolInfo.class).protocolSide();
else if (typeReferences.get().contains(method.getDeclaringClass()))
side = method.getDeclaringClass().getAnnotation(ProtocolInfo.class).protocolSide();
else
return;
else return;
if (callerSide.equals(ProtocolVersion.ProtocolSide.CLIENT) &&
!side.equals(callerSide))
if (callerSide.equals(ProtocolVersion.ProtocolSide.CLIENT) && !side.equals(callerSide))
throw new IncompatibleProtocolSideException(callerSide, side);
}
});
}
private Method methodGetByName(String methodName) {
for (Method method : this.annotatedMethods)
if (method.getName().equals(methodName))
return method;
for (Method method : this.annotatedMethods) if (method.getName().equals(methodName)) return method;
return null;
}
private Class<?> typeHasAnnotation(String typeName) {
for (Class<?> type : this.annotatedTypes)
if (type.getName().equals(typeName))
return type;
for (Class<?> type : this.annotatedTypes) if (type.getName().equals(typeName)) return type;
return null;
}