AspectJ works with Java 7? - java

I instaled AspectJ in Eclipse (AJDT), but the specific methods of Java 7 are marked as errors when I use the AspectJ project.
My doubt is if AspectJ works with Java 7 or this is an issue with Eclipse or AJDT.
EDIT: The problem is AJDT that doesn't support AspectJ for Java 7 yet. There is some IDE to AspectJ that supports?

You need AspectJ 1.7.0 M1 (or higher) for Java 7 compatibility. http://www.eclipse.org/aspectj/doc/released/README-170.html

From the aspectJ webpage:
"AspectJ 1.7.0.M1 is now available for download. See the readme for more information. This is our first Java7 compiler based milestone." so it should work. Did you search at all?

You should install the snapshot version of the AspectJ Development Tools (AJDT) from this update site:
http://download.eclipse.org/tools/ajdt/37/dev/update

Related

AspectJ compatibility

We are using an external library that has been compile-time weaved with AspectJ 1.9.6. We would like to use Java 17 and thus need at least AspectJ 1.9.8 to compile-time weave our own code. During runtime we have a shared classpath (WEB-INF/lib) for both our classes and the external library. Is it save to provide an AspectJ Runtime Version 1.9.8 here? Can we even go further and use the latest version of the runtime (which is then also used to compile-time weave our code) --> 1.9.9.1?
Basically: Is the compile-time weaved code of our external dependency compatible with those higher runtimes?
(I am aware of the statements noted at: https://www.eclipse.org/aspectj/doc/released/devguide/compatibility.html)
Please just use the latest AspectJ version, as of today 1.9.9.1, see
https://github.com/eclipse/org.aspectj/blob/master/docs/dist/doc/JavaVersionCompatibility.md
Semi off topic: Actually, I could release AspectJ 1.9.19 (in the future, the minor-minor will mirror the latest supported Java version) anytime, if it was not for some unfixed Eclipse Java compiler bugs concerning Java 19 preview features, which I would like to see fixed upstream before releasing the next AspectJ version. But you do not need Java 19 language features, so you are fine with 1.9.9.1.

Should I update aspectJ when migrating from java 6 to 8?

My AspectJ version is still on 1.6.8 running on a Java 6 Project.
Suppose I migrate to Java 8.
Should I update the AspectJ version? Is it mandatory?
If yes, are there things I have to be aware of?
This question was flagged as a duplicate before, but I voted to re-open it because the other question was about AspectJ Maven Plugin compatibility with Java 8 and the answers there do not explain anything explicitly in order to answer this question.
AspectJ 1.6.x was published for Java 6, just as AspectJ 1.7.x was for Java 7, 1.8.x for Java 8, 1.9.x for Java 9-13 at the date of writing this.
Having said that, you should consider the following:
If you would just use the Java 8 compiler but compile your Java 6 code with target 1.6, in theory you could continue using AspectJ 1.6.8 (e.g. runtime) too.
But as soon as you compile with target 1.8 and/or use Java 8 language features, you have to use AspectJ 1.8.x (I recommend the latest version) at least in order to make the AspectJ compiler and weaver understand those language features and the byte code at all.
I would even recommend to use the latest 1.9.x version, it is backward compatible and might have a few bug fixes missing in 1.8.x. But that is an optional choice. I always use the latest AspectJ version even in Java 8.

Upgrading Project from JDK 6 to JDK 8

My current project is built on Java 6. I'm thinking of upgrading it to Java 8.
Here is the details of the build.properties
xdoclet.home=D:/**/xdoclet-1.2.3
jboss.deploy.dir=D:/**/jboss-6.1.0.Final
application.dir=D:/**/**/cal
middlegen.home=D:/**/middlegen-2.0-b1
compiler.home=C:/Program Files/Java/jdk1.6.0_24/bin/javac .
I've tried building the project on JDK 8 and it is building successfully.
I know that I have to upgrade every libraries so that it can work with JDK 8.
How can I make sure about the dependencies to be correct as there are so many jars? And also Do I have to change my Jboss Application Server to Wildfly Application Server as Jboss AS 7 doesn't support JDK 8?
Please suggest how to approach. Any help appreciated.
And also let me know if it's better to build the project from Scratch in JDK 8 than upgrading it to JDK 8.
1) If you need to use jdk8 than you have to switch too the newer jboss.
2) It is not required to updated all jar's since jdk8 can run older jars
it there is no compatibility problem.
3) If you already have an large probject it is faster to keep it.
4) You can review your code and use the new java 8 features like "<>" and "try()"
For more qualified answer your question is to unspecific.
I would like to suggest you to update JBOSS 6 to wildfly 8 if there is a change required for the updation of JDK 6 to JDK 8.
But there is some other way!!! you can run your JBOSS 6 externally and add the the project.war file in JBOSS>>standalone>>deployment.
For Upgrade of JDK 8,i would suggest to go through JDK 8 feature and see where you can implement the new feature of java in your source code and have a mock testing class for the same.Make sure you have a mock project as it is the good practice for the enhancement of the project.

