How to start aspectj loadtime weaver agent without restarting jvm / how to start loadtime weaver in code? - aop

Is there any way to start the AspectJ loadtime weaver during the application is running? Means without restarting the JVM and adding -javaagent:... ?
I tried https://stackoverflow.com/a/35775792/3880225 but without any success.

Yes, you can do that, I implemented this capability myself for AspectJ and it was included since version 1.8.7, see release notes for an example.
But please note that weaving will only work for classes loaded after you have activated the weaver.

Related

How can I debug a project in IntelliJ and provide a context xml file?

I have written a subclass of Jetty's WebAppClassLoader. I wrote a context XML file to configure the web app context with my classloader, enabled the ext module, and added my classloaders to $JETTY_BASE/lib/ext. This all works when I run my program outside of IntelliJ.
What I need to do though is run my program within IntelliJ. I have it working with the Jetty maven plugin, but this is not ideal because it forces the maven build to run each time I want to start the program which is quite slow.
As far as I can tell the only thing preventing this from working is that I can see no way to tell Jetty about my context XML file when I run it through the IntelliJ Jetty Run/Debug configuration.
Is there a way around this problem?

Force IntelliJ to rerun anntoation processors?

Is there any way to rerun annotation processors without rebuilding the entire project?
I'm developing an annotation processor which is used in project that takes ~ 10 minutes to build from scratch and it's a bit painful to wait 10 mins to test a change...
General Aspect
This sounds like you don't have a proper testing approach for your annotation processor.
If you do testing always in an integrated environment, you will always have the problem of long running tests. This applys to any test environment that depens on heavy task.
So, my generall advice would be to write lightwight unit tests to check you code is working as expected. That's a general advice I can give you.
This article https://blog.jooq.org/2018/12/07/how-to-unit-test-your-annotation-processor-using-joor/ from Lukas Eder - the founder of JOOQ and that uses java annotation processors as well - is about unit testing java annotation processors.
Only Run Annotation Processors
Intellij Idea
AFAIK there is no way to do this.
Maven
If your project runs on maven, you can trigger annotation processors by just execution the generate-sources phase.
Annotation processor can not be run without the compiler.
If you are not using Maven or Gradle to build the project but is using the IDE's build, invoke the Build | Build Project action. This way IDE will perform an incremental build that will build only changed classes.

testing_sm setting of intelliJ 2017

There was testing_sm setting which exist in previous version of intelliJ and used to make TestNG run in remote mode. It is not available now in 2017.1.4 version.
Anyone aware of why it is removed and what is the new setting to run test by Remote TestNG runner in place of default TestNG runner.
This was an internal setting during the migration to the new protocol. As there were no problems reported after the migration, the setting is now removed as obsolete. The old protocol has caused compatibility issues.

IntelliJ Datanucleus Enhancer plugin not working

The project I'm developing uses Datanucleus 2.0.3, so I'm using those libraries for enhancement (plugin is configured to use the module dependencies as well). IntelliJ version 12.0.1 on a Ubuntu 12.4 machine. I know the 2.0.3 is ancient history but upgrading it at least now is not an option for me.
From gradle all works fine. I imported by project to IntelliJ and when I ran the tests from junit I got the usual ClassNotPersistenceCapableException so I recalled I need a plugin for this.
I installed the newest plugin (tried both the beta and the last stable version) and configured the plugin to enhance my this one module. I chose JDO and applied, it discovered all the classes annotated for persistence, I rebuilt the whole project, ran the tests again and the same error occurs.
some things I've noticed / checked:
- the Enchaner is ticked in "Build / Datanucleus Enhancer"
- looked for multiple datanucleus jars, but there is only one
- haven't seen any message in IntelliJ in the Event Log saying is has done enhancing (the gradle enhancer logs such a message)
- haven't seen any error messages in IntelliJ saying enhancement failed, I also didn't find any log files outside IntelliJ (should there be any?)
- when I manually added the gradle built classes at the top of the classpath for the test the tests passed - but this is no good
- the module has the following datanucleus 2.0.3 jars on it's classpath: datanucleus-core, datanucleus-enhancer, datanucleus-connectionpool, datanucleus-rdbms and the asm-3.1.jar (the dependencies say it's 3.0-4.0 so this one should fit)
I have no idea why it sees the classes but doesn't enhance them, or maybe it does try and silently fail ... but then I don't know how to diagnose the problem
No other ideas come to my mind, please advise what to check or what to try.

Maven Chronos plugin

I have a problem with Maven Chronos plugin. Is it possible to tell plugin a mask for name of jmx files to execute?
Thx
It is still not possible to use the chronos plugin to proces files based on a mask. It is possible to select a folder containing tests (.jmx-files), which should be good enough for most cases.
I have a problem with Maven Chronos plugin. Is it possible to tell plugin a mask for name of jmx files to execute?
No, this is currently not supported, the chronos plugin is limited to process only one .jmx/.jtl that you must "hard code" in the POM. But an issue has been logged as MOJO-1460 to enhance the plugin and make it able to process multiple scenario. It's not exactly what you're asking for but it might provide a decent alternative (and there is a patch attached).
Do you know if I can run multiple jmeter tests with any other plugin?
I double checked and it appears that the maven-jmeter-plugin can do that (and even supports includes and excludes if required).
A more recent version of the plugin (using JMeter 2.3) was hosted on Google's code and can now be found on github.