tycho icon indicating copy to clipboard operation
tycho copied to clipboard

"The type java.lang.Object cannot be resolved" when building multithreaded with OpenJDK17

Open eNBeWe opened this issue 3 years ago • 15 comments

Not sure if this is a Tycho issue, a maven issue, a jdk issue or a "we" issue. We have some project that we are currently building with OpenJDK 11, Maven 3.6.3 (probably) and Tycho 2.7.3. It works fine on my local machine as well as our jenkins agent, using -T1C parameter for maven.

Now we want to update to Java 17 and switched the docker build container to OpenJDK 17 and Maven 3.8.4 (still on Tycho 2.7.3). We kept everything else the same, so we still have the target set to 11. It compiles when I run single-threaded, but when I add -T1C to the build, it fails with lots of errors like

15:22:43  [ERROR] The type java.lang.Object cannot be resolved. It is indirectly referenced from required .class files
...
15:22:43  [ERROR] The type java.lang.String cannot be resolved. It is indirectly referenced from required .class files
...
15:22:43  [ERROR] The type java.lang.Class cannot be resolved. It is indirectly referenced from required .class files

So something seems to be broken somewhere, and I am unsure where. Build server should yield 96 possible threads when running with -T1C. The project has about 200 modules to be built. From the looks of the log it tries to build about 34 modules at once, when starting and then quickly fails.

What I tried:

  • I found #1071 and tried adding a toolchain.xml to the build. Didn't change anything
  • I cleaned all configurations in .classpath as well as Manifest.MF with regards to the BREE.
  • I got it to build ONCE with multiple threads, after cleaning the workspace entirely, but that was not reproducible. Might have been another parallel job on the machine, that changed the load-profile.

eNBeWe avatar Jul 01 '22 07:07 eNBeWe

@akurtakov this sounds similar to the problem I encountered you mentioned some issues also here: https://github.com/eclipse/tycho/issues/983 is it possible that the multi-treading problem of EJC?

laeubi avatar Jul 01 '22 07:07 laeubi

I see this too in multithreaded builds with Tycho 3 and Java 17: [ERROR] Failed to execute goal org.eclipse.tycho:tycho-compiler-plugin:3.0.0-SNAPSHOT:compile (default-compile) ... [ERROR] The type java.util.List cannot be resolved. It is indirectly referenced from required .class files or [ERROR] The type java.lang.String cannot be resolved. It is indirectly referenced from required .class files

Running single-threaded works fine

hd42 avatar Jul 01 '22 07:07 hd42

@akurtakov this sounds similar to the problem I encountered you mentioned some issues also here: #983 is it possible that the multi-treading problem of EJC?

Vacation. Please remind me in 2weeks.

akurtakov avatar Jul 01 '22 07:07 akurtakov

I tried setting the target and source level to 17 and for some reason it now worked (at least three times in a row). Still some more evaluation needed here, I think.

eNBeWe avatar Jul 01 '22 12:07 eNBeWe

Current reproducer:

  • git clone https://github.com/eclipse/tycho.git
  • cd tycho
  • Make sure java -version shows 17
  • mvn clean package -T16 -DskipTests

Using java 11 the build suceeds!

laeubi avatar Jul 01 '22 13:07 laeubi

I have opened an issue at JDT:

  • https://github.com/eclipse-jdt/eclipse.jdt.core/issues/183

laeubi avatar Jul 01 '22 13:07 laeubi

@akurtakov this sounds similar to the problem I encountered you mentioned some issues also here: #983 is it possible that the multi-treading problem of EJC?

Vacation. Please remind me in 2weeks.

I'm feeling free to do the reminding :)

col-panic avatar Jul 27 '22 08:07 col-panic

The issue is fixed in JDT but not released yet so tycho can not include it see

  • https://github.com/eclipse-jdt/eclipse.jdt.core/issues/241
  • https://github.com/eclipse-jdt/eclipse.jdt.core/issues/209

(but you can vote to get is released)

laeubi avatar Jul 27 '22 08:07 laeubi

@laeubi thank you - how do I vote? can't seem to find the resp. eclipse bug ids?!

