I am puzzled and annoyed some time now by being unable to use the new Java 10 feature “var” for local declarations within Cuba Studio 2018.3, which might indeed be an IntelliJ problem or me being unable to get all the myriads of JDK settings right. I started off with JDK 1.8 and switched to Java 12, but when compiling I always get following error:
error: cannot find symbol class var
for one of my screens:
@Subscribe
private void onInit(InitEvent event) {
var x = 5;
The intellisense does not actually mark this line as erroneous, but the compiler does.
As far as I can see, I am using the right compiler and changed all JDK settings to Version 12 and still, the compiler complains (I changed Project structure: Project SDK, Project language level, modules sources language level, Settings: Build, Execution Deployment -> Java compiler).
I am still unable to solve this really annoying phenomenon. I checked the actual build process and observed, that gradle uses some default compiler option parameters, that cannot be altered within Cuba Studio - language levels will be reset, whenever I refresh gradle settings resulting in following compiler options (only a small selection):
21:59:27.117 [DEBUG] [org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler] Compiler arguments: -source 1.8 -target 1.8 -d
Even changing compiler options in the build.gradle file has no effect, compiler options seem effectively hardcoded. Any further hints will be appreciated.
Thank you very much, that is very helpful. As I don’t have a JDK 11 installed yet, I need to prepare a fresh install and will report on my progress using your instructions then.
Unfortunately, there is no change after performing your instructions. Although I inserted the gradle operations, the language level stays at the Java 8 level (see attachment). It is always reset after refreshing the gradle settings.
Thank you very much, Yuriy,
that solved my problem finally. I guess I need to polish my gradle skills, sorry for being kind of ignorant regarding proper gradle usage