Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [tycho-user] Compiling for different Java versions with Maven



On Wed, Aug 5, 2020 at 5:20 PM Patrick Tasse <patrick.tasse@xxxxxxxxx> wrote:
Hi Mickael,

This is all new and confusing to me so I'm learning as I go along. I'll describe what I observe, not knowing what is relevant...

What do you mean by "the build was compiled for JavaSE-11 ? Aren't the class files not using the Java 1.8 class version?

This was on the Jenkins build running a Docker image. I do not know how to tell if the class files are compiled for 1.8 or 11 from the tycho-compiler-plugin on the remote machine.

You'll need to find a way to get access to some jar or .class file and use javap locally.

I had based myself on the fact that the log showed the test running with java.version=11.0.2 and the exception stack traces show "at java.base/java.lang.*" instead of "at java.lang.*". But I guess the test can run with JavaSE-11 even if classes are compiled for JavaSE-1.8, right?
I tried it locally from the command-line mvn and using 'javap -verbose' I can see that the class files are indeed version 52 (JavaSE-1.8).

OK, so i think it's fine: the version of Java that's used at execution or during dependency resolution doesn't really matter at compilation: the tycho-compiler-plugin, which is more or less a proxy to JDT's ECJ compiler, will set the target level according to the BREE, and that doesn't depend on the running java version nor on the actual one that's used for dependency resolution.

However, a better and more portable approach (with PDE) is to override the source/target levels in build.properties.

I'm not sure what that means. Is it each plug-in's build.properties file (we have 125 plug-ins)? What property would we need to set and how would we dynamically set it from the Jenkins/mvn parameters?

It's OK, just ignore that comment at the moment, as the current approach works: BREE controls the java target version -unless it's overridden somewhere else., and that's probably all that matters to you so you don't need extra customization. You should just remove your configuration of tycho-compiler-plugin regarding source/target/release levels, default behavior is likely to give better results with less worries.

HTH
--
Mickael Istria
Eclipse IDE developer, for Red Hat Developers

Back to the top