简体   繁体   中英

Is it viable to compile my project in java8 and then run it on java 17

I've read a few articles where in jdk 9, .* APIs have been removed. By removed does this mean they are completely removed from the jdk 9 or are they marked as deprecated?

Given the above statement, if in case the project is jdk 8 compiled, would it run without any issues on jdk 17? I am trying this for the first time, and had issues with tomcat not being able to support jdk 8 because of modularity changes.

I am planning to compile in jdk 8 and then run on jdk 17 until the entire project is jdk 17 compliant (By jdk 17 compliant, I meant to use the updated APIs rather the the existing deprecated APIs of jdk8).

Am I headed in the correct direction? or should I follow a different migration approach?

By removed does this mean they are completely removed from the jdk 9 or are they marked as deprecated?

Some have been just marked as deprecated. Others have been removed entirely., though generally not in Java 9. Most of the removals were done later, and some are still to occur. If you look at elements that are now annotated as @Deprecated , the annotation in some cases will formally indicate that the element is going to be removed.


Given the above statement, if in case the project is jdk 8 compiled, would it run without any issues on jdk 17

Not necessarily. Another thing that has happened is that access to "internal" Java SE APIs has been progressively closed off. So if your application uses these APIs, in Java 9 you got warnings, by Java 11 you got errors by default, and by Java 17 some access has become (I think) impossible.

So ... there can be "issues".

The correct approach to migration is simply to do it. And test, test, test until you have ironed out all of the problems.

Obviously, that means that you need a test server, and you need to use an automated test framework with unit tests, functional tests, UI tests and so on. But those are just good Software Engineering practices. You should already be following them.


Am I headed in the correct direction? or should I follow a different migration approach?

There is only one approach ... really. Test, test and test.

Before you start, it would be advisable to check all of your project's dependencies (libraries, etc) to see if they are supported on Java 17. Then update them to the correct (probably latest) versions.

Java 17 has only been released for a few weeks, so there is a good chance that some of your dependencies haven't caught up yet. If that is the case, it may be a better idea to target Java 11 LTS at this stage.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM