Is it possible to have an aspect around other aspects - ant

my question is related to this question
We have different aspect class that do #around advice on different part of an application (fat client in Swing) to measure the execution time.
I have another aspect (ExceptionHandler) that do #around on all the aspects method i wrote.
I did this to avoid that the aspects created would throw exception and make the client application fails. So basically, i try catch the Proceed of my other #around method and just log exception that arise. I only throw an exception when i detect it come from the proceedingJoinPoint
if (joinPoint.getSignature().getDeclaringTypeName().equalsIgnoreCase("org.aspectj.lang.ProceedingJoinPoint")) {
throw exception;
}
Is it valid to do this?
In Eclipse with AJDT the app run fine and i tested the ExceptionHandler and it worked as expected.
But in other env. (Integration) the application fail as soon as it meet a line advised by the exceptionHandler with this Error
Exception in thread "main" java.lang.NoSuchMethodError: com.xxx.yyy.aop.aspect.ExceptionHandlerAspect.aspect
Of()Lcom/xxx/yyy/aop/aspect/ExceptionHandlerAspect;
at com.xxx.yyy.aop.aspect.ecs.AspectBaseEcs.inspectLoginInfo(AspectBaseEcs.java:65)
at com.xxx.yyy.app.es.security.Security.loadApplications(Security.java:172)
at com.xxx.yyy.app.es.gui.VSDlgLogin.loadSecurity(VSDlgLogin.java:346)
at com.xxx.yyy.app.es.ApplicationSuite.start(ApplicationSuite.java:839)
at com.xxx.yyy.app.es.ApplicationSuite.main(ApplicationSuite.java:501)
I have also decompile the code to see if aspectOf() was weaved into my ExceptionHandler and the method is there!!!!!!!???????????
Why this error rise...?
I'm clueless.

Finally found the problem. Our Application had a dependency on common module jar that was containing aspect too.
The base package name was the same : com.xxx.aop and the base class we used for our aspects was the same name!!!! So 2 com.xxx.aop.AspectBase.class were loaded.
Since we used a flag in our ant build file to enable compile time weaving at yes/no, one of our AspectBase.class was not weaved while the other was.
Can't believe i didn't see that before!!!!!

Related

Vaadin: after upgrading to v23.0.1 (from 22.0.2): Error with Binder opening a Form

