Bug 562500 - Show a lot of xxx cannot be resolved to a type or variable
Summary: Show a lot of xxx cannot be resolved to a type or variable
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.15   Edit
Hardware: PC Windows 10
: P3 critical (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords: needinfo
Depends on:
Blocks:
 
Reported: 2020-04-26 22:54 EDT by fang yongcheng CLA
Modified: 2024-04-10 00:50 EDT (History)
2 users (show)

See Also:


Attachments
import not found example (68.55 KB, image/png)
2020-04-26 22:54 EDT, fang yongcheng CLA
no flags Details
Error "Cannot resolve type" for correctly compiled class (445.70 KB, image/png)
2020-04-28 11:38 EDT, Marek Mosiewicz CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description fang yongcheng CLA 2020-04-26 22:54:29 EDT
Created attachment 282572 [details]
import not found example

After migrating from Java 8 to Java 11, I got a lot of odd compiling issues. For example, in ReapService.java, there is an import error: The import xxx.framework.utility.interprocessUtil.JniEnvironmentException cannot be resolved. But actually JniEnvironmentException.java is well compiled and I can see the JniEnvironmentException.class file. The way to solve the compiling issue is to edit ReapService.java (e.g.: add a new blank line which will not introduce new compiling error) and Save (Build Automatically) and the compiling issue disappears.

After all the import errors are resolved in this way, then the application could be started normally. But sometimes if trigger a build (or clean project), these errors occur again.

I also tried to use maven to build the project and the build is successful.
Comment 1 fang yongcheng CLA 2020-04-26 23:06:12 EDT
Note that we have hundreds of java source files and every time we got the same compiling files.
Comment 2 fang yongcheng CLA 2020-04-28 03:47:43 EDT
I tried the eclipse 4.10 and this issue never occurs.
Comment 3 Stephan Herrmann CLA 2020-04-28 06:19:57 EDT
please provide a zipped project for reproducing the issue, thanks.

Please also check if any related exceptions were logged to the Errors view / <workspace>/.log file.
Comment 4 Marek Mosiewicz CLA 2020-04-28 11:38:29 EDT
Created attachment 282607 [details]
Error "Cannot resolve type" for correctly compiled class
Comment 5 Marek Mosiewicz CLA 2020-04-28 11:41:37 EDT
This error occurs for https://github.com/adempiere/adempiere project which can be downloaded from GitHub.
This project have some what circular dependecies, but it seems that class CompiereColor can not be resolved, even if it is correctly compiled and in classpath.
This project contains subproject which can complicate things. Use only "adempiere" project when importing from Eclipse.
Comment 6 Stephan Herrmann CLA 2020-04-28 12:07:34 EDT
Thanks for mentioning adempiere. We had several issues with that project before, see bug 543070. The bottom line was: that project is (was?) not yet ready for JPMS, in particular it listed several dependencies that created illegal clashes with modules from the System library.

Please check if you also see problems of the kind:

The package javax.xml is accessible from more than one module: <unnamed>, java.xml

Please note that javac (and thus a regular maven build) illegally keeps silent about this error, more info on this:
* https://stackoverflow.com/questions/51094274/eclipse-cant-find-xml-related-classes-after-switching-build-path-to-jdk-10/53824670#53824670
* https://bugs.openjdk.java.net/browse/JDK-8215739

Also see bug 543070 comment 8 for steps that helped one user to compile that broken project with Eclipse.
Comment 7 Marek Mosiewicz CLA 2020-04-29 09:21:31 EDT
Yo are right. It seems that there is somewhere already this package and this causes this problem.
Comment 8 Eclipse Genie CLA 2022-04-20 04:54:28 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 9 Eclipse Genie CLA 2024-04-10 00:50:43 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.