col-panic avatar Jul 27 '22 08:07 col-panic

@laeubi thank you - how do I vote? can't seem to find the resp. eclipse bug ids?!

You can leave a comment or you can add a reaction, you can even ask on the mailinglist, or if you are member of an eclipse.company try to give more priority on even other channels as well :-)

laeubi avatar Jul 27 '22 08:07 laeubi

FWIW, given that release process is owned by a very few people who do not have extra resources to spend on build stuff, I'm skeptical any form of voting can change the current capability of Eclipse JDT to release on demand. Such flexibility requires more investment, so basically, more contributors. However, we recently changed things in Platform so that SNAPSHOTs can be produced on demand. If recent snapshots can fix the isue, then Tycho could use them and provide a fixed version. Request to produce new snapshots should be sent to [email protected] mailing-list.

mickaelistria avatar Jul 27 '22 11:07 mickaelistria

skeptical any form of voting can change the current capability of Eclipse JDT to release on demand.

At least it can show that there are more people interested and thus is is valuable to spend the extra time to perform a simple

mvn deploy:deploy-file -Dfile=<..>/org.eclipse.jdt.core-3.30.100-SNAPSHOT-batch-compiler.jar -DgroupId=org.eclipse.jdt -DartifactId=ecj -Dversion=3.30.100-RC1 -Dpackaging=jar

... no one asked for a full release deployment ...

laeubi avatar Jul 27 '22 12:07 laeubi

@laeubi Can I integrate this somehow for myself into my pom.xml? E.g. By directly using https://download.eclipse.org/releases/2022-09/202207151001/plugins/org.eclipse.jdt.core_3.30.100.v20220705-0752.jar somehow?

col-panic avatar Jul 29 '22 08:07 col-panic

Can I integrate this somehow for myself into my pom.xml

Yes see https://github.com/eclipse-jdt/eclipse.jdt.core/issues/241#issuecomment-1187635534

laeubi avatar Jul 29 '22 08:07 laeubi

Beside that I hope that some minor issues are fixed at ECJ in the next day and will simply deploy a fixed version to central under the Tycho group-id then...

laeubi avatar Jul 29 '22 08:07 laeubi

This should be fixed in the Tycho 3.0.0 SNAPSHOT now!

laeubi avatar Sep 18 '22 06:09 laeubi

Just updated to Tycho 3.0.0 as released, I get this message now even if i DO NOT build in parallel, but it refers to classes within the aggregator.

My sample

[WARNING] The requested profile "github" could not be activated because it does not exist.
[ERROR] Failed to execute goal org.eclipse.tycho:tycho-compiler-plugin:3.0.0:compile (default-compile) on project ch.elexis.core.model: Compilation failure: Compilation failure: 
[ERROR] /Users/marco/git/elexis-3-core/bundles/ch.elexis.core.model/src/ch/elexis/core/model/TypedArticle.java:[192] 
[ERROR] 	return getEntity().getTyp() != null ? getEntity().getTyp() : ArticleTyp.ARTIKEL;
[ERROR] 	                   ^^^^^^

this clearly is not the case, the respective reference plugin is compiled successfully and the code works up until changing to Tycho 3.0.0

Could this be related to the warning Using JavaSE-17 to fulfill requested profile of JavaSE-11 this might lead to faulty dependency resolution, consider define a suitable JDK in the toolchains.xml

col-panic avatar Oct 05 '22 07:10 col-panic

Have you tried

consider define a suitable JDK in the toolchains.xml

already?

laeubi avatar Oct 05 '22 07:10 laeubi

I have to

Have you tried

consider define a suitable JDK in the toolchains.xml

already?

I have to wrap my head around this. There is only one JDK installed, and its Java 17 for everything. It worked up until switching to Tycho 3.0 (except for the parallel building part). With toolchains I am supposed to be able to use different JDKs for maven and build etc. which is not what I want.

Besides: Switching the eclipse-plugin Bundle-RequiredExecutionEnvironment Java-SE17 removes this message, but does not fix the problem.