Maven: compile Java 7 with JDK8

I need to ensure one thing before doing it, so I have not yet tested the solution I'll propose.
I have a Jenkins on which one project compiles with a JDK 7 with target Java 7. I have a new project written in Java 8, and I'd like to add it to my Jenkinsfor it to build it too.
As a consequence, I need to install a JDK 8 on the machine. I know we can specify the java compiler version in the pom of each project, but I'm fearing this: once I have installed JDK 8, will my Java 7 project still be able to compile with that JDK 8? Should I have the two JDK installed on the machine, and have a configuration for each project to be able to locate its own JDK? Or will my Java 7 project be able to compile in Java 7 using the JDK 8 ?
Thanks for any help.
As stated in comments, it is possible to install multiple JDKs on Jenkins machine (see this answer as an example) and to configure each job to use a specific one.
Besides, you could perfectly compile your Java7 project using Java8 JDK. However, I advise you not to do that. indeed, if backwards compatibility is enforced at language level, you may find some APIs in which bugs you were unaware of, but the libs you use already knew, have been fixed, creating some weird behaviours. As a consequence, your Java7 application would compile using Java8 JDK, but expose bugs at runtime. And it would be the hell of a nightmare to solve those bugs (believe me, my friend, I've met that kind of horrors in a previous common company).
You can use multiple jdk on your machine, but remember to use specific jdk for specific project. Configure POM file of your project carefully if you have installed multiple jdk. Compiling Source Using Maven
Or you can change JAVA_HOME in the Build Environment section of the job configuration you can set environment variables for the job. Although, you can use multiple JDKs but its not a good practice to in CI/CD. Use specific machines with specific configurations.

Java Version for PMD, Findbugs and Checkstyle

I need to use PMD, Findbugs and Checkstyle in Eclipse for a Development project. Is Java 6 enough to use these tools? or I need java 7?
Java 6 is enough (Even 5 will work).
Everything should work for
1.5>=Java<1.8
Findbugs
FindBugs requires JRE (or JDK) 1.5.0 or later to run. However, it can
analyze programs compiled for any version of Java, from 1.0 to 1.7.
Some classfiles compiled for Java 1.8 give FindBugs problems, the next
major release of FindBugs will handle Java 1.8 classfiles.
http://findbugs.sourceforge.net/
Checkstyle
Added Java 7 support to the grammar. Thanks to Dinesh Bolkensteyn for
patch #3403265
http://checkstyle.sourceforge.net/releasenotes.html
PMD
•2011-11-04 PMD 4.3 (download): ◦Add support for Java 7 grammer -
thanks to Dinesh Bolkensteyn and SonarSource
http://pmd.sourceforge.net/pmd-4.3/
Notice latest PMD requires Java 7/8
running PMD only requires Java 7 (or Java 8 for Apex and the Designer).

Categories

Resources