Aspektj staticInitialisierung verändert den Methodenkontext des Code in der Clinit bei @AroundJava

Java-Forum
Anonymous
 Aspektj staticInitialisierung verändert den Methodenkontext des Code in der Clinit bei @Around

Post by Anonymous »

Diese Frage ist eine Folge der Frage hier
Aspekte @around Ein statischer Initialisierer < /p>
Ich habe diese Antwort akzeptiert, weil sie den Aspekt auf den Code anwendete, aber ich hatte es noch nicht ausgeführt, um es immer noch zu Problemen zu sehen ... < /p>
Ich habe diesen Aspekt < /p>

Code: Select all

package com.acme.aspects.exceptions;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@Aspect
public class StaticInitializerExceptions {

private static final Logger LOGGER = LoggerFactory.getLogger(StaticInitializerExceptions.class);

@Around("staticinitialization(!is(InterfaceType)) && !within(MyAspect) && !within(com.acme.aspects.exceptions.StaticInitializerExceptions)")
public Object logStaticInitializerException(ProceedingJoinPoint joinPoint) throws Throwable {
try {
return joinPoint.proceed();
} catch (Throwable t) {
LOGGER.error("STATIC INITIALIZER EXCEPTION CAUGHT", t);
throw t;
}
}
}
In einem Versuch, die Quelle eines mysteriösen NoklassdeffoundErrors in einem Initialisierer zu finden. />

Code: Select all

public class AcmeContextListener implements ServletContextListener {

private static final Logger LOGGER = LoggerFactory.getLogger(AcmeContextListener.class);

....
}
< /code>
Dann wird es Clinit so gewebt, dass der
logger = loggerfactory.getLogger (AcmeContextListener.ClASS);  - STATIC INITIALIZER EXCEPTION CAUGHT
at com.acme.listener.AcmeContextListener.clinit$_aroundBody0(AcmeContextListener.java:20) ~[_servlets.jar:25.6.0.0]
at com.acme.listener.AcmeContextListener.clinit$_aroundBody1$advice(AcmeContextListener.java:17) ~[_servlets.jar:25.6.0.0]
java.lang.IllegalAccessError: Update to static final field com.acme.listener.AcmeContextListener.LOGGER attempted from a different method (clinit$_aroundBody0) than the initializer method 
at com.acme.listener.AcmeContextListener.(AcmeContextListener.java:1) ~[_servlets.jar:25.6.0.0]
Gibt es hier etwas, das hier getan werden kann?

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post