There are lots of other messages now, however, like

[ERROR] [accfbe90-af53-4654-99e2-072d5ce42642][extension>org.eclipse.tycho:tycho-maven-plugin:3.0.0] org.eclipse.core.runtime
org.osgi.framework.BundleException: Error starting module. osgi.identity; osgi.identity="org.eclipse.core.runtime"; type="osgi.bundle"; version:Version="3.26.0.v20220813-0916"; tags:List<String>="osgi.connect"; singleton:="true" [id=49]
    at org.eclipse.osgi.container.Module.doStart (Module.java:614)
    at org.eclipse.osgi.container.Module.start (Module.java:468)
    at org.eclipse.osgi.framework.util.SecureAction.start (SecureAction.java:513)
    at org.eclipse.osgi.container.ModuleContainer.start (ModuleContainer.java:888)
    at org.eclipse.osgi.container.ModuleContainer.applyDelta (ModuleContainer.java:879)
    at org.eclipse.osgi.container.ModuleContainer.resolveAndApply (ModuleContainer.java:560)
    at org.eclipse.osgi.container.ModuleContainer.resolve (ModuleContainer.java:503)
    at org.eclipse.osgi.container.ModuleContainer.resolve (ModuleContainer.java:492)
    at org.eclipse.osgi.container.Module.start (Module.java:446)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel$2.run (ModuleCo

col-panic avatar Oct 05 '22 07:10 col-panic

There is only one JDK installed, and its Java 17 for everything. It worked up until switching to Tycho 3.0 (except for the parallel building part).

Then it might not be directly related but toolchains are recommended when compiling for older JDKs

Can you provide an integration-test to demonstrate the issue? Maybe there are other plugins in your build that are incompatible with tycho 3?

laeubi avatar Oct 05 '22 07:10 laeubi

This should be fixed in the Tycho 3.0.0 SNAPSHOT now!

We are using Tycho 3.0.0 release and are still seeing such errors in multithreaded builds:

[ERROR] The type java.lang.String cannot be resolved. It is indirectly referenced from required .class files

sratz avatar Oct 10 '22 10:10 sratz

@sratz One would need what JDK is used for build, what is sued for compile (e.g. content of toolchains.xml)

laeubi avatar Oct 10 '22 10:10 laeubi

maven / Tycho build is run with SapMachine 17.0.4.1 (openJDK).

tycho-compiler-plugin is set to to <useJDK>SYSTEM</useJDK> and <release>11</release>.

Toolchains should not be relevant in this case but looks as follows:

<?xml version="1.0" encoding="UTF8"?>
<toolchains>
  <toolchain>
    <type>jdk</type>
    <provides>
      <version>11</version>
      <vendor>SAP</vendor>
      <id>JavaSE-11</id>
    </provides>
    <configuration>
      <jdkHome>/home/jenkins/tools/java/SAP/sapmachine-jdk-11.0.16.1</jdkHome>
    </configuration>
  </toolchain>
  <toolchain>
    <type>jdk</type>
    <provides>
      <version>17</version>
      <vendor>SAP</vendor>
      <id>JavaSE-17</id>
    </provides>
    <configuration>
      <jdkHome>/home/jenkins/tools/java/SAP/sapmachine-jdk-17.0.4.1</jdkHome>
    </configuration>
  </toolchain>
</toolchains>

sratz avatar Oct 10 '22 10:10 sratz

Maybe a custom ECJ setting somewhere in the poms using an older release?

laeubi avatar Oct 10 '22 10:10 laeubi

Oh, my bad. In this particular build Tycho 2.7.5 is still used.

Sorry for the noise.

sratz avatar Oct 10 '22 10:10 sratz

Have you tried

consider define a suitable JDK in the toolchains.xml

already?

yes. The problem persists.

Running mvn clean verify with a proper toolchains.xml on https://github.com/elexis/elexis-3-core/tree/f24622 leads to the following error:

...
[ERROR] Failed to execute goal org.eclipse.tycho:tycho-compiler-plugin:3.0.0:compile (default-compile) on project ch.elexis.core.model: Compilation failure: Compilation failure: 
[ERROR] /Users/marco/git/elexis-3-core/bundles/ch.elexis.core.model/src/ch/elexis/core/model/TypedArticle.java:[192] 
[ERROR] 	return getEntity().getTyp() != null ? getEntity().getTyp() : ArticleTyp.ARTIKEL;
[ERROR] 	       ^^^^^^^^^^^^^^^^^^^^
[ERROR] The type ArticleTyp cannot be resolved. It is indirectly referenced from required .class files
[ERROR] /Users/marco/git/elexis-3-core/bundles/ch.elexis.core.model/src/ch/elexis/core/model/TypedArticle.java:[192] 
[ERROR] 	return getEntity().getTyp() != null ? getEntity().getTyp() : ArticleTyp.ARTIKEL;
[ERROR] 	                   ^^^^^^
...

which makes no sense, as the resp. file was successfilly compiled within

[INFO] ch.elexis.core 3.10.0-SNAPSHOT ..................... SUCCESS [  1.859 s]

Other Info:

openjdk version "17.0.4.1" 2022-08-12 OpenJDK Runtime Environment Temurin-17.0.4.1+1 (build 17.0.4.1+1) OpenJDK 64-Bit Server VM Temurin-17.0.4.1+1 (build 17.0.4.1+1, mixed mode, shari

Apache Maven 3.8.6 (84538c9988a25aec085021c365c560670ad80f63) Maven home: /usr/local/Cellar/maven/3.8.6/libexec Java version: 17.0.4.1, vendor: Eclipse Adoptium, runtime: /Library/Java/JavaVirtualMachines/temurin-17.jdk/Contents/Home Default locale: de_AT, platform encoding: UTF-8 OS name: "mac os x", version: "11.7", arch: "x86_64", family: "ma

col-panic avatar Oct 10 '22 11:10 col-panic

Such error can also be generated if an import is missing (at least JDT thinks so) and as the type is from ch.elexis.core and you are compiling ch.elexis.core.model maybe a package is not exported/imported that is transitively required?

Can you try to extract getEntity().getTyp() into a local variable ent = getEntity() in that code path?

laeubi avatar Oct 10 '22 11:10 laeubi

I tried, the error message does not really change

[ERROR] Failed to execute goal org.eclipse.tycho:tycho-compiler-plugin:3.0.0:compile (default-compile) on project ch.elexis.core.model: Compilation failure: Compilation failure: 
[ERROR] /Users/marco/git/elexis-3-core/bundles/ch.elexis.core.model/src/ch/elexis/core/model/TypedArticle.java:[193] 
[ERROR] 	ArticleTyp articleType = entity.getTyp();
[ERROR] 	                                ^^^^^^
[ERROR] The method getTyp() from the type Artikel refers to the missing type ArticleTyp

it's just refering to entity now. Interestingly enough - this only seems to be a problem on OS X. Running it on Linux always passes this part without a problem.

col-panic avatar Oct 11 '22 05:10 col-panic

@laeubi I believe this is only partially fixed. I am still getting this errors with tycho 4.0.7 and ecj 3.37.0: [ERROR] Failed to execute goal org.eclipse.tycho:tycho-compiler-plugin:4.0.7:compile (default-compile) on project companyXX.YYTactics: Compilation failure: Compilation failure: [ERROR] D:\Webservice\jenkins\workspace\ZZZ\bundles\companyXX.YYactics\src\registration\YYTacticsClassList.java: [ERROR] package registration; [ERROR] ^ [ERROR] The type java.lang.String cannot be resolved. It is indirectly referenced from required type otherCompanyXX.ILink [ERROR] 1 problem (1 error) [ERROR] -> [Help 1]

Similar issue in Eclipse IDE 2022_12: The type java.lang.String cannot be resolved. It is indirectly referenced from required type companyXX.YYYYDataBuilder

jocwurs avatar Apr 10 '24 13:04 jocwurs

@jocwurs is there any project to reproduce the problem? I'm not aware of such problem in the past years.

laeubi avatar Apr 14 '24 17:04 laeubi