tycho icon indicating copy to clipboard operation
tycho copied to clipboard

Reproduce JavaSE-17 issues on JDK 11

Open aumann opened this issue 2 years ago • 22 comments

This is only reproducing issue #950 when run locally with JAVA_HOME set to a JDK-11.

If you point me to a similar test I can try and complete the test setup at least (i.e. prepare for this test running, and running on Java 11).

aumann avatar May 07 '22 15:05 aumann

As mentioned in the discussion, this story requires a toolchains.xml to define where to find Java 17. The test would need to include that.

mickaelistria avatar May 07 '22 19:05 mickaelistria

where would I the jdkHome in the toolchains.xml point to? Locally I have this one, but the path will obviously not be valid for CI:

<?xml version="1.0" encoding="UTF8"?>
<toolchains>
  <toolchain>
    <type>jdk</type>
    <provides>
      <version>1.8</version>
      <id>JavaSE-1.8</id>
    </provides>
    <configuration>
      <jdkHome>/usr/lib/jvm/java-8-openjdk-amd64</jdkHome>
      <bootClassPath>
        <includes>
          <include>jre/lib/*</include>
          <include>jre/lib/ext/*</include>
          <include>jre/lib/endorsed/*</include>
        </includes>
      </bootClassPath>
    </configuration>
  </toolchain>
  <toolchain>
    <type>jdk</type>
    <provides>
      <version>17</version>
      <id>JavaSE-17</id>
    </provides>
    <configuration>
      <jdkHome>/home/aleaum/.sdkman/candidates/java/17.0.3-tem</jdkHome>
    </configuration>
  </toolchain>
</toolchains>

I'll try and find one in the other integration tests, if there are obvious other examples I hope I find them...

aumann avatar May 07 '22 19:05 aumann

I forgot to re-ask / mention I did not find a similar toolchains setup. Can someone point me to a similar test (or mention the path I need to put into the toolchains file?)

aumann avatar May 19 '22 14:05 aumann

Unit Test Results

0 files  0 suites   0s :stopwatch: 0 tests 0 :heavy_check_mark: 0 :zzz: 0 :x:

Results for commit d734cf21.

github-actions[bot] avatar Jun 02 '22 12:06 github-actions[bot]

where would I the jdkHome in the toolchains.xml point to? Locally I have this one, but the path will obviously not be valid for CI:

We use this approach at work:

  • check in a complete maven toolchains.xml with the project, where the paths are just properties
  • inject the actual path of the JDK from the CI system into the file content via some groovy code (in the Jenkinsfile)
  • use --global-toolchains option in the maven call to use the modified file

I'm not sure what would be the best way to inject/overwrite the JDK path here with the Github actions. If all else fails, one could still write such a toolchains file via antcall or similar from within the build.

Bananeweizen avatar Jun 03 '22 07:06 Bananeweizen

I'm not sure what would be the best way to inject/overwrite the JDK path here with the Github actions

Toolchains support property expansion, so there should be no need to modify the file itself and one can simply use ENV variables like here:

https://github.com/eclipse/tycho/blob/master/toolchains-gh.xml

laeubi avatar Jun 03 '22 07:06 laeubi

@akurtakov as you are dedicated to Java 17 support, can you take a look here what might be the problem?

laeubi avatar Jun 15 '22 04:06 laeubi

I forgot to re-ask / mention I did not find a similar toolchains setup. Can someone point me to a similar test (or mention the path I need to put into the toolchains file?)

Tycho GH actions already use the following toolchain: https://github.com/eclipse/tycho/blob/master/toolchains-gh.xml

laeubi avatar Jun 15 '22 04:06 laeubi

I honestly don't understand what the issue is here. Toolchain for Java-17 must be setup in order to compile using Java 17 APIs while running on Java 11 . Tycho itself will require Java 17 (#983) soon so I strongly advice switching the JVM driving the build to Java 17 and configure Java 11 in your toolchain. Announced at https://www.eclipse.org/lists/tycho-dev/msg02086.html and https://www.eclipse.org/lists/cross-project-issues-dev/msg19262.html .

akurtakov avatar Jun 15 '22 07:06 akurtakov

@akurtakov as far as I understand the issue arise when tycho is running on a lower JVM (11 here) but code should be compiled with a higher one (17 here). Maybe @aumann can give better details.

laeubi avatar Jun 15 '22 07:06 laeubi

/rebase

laeubi avatar Jun 15 '22 07:06 laeubi

@akurtakov as far as I understand the issue arise when tycho is running on a lower JVM (11 here) but code should be compiled with a higher one (17 here). Maybe @aumann can give better details.

Yes, exactly.

I know that this can be worked around - still I expected this to work, and @mickaelistria confirmed my expectations here: https://github.com/eclipse/tycho/discussions/938#discussioncomment-2691855 - that's why I've openend the issue.

aumann avatar Jun 15 '22 09:06 aumann

So you are running Tycho with Java 11, have toolchains configuration for Java17, tycho uses Java 17 and build fails ?

akurtakov avatar Jun 15 '22 09:06 akurtakov

Just to be sure, does it happen with Tycho 3.0.0-SNAPSHOT? I ask that question as if you're using old tycho version it will come with old ecj/jdt.core version which may not support Java 17 constructs yet.

akurtakov avatar Jun 15 '22 09:06 akurtakov

So you are running Tycho with Java 11, have toolchains configuration for Java17, tycho uses Java 17 and build fails ?

Yes, that's right.

Just to be sure, does it happen with Tycho 3.0.0-SNAPSHOT? I ask that question as if you're using old tycho version it will come with old ecj/jdt.core version which may not support Java 17 constructs yet.

I can try today in the evening - until now, I've only tested upto 2.7.2

aumann avatar Jun 15 '22 09:06 aumann

/rebase

laeubi avatar Jun 24 '22 11:06 laeubi

@aumann can you please give exact steps to reproduce:

  1. What JDK use for running mvn (e.g. out put from mvn -V)
  2. What JDKs are in your toolchain.xml
  3. in what folder do sou issue what exact mvn command and what is the error you see.
  4. What exact Tycho version is used.

laeubi avatar Jun 24 '22 11:06 laeubi

@aumann can you please give exact steps to reproduce:

1. What JDK use for running `mvn` (e.g. out put from `mvn -V`)
➜  compiler.jdt.bree.java17 git:(reproduceBree17On11Bug) ✗ mvn -version
Apache Maven 3.8.6 (84538c9988a25aec085021c365c560670ad80f63)
Maven home: /home/aleaum/.sdkman/candidates/maven/current
Java version: 11.0.15, vendor: Eclipse Adoptium, runtime: /home/aleaum/.sdkman/candidates/java/11.0.15-tem
Default locale: de_DE, platform encoding: UTF-8
OS name: "linux", version: "5.4.0-121-generic", arch: "amd64", family: "unix"

2. What JDKs are in your `toolchain.xml`
➜  compiler.jdt.bree.java17 git:(reproduceBree17On11Bug) ✗ cat ~/.m2/toolchains.xml 
<?xml version="1.0" encoding="UTF8"?>
<toolchains>
  <toolchain>
    <type>jdk</type>
    <provides>
      <version>1.8</version>
      <id>JavaSE-1.8</id>
    </provides>
    <configuration>
      <jdkHome>/usr/lib/jvm/java-8-openjdk-amd64</jdkHome>
      <bootClassPath>
        <includes>
          <include>jre/lib/*</include>
          <include>jre/lib/ext/*</include>
          <include>jre/lib/endorsed/*</include>
        </includes>
      </bootClassPath>
    </configuration>
  </toolchain>
  <toolchain>
    <type>jdk</type>
    <provides>
      <version>17</version>
      <id>JavaSE-17</id>
    </provides>
    <configuration>
      <jdkHome>/home/aleaum/.sdkman/candidates/java/17.0.3-tem</jdkHome>
    </configuration>
  </toolchain>
</toolchains>

3. in what folder do sou issue what exact `mvn` command and what is the error you see.

I'm using the project as committed here, and execute maven from the it-project root:

➜  compiler.jdt.bree.java17 git:(reproduceBree17On11Bug) ✗ pwd
/home/aleaum/Develop/oomph-eclipse/tycho-master/git/org.eclipse.tycho/tycho-its/projects/compiler.jdt.bree.java17

➜  compiler.jdt.bree.java17 git:(reproduceBree17On11Bug) ✗ mvn clean compile
Full output
➜  compiler.jdt.bree.java17 git:(reproduceBree17On11Bug) ✗ mvn clean compile   
[INFO] Scanning for projects...
[WARNING] No explicit target runtime environment configuration. Build is platform dependent.
[INFO] Resolving dependencies of MavenProject: tycho-its-project.compiler.jdt.bree.java17:bundle:1.0.0 @ /home/aleaum/Develop/oomph-eclipse/tycho-master/git/org.eclipse.tycho/tycho-its/projects/compiler.jdt.bree.java17/bundle/pom.xml
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO] 
[INFO] parent                                                             [pom]
[INFO] bundle                                                  [eclipse-plugin]
[INFO] 
[INFO] ---------< tycho-its-project.compiler.jdt.bree.java17:parent >----------
[INFO] Building parent 0.0.1-SNAPSHOT                                     [1/2]
[INFO] --------------------------------[ pom ]---------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ parent ---
[INFO] 
[INFO] ---------< tycho-its-project.compiler.jdt.bree.java17:bundle >----------
[INFO] Building bundle 1.0.0                                              [2/2]
[INFO] ---------------------------[ eclipse-plugin ]---------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ bundle ---
[INFO] Deleting /home/aleaum/Develop/oomph-eclipse/tycho-master/git/org.eclipse.tycho/tycho-its/projects/compiler.jdt.bree.java17/bundle/target
[INFO] 
[INFO] --- tycho-packaging-plugin:2.7.2:build-qualifier (default-build-qualifier) @ bundle ---
[INFO] The project's OSGi version is 1.0.0
[INFO] 
[INFO] --- tycho-packaging-plugin:2.7.2:validate-id (default-validate-id) @ bundle ---
[INFO] 
[INFO] --- tycho-packaging-plugin:2.7.2:validate-version (default-validate-version) @ bundle ---
[INFO] 
[INFO] --- target-platform-configuration:2.7.2:target-platform (default-target-platform) @ bundle ---
[INFO] 
[INFO] --- tycho-compiler-plugin:2.7.2:validate-classpath (default-validate-classpath) @ bundle ---
[INFO] Resolving class path of bundle...
[INFO] 
[INFO] --- maven-resources-plugin:2.4.3:resources (default-resources) @ bundle ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /home/aleaum/Develop/oomph-eclipse/tycho-master/git/org.eclipse.tycho/tycho-its/projects/compiler.jdt.bree.java17/bundle/src/main/resources
[INFO] 
[INFO] --- tycho-compiler-plugin:2.7.2:compile (default-compile) @ bundle ---
[INFO] Compiling 1 source file to /home/aleaum/Develop/oomph-eclipse/tycho-master/git/org.eclipse.tycho/tycho-its/projects/compiler.jdt.bree.java17/bundle/target/classes
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] 
[INFO] parent 0.0.1-SNAPSHOT .............................. SUCCESS [  0.033 s]
[INFO] bundle 1.0.0 ....................................... FAILURE [  0.983 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  2.908 s
[INFO] Finished at: 2022-06-24T20:41:14+02:00
[INFO] ------------------------------------------------------------------------


> 4. What exact Tycho version is used.

2.7.2

aumann avatar Jun 24 '22 18:06 aumann

@laeubi is this one fixed now?

akurtakov avatar Jul 19 '22 05:07 akurtakov

@aumann Would you please sign https://www.eclipse.org/legal/ECA.php ? Without it we can not accept patch from you.

akurtakov avatar Jul 19 '22 05:07 akurtakov

I don't think so @aumann has provided steps to reproduce but I can't tell if this is an issue in Tycho or EJC ...

laeubi avatar Jul 19 '22 05:07 laeubi

@aumann Would you please sign https://www.eclipse.org/legal/ECA.php ? Without it we can not accept patch from you.

I've re-signed with the correct mail address.

aumann avatar Jul 21 '22 11:07 aumann

Test Results

324 files  324 suites   2h 20m 41s :stopwatch: 290 tests 286 :heavy_check_mark: 4 :zzz: 0 :x: 580 runs  571 :heavy_check_mark: 9 :zzz: 0 :x:

Results for commit 2fe1a595.

:recycle: This comment has been updated with latest results.

github-actions[bot] avatar Aug 29 '22 21:08 github-actions[bot]

@akurtakov any chance we can finish this for 3.0? Is this an issue with Tycho or with EJC?

laeubi avatar Sep 15 '22 13:09 laeubi

Well, it's probably time to move Tycho to require Java 17 actually. The jdt bug that forced this revert is supposed to be fixed now.

akurtakov avatar Sep 15 '22 14:09 akurtakov

Well, it's probably time to move Tycho to require Java 17 actually. The jdt bug that forced this revert is supposed to be fixed now.

I think we should first fix all Java 17 related issue to be sure people can still compile for older versions and never versions...

laeubi avatar Sep 15 '22 14:09 laeubi

This one happens when running on Java 11 but targetting Java 17 which would no longer be relevant if Tycho requires Java 17 as runtime JVM.

akurtakov avatar Sep 15 '22 14:09 akurtakov

This one happens when running on Java 11 but targetting Java 17 which would no longer be relevant if Tycho requires Java 17 as runtime JVM.

But Java 19 and so on will be, so this should be fixed first before we move on to a never JVM that possible hides an issue with compiling with higher JVMs thath those the Tycho build is run with.

laeubi avatar Sep 15 '22 14:09 laeubi

I highly doubt that is true (esp. without a reproducer). My look into jdt.core points to isJRE12Plus as the most likely cause so if requiring Java 17 I think this bug will not be hidden but the combination it happens to be no longer supported.

akurtakov avatar Sep 15 '22 14:09 akurtakov

So if its a JDT Bug we should report it there.

laeubi avatar Sep 15 '22 14:09 laeubi