What happens if the class supplied with our bank is added to the standard Java library?

I am currently thinking of adding a small part of JSR-310, javax.time.Duration to our library.

This currently works great.

But JSR-310 is planned to integrate in Java 8! When our Java 8 application javax.time.Duration , what happens if the standard library has a javax.time.Duration class and the same class sent with our jar file?

Will one of the classes be silently ignored? (Which one?) Will there be an error when the Java 8 VM tries to load a class from our library?

Are there any compatibility issues that I should be aware of?

+4
source share
2 answers

The JVM follows the class path to determine which class to load. If there are several, later classes are silently ignored.

For the class that is part of the JVM, they are part of the bootclass path, which runs before the start of the class path.

If there are no changes to the change in the API, you should not notice the difference, and your additional JAR will be effectively ignored using Java 8.

+6
source

Now this problem can be clarified.

The JDK1.8 classes will be in the java.time namespace and cannot be overridden (since they are deep in the Java core).

A backport project is available, which allows you to use a very similar API for JDK1.7. This uses the org.threeten.bp namespace. The idea is that moving forward in JDK1.8 will simply require renaming the package for the most part.

The javax.time namespace javax.time no longer used.

+1
source

Source: https://habr.com/ru/post/1432466/


All Articles