MenoData / Time4J

Advanced date, time and interval library for Java with sun/moon-astronomy and calendars like Chinese, Coptic, Ethiopian, French Republican, Hebrew, Hijri, Historic Christian, Indian National, Japanese, Julian, Korean, Minguo, Persian, Thai, Vietnamese
GNU Lesser General Public License v2.1
438 stars 64 forks source link

error using 5.9 with jdk 1.8 #964

Closed olamy closed 2 years ago

olamy commented 2 years ago

When using 5.9 release with jdk 1.8. There is the following error:

java.lang.NoSuchMethodError: java.lang.Math.floorDiv(JI)J
    at net.time4j.base.GregorianMath.toMJD(GregorianMath.java:513)
    at net.time4j.Moment.<clinit>(Moment.java:388)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:348)
    at net.time4j.engine.Chronology.lookup(Chronology.java:417)
    at net.time4j.format.expert.ChronoFormatter.setUp(ChronoFormatter.java:3090)
    at net.time4j.format.expert.ChronoFormatter.rfc1123(ChronoFormatter.java:3353)
    at net.time4j.format.expert.ChronoFormatter.<clinit>(ChronoFormatter.java:232)

You have probably release the jars using java9+. Too avoid such issues you should add the release following configuration for m-compiler-p <release>8</release>

MenoData commented 2 years ago

Thank you very much for your contribution. I see now the problem. Indeed, I had used the newest JDK for build, but the method Math.floorDiv(long, int) only exists since Java 9, different from the overloaded methods Math.floorDiv(long, long) or Math.floorDiv(int, int).

See also this SO-post.

Just a curious question before I merge your contribution: Do you absolutely need Java 8 as target, or can you also use a future version of Time4J starting with at least Java 9 (for better module support)?

Anyway, Time4J-v5.9.1 will contain your fix and remain compatible with Java 8.

olamy commented 2 years ago

Thank you very much for your contribution. I see now the problem. Indeed, I had used the newest JDK for build, but the method Math.floorDiv(long, int) only exists since Java 9, different from the overloaded methods Math.floorDiv(long, long) or Math.floorDiv(int, int).

See also this SO-post.

I know this as I'm maintaining the m-compiler-p ;)

I made the change very simple as it looks you are using java 11 locally. for sure the best option is to use a profile etc... (but only if you keep using java8 for building your project). You can make java 11 mandatory for building but still targeting java 8 using the release flag of the compiler. It's really up2u :)

Just a curious question before I merge your contribution: Do you absolutely need Java 8 as target, or can you also use a future version of Time4J starting with at least Java 9 (for better module support)?

Anyway, Time4J-v5.9.1 will contain your fix and remain compatible with Java 8.

I was looking at this because of investigating this one https://github.com/jenkinsci/ldap-plugin/pull/135 to fix it I will need java 8 as Jenkins is still java 8 but only for few weeks so it doesn't matter really :) again it's up2u to make your library java11 mandatory. My 2 cts: do you need some java11 only code in your library? if not just target java8.

MenoData commented 2 years ago

Thanks again for your contribution and detailed reply.