[2.4.6 Scala] Any way to compile with javac's -parameter option?

132 views
Skip to first unread message

Sean McClelland

unread,
Jan 6, 2016, 8:21:36 PM1/6/16
to play-framework
Hi,

I am using a library (RethinkDB) that tries to use the Java 8 parameters compiler option to convert a Map<String,Object> to whatever class you specify. In my case, I am using Scala case classes. In order for this to work, the code needs to be compiled with the -parameters flag when you call javac. Since I am using Scala with Play, does anyone know how to get it to compile with that flag enabled, or if this is even possible? Ideally, I'd love to configure it in the build.sbt and not have to use environment variables.

Thanks,

-Sean

Matthias Kurz

unread,
Jan 6, 2016, 8:36:40 PM1/6/16
to play-framework
Read here:

Try this (Didn't test myself):
javacOptions += "-parameters"

Regards,
Matthias

Sean McClelland

unread,
Jan 7, 2016, 12:06:12 PM1/7/16
to play-framework
Hi Matthias,

Thanks for posting this. As far as I can tell, javacOptions only applies when compiling the actual java sources. Since I am trying to compile a scala case class, I think I would have to use scalacOptions and go through the scala compiler. The scalac compiler doesn't have a -parameters flag and I haven't been able to find an equivalent yet. (I'm using Scala 2.11.7 right now). Anyway I did make a run at using javacOptions yesterday but it didn't work.

Thanks,

-Sean

Matthias Kurz

unread,
Jan 7, 2016, 12:44:12 PM1/7/16
to play-framework
Just found this:

Looks like you have to wait for Scala 2.12(-M4) :(

I read somewhere that it would be already possible with Scala reflection, but as you are using a 3rd party lib (RethinkDB) that's probably not an option.

Sean McClelland

unread,
Jan 7, 2016, 1:34:51 PM1/7/16
to play-framework
Hi Matthias,

Thanks so much for finding that information. I am glad to wait as I can get around it for the time being by letting the case classes be mutable.

-Sean
Reply all
Reply to author
Forward
0 new messages