j-easy / easy-random

The simple, stupid random Java beans/records generator
https://github.com/j-easy/easy-random/wiki
MIT License
1.61k stars 233 forks source link

Java 8 Dates support #41

Closed danielraczynski closed 8 years ago

danielraczynski commented 9 years ago

Since I'm getting the following error

Caused by: java.lang.NoSuchMethodException: java.time.ZonedDateTime.() at java.lang.Class.getConstructor0(Class.java:3082) at java.lang.Class.newInstance(Class.java:412) ... 10 more

I assume that Java 8 Dates types are not supported (the same applies for LocalDateTime and OffsetDateTime). I also saw that for deprecated Date type the library works fine.

Didn't have time to look at the code - but if this is the case than I advice you to add it to future release since this is the standard for Java 8.

fmbenhassine commented 9 years ago

Java 8 Date types are not supported yet. I'll add support for them in a future release.

Thank you for pointing out this issue.

Regards Mahmoud

fmbenhassine commented 8 years ago

Hi @danielraczynski ,

I added support for Java 8 Date and Time types in the 2.0.0-SNAPSHOT version (which I deployed to maven central repo). Use the following repo to get it:

<repository>
    <id>ossrh</id>
    <url>https://oss.sonatype.org/content/repositories/snapshots</url>
</repository>

It would be great if you could give it a try and tell me if it is ok for you. Thank you.

Kind regards Mahmoud

prietopa commented 8 years ago

Hi, i dont unferstand because in #28, you said that be carefull to use Java8 classes as Supplier class.

JMPrieto.

El lun., 21 de diciembre de 2015 22:35, Mahmoud Ben Hassine < notifications@github.com> escribió:

Hi @danielraczynski https://github.com/danielraczynski ,

I added support for Java 8 Date and Time types in the 2.0.0-SNAPSHOT version (which I deployed to maven central repo). Use the following repo to get it:

ossrh https://oss.sonatype.org/content/repositories/snapshots

It would be great if you could give it a try and tell me if it is ok for you. Thank you.

Kind regards Mahmoud

— Reply to this email directly or view it on GitHub https://github.com/benas/random-beans/issues/41#issuecomment-166431058.

fmbenhassine commented 8 years ago

Hello @prietopa

Only module random-beans-java8 requires Java 8, all other modules are Java 6 compatible. In #28, the goal is to add a method in the PopulatorBuilder that accepts a Supplier an adapt it to a Randomizer (which is a great idea), but this requires the random-beans module to use Java 8 which makes the library incompatible with Java 6..

The goal is to use Java 8 APIs only in the random-beans-java8 and keep using Java 6 compatible APIs in other modules.

Java is backward compatible, unless you use APIs introduced in a newer version.. I've tried to set compiler settings (-source 1.8, -target 1.6) to compile in version 8 and produce version 6 byte code, but this is not possible.

prietopa commented 8 years ago

understood!

JMPrieto

2015-12-22 11:01 GMT+01:00 Mahmoud Ben Hassine notifications@github.com:

Hello @prietopa https://github.com/prietopa

Only module random-beans-java8 requires Java 8, all other modules are Java 6 compatible. In #28 https://github.com/benas/random-beans/issues/28, the goal is to add a method in the PopulatorBuilder that accepts a Supplier an adapt it to a Randomizer (which is a great idea), but this requires the random-beans module to use Java 8 which makes the library incompatible with Java 6..

The goal is to use Java 8 APIs only in the random-beans-java8 and keep using Java 6 compatible APIs in other modules.

Java is backward compatible, unless you use APIs introduced in a newer version.. I've tried to set compiler settings (-source 1.8, -target 1.6) to compile in version 8 and produce version 6 byte code, but this is not possible.

— Reply to this email directly or view it on GitHub https://github.com/benas/random-beans/issues/41#issuecomment-166571372.

wheredevel commented 8 years ago

@benas I cloned the repo and noticed java8 module commented out. Uncommented, and it fails to build. What's missing? Perhaps I could help...

fmbenhassine commented 8 years ago

I decided to postpone Java 8 support to v3. See here: https://github.com/benas/random-beans/issues/49#issuecomment-174336657

This is because I was not able to make the code base compile with -source=1.8 and -target=1.7

Check the milestone of each issue to see in what release it is planned to land

fmbenhassine commented 8 years ago

Hi @danielraczynski

As discussed, Java 8 support has been postponed to v3 (the upcoming release). I have just published the 3.0.0-SNAPSHOT to maven central. This version includes support for JSR 310 types.

Here is a sample bean and a passing test. It would be great if you could give it a try and tell me if it is ok for you. Thank you.

Kind regards Mahmoud

fmbenhassine commented 8 years ago

hello @danielraczynski

If you have any problem with JSR 310 types support, please don't hesitate to file an issue.

Kind regards Mahmoud