After upgrading to Vaadin 23.0.x (from former 22.0.2) I now keep getting the following error when opening a certain dialog:
2022-08-01 18:56:25,977 ERROR [http-nio-8085-exec-5] net.mmo.utils.kism.ui.views.nodes.NodeView: java.lang.IllegalStateException: All bindings created with forField must be completed before calling readBean
at com.vaadin.flow.data.binder.Binder.checkBindingsCompleted(Binder.java:3070)
at com.vaadin.flow.data.binder.Binder.readBean(Binder.java:2110)
at net.mmo.utils.kism.ui.views.nodes.NodeForm.readBean(NodeForm.java:487)
at net.mmo.utils.kism.ui.views.nodes.NodeForm.setNode(NodeForm.java:211)
This dialog has worked perfectly fine since I wrote it (using version 18.0.x about 2 years ago) and up to v22.0.2. I can't make sense of that error message and I don't understand what the issue could be here. I verified that issue going back and forth and the difference is really only the Vaadin version upgrade. Before it, the dialog works just fine and after it I get the above Exception when opening it.
I also can't quite believe what I think the message is stating here: if it would indeed check that I define or complete any bindings AFTER calling Binder.readBean() - how could it know that already in that very moment, i.e. when the code calls readBean() - as indicated by the stacktrace?
If there would indeed be any bindings being defined afterwards, IMHO it could only find that out AFTER said readBean()-call, i.e. when any additional bindings were actually defined, couldn't it?
So, could someone please try to "translate" or explain that issue or the background behind it to me?
The error basically states the problem: in the process of binding a field to a property (or getter/setter in general), the finishing step of actually binding was not undertaken. So the process was started with .forField() but never finished by .bind().
Since the error message as of now only states the fact, but not the culprit, a developer would be in need of a debugger to inspect the private state of the Binder, where the map incompleteBindings holds the current state of the Binder. The content of this map may help to find the culprit, e.g. by only holding one entry and by inspecting the flow of the program so far, that would conclude, what binding attempt failed. Or e.g. via the included field types.
Other than plain "bugs" by the developer, there are some potential reasons, why this suddenly happens by like an update or what places to look for:
multiple (re-)binding was recently added (e.g. to first bind "automatically" and then hand-tune the result); this holds potential, that older versions of the code just kept the initial binding and ignored the dangling second process.
the binding process uses a builder pattern; builder must build up on the result of the previous steps. This means, that in imperative code, there is the chance, that this chained call miss reassigning the build step. E.g.
var b = binder.forField(field)
if (predicate)
b.asRequired() // XXX: should be `b = b.asRequired()`
b.bind(...)
(this may or may not be a source for this kind of problem, but it's good to point out here, since the binder builder implementation actually switche(s|d) the builder (in the past)

ARMv8 exception vector significance of EL0_SP

I am new to ARMv8 architecture and while reading the v8 exception vectors I am not able to understand significance of adding SP_EL0 level vectors while SP_ELx vector set exists. What I am trying to find a use case where this is useful. I understand that when the exception is taken at same level by default the stack of same exception level is used for example if EL2 (Hyp) mode is defined then if exception occurs while being at EL2 level the stack defined at EL2 will be used but not sure if I configure to use EL0 level stack under what use cases this could be useful ? Can some one give a use case and explain ?
Also while going through the spec it seems these two different stack usage idea is taken from Cortex-M architecture but i am not very clear with thread and handler modes as well. Can any one explain it ?
Just wanted to add here that ARMv7 doesn't have thread and handler concept so i am not clear requirement in ARMv8.
Thanks
SP_EL0 is the "normal" stack pointer. Your code that runs in any EL should be running on SP_EL0 whenever it can. SP_EL1/2/3 is the "exception" stack pointer for that mode. When an exception, fault, or interrupt happens, the processor switches to this stack (and possibly switches EL). Your exception handler code should do what it needs to save the exception state and get itself onto SP_EL0 to complete handling the exception.
That is, your EL0 user code, your EL1 kernel code, your EL2 hypervisor, and your EL3 monitor should all be using SP_EL0 except in the early stages of their exception handlers. If you were to take a nested exception while on SP_ELx (non-zero), you could blow over your stack, ELR, FAR, etc. which is why you want to save these and get back to SP_EL0 as soon as you can.

Method code too large in Groovy & Grails?

2014-06-17 11:22:18,622 [Thread-11] ERROR compiler.GrailsProjectWatcher - Compilation Error: startup failed:
General error during class generation: Method code too large!
What is the solution? Only 4-5 line code hide and restart then fully run in successfully, the bootStrap file size is 149k. When I comment or delete 4-5 line code, it will be run without no error!
The Java Virtual Machine has a limitation that methods cannot be larger than 64k (65536 bytes). This post describes this limitation in details.
The best way to overcome this issue is simply splitting your large method into smaller ones, which is generally a good practice.
Also notice that the JVM JIT compiler will not compile methods larger than 8K. You can however change this behavior using the -XX:-DontCompileHugeMethods option.
The problem: Just got in Jenkins pipeline the following exception error: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
General error during class generation: Method code too large!
java.lang.RuntimeException: Method code too large!
Explanation : The root cause related to 64kB limit of byte code of a single method. Java Virtual Machine has implicit limitations on class that there are mandatory to be followed and restricted according to performance and the language limitiation - such as: size of an operand stack in frame, length of fields and method names, number of methods may be declared in class etc... you can follow this "check list" on Oracle JVM documentation. You got the method size limitation on this scenario.
Solution: In order to solve this issue, just separate the class methods into shared-lib library or sub internal / external class (such as Utils.Groovy for example) and import that library in your main class. In general a code should be readable , lean and high level. if it's too long export the functionality use object oriented architecture and you would earn readable and maintainable code as well.

Grails breaks after telling me that files exist in the views folder when they actually do not?

When I try to scaffold new controller and views for some domain class, Grails keeps telling me that there exists files in grails-app/views/domainName/{create.gsp, edit.gsp, list.gsp, show.gsp}.
However I have repeatedly deleted the whole domainName dir from the views location many times.
What is Grails referring to? is this related to caching somehow?
Even if I ignore this abnormality and tell grails to overwrite the files even though they dont exist, when i lunch the application, navigate to that controller and click create new domainItem - the browser with think for a minute after which Grails spits the following exception:
Error executing script RunApp: GC overhead limit exceeded
2011-11-02 10:22:50,484 [ContainerBackgroundProcessor[StandardEngine[Tomcat]]] ERROR core.ContainerBase - Sanitizing stacktrace:
- Exception invoking periodic operation:
java.lang.OutOfMemoryError: GC overhead limit exceeded
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:116)
at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1337)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1601)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1590)
at java.lang.Thread.run(Thread.java:722)
The app works fine with any other domain class.
Things I have tried:
1. delete the problematic domain along with the controller and views, delete the unit test, delete the generated class files. basically eradicate any known-to-me trace of that domain class
2. run 'clean'
3. make a new domain with the same name
4. scaffold the views and controller for it again (at which point grails ask me if I want to override the views?!)
5. restart STS
6. restart computer
so the problem is in this line:
time(range:0L..86400000L) //24h in milliseconds
which I still dont understand why. the variable time is of type long
The following two variations also result in memory overflow:
time(range:0..86400000L)
time(range:0..86400000)

Getting source code information from groovy stack trace

When exception generated I want to show some additional information (source code) for particular exception. But grails have very hairy exceptions (it's all about groovy dynamic nature). It's my problem where to get and how to display source code. All I need is file/line information.
So... Is there any possibility to get file and line where exception were generated in grails/groovy?
Hmm, you aren't already getting this? All my grails exceptions have file/line information in them by default. The only difficulty is that if the exception is in a closure, it doesn't show the actual closure name. Could you post a sample stacktrace?

Resources