Bug 517514 - Eclipse shows phantom compile errors and pretends wrong Java version would be in effect
Summary: Eclipse shows phantom compile errors and pretends wrong Java version would be...
Status: ASSIGNED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Debug (show other bugs)
Version: 4.5.2   Edit
Hardware: PC Linux
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: JDT-Debug-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords: needinfo
Depends on:
Blocks:
 
Reported: 2017-05-31 06:03 EDT by Alexander Veit CLA
Modified: 2022-12-20 13:49 EST (History)
3 users (show)

See Also:


Attachments
Screenshot of project and workspace settings. (230.90 KB, image/png)
2017-05-31 06:03 EDT, Alexander Veit CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander Veit CLA 2017-05-31 06:03:21 EDT
Created attachment 268652 [details]
Screenshot of project and workspace settings.

It happens that Eclipse recompiles projects and then shows thousands of phantom compile errors on each project. The errors are related to language contructs that are only available in newer Java versions (generic types, lambdas, etc.). The Java version configured and used throughout all projects and in the workspace is Java 8. The compiler compliance level also is 1.8 everywhere. However, in the failing project a greyed-out value of 1.4 is shown (see screenshot).

The problem occurs regularly, about once a day. Fiddling around, cleaning and rebuilding projects helps. Unfortunately this usually takes much time, what renders Eclipse under Linux somewhat non-productive.

Eclipse should not assume, or guess, or fall back to any settings that are not configured anywhere.

System JDK installed from
 deb http://ppa.launchpad.net/webupd8team/java/ubuntu xenial main

# java -version
java version "1.8.0_131"
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)

Workspace with ~70 dependent Java projects.

OS: Debian Linux Jessie with Cinnamon Desktop
Comment 1 Alexander Veit CLA 2017-06-29 07:24:55 EDT
The problem also exists in Oxygen.
Comment 2 Stephan Herrmann CLA 2017-07-02 07:54:13 EDT
This reminds me of a problem we've intermittently seen in our tests, too (bug 482991). There the problem was indeed related to detecting/recognizing the current JVM.

Could you please try if the problem also occurs when you directly install the Oracle JDK (vs. the repackaged version from that ppa)? Perhaps the JDK is not correctly recognized as 1.8. I've no idea what that installer does.

Now that you've upgraded to Oxygen, you could also try the following "hack": launch Eclipse with the following vmarg:
  -Djdt.default.test.compliance=1.8
This property is intended only for tests, but if that prevents the bug from occurring in your case, we'd know better what is going on (and you'd have a workaround for now).

Moving to JDT/Debug to seek their advice on VMs that are / are not recognized by JavaRuntime.initializeVMs()
Comment 3 Per Digre CLA 2017-07-03 03:03:55 EDT
I have exactly the same error and I have only seen it with Oxygen. 

I'm able to get around it by switching temporarily back to Java 7 for workspace settings.
Comment 4 Stephan Herrmann CLA 2017-07-03 12:46:48 EDT
(In reply to Per Digre from comment #3)
> I have exactly the same error and I have only seen it with Oxygen. 
> 
> I'm able to get around it by switching temporarily back to Java 7 for
> workspace settings.

So the questions/suggestions from comment 2 are directed also at you :)
Comment 5 Per Digre CLA 2017-07-03 14:51:15 EDT
I suspect this has something to do with "not using Oomph". I had a similar annoying issue with "Build Automatically" never remembered as ON after restarting Eclipse. This went away when I set Oomph to record preferences. 

Prior to the release I had a "not using Oomph" issue with being stuck on Dark Theme, same resolution using Oomph.

I will test comment #2 when I get back to work tomorrow :-)
Comment 6 Per Digre CLA 2017-07-04 10:14:36 EDT
Regarding comment #2 I am unable to reproduce the issue now. I suspect that having once recorded to Oomph will resolve future installations?

This was the setup when it failed for me first time I used Oxygen.

Eclipse for RCP and RAP Developers
Version: Oxygen Release (4.7.0)
Build id: 20170620-1800

C:\Users\psd.ESITO-PSD2>java -version
java version "1.8.0_77"
Java(TM) SE Runtime Environment (build 1.8.0_77-b03)
Java HotSpot(TM) 64-Bit Server VM (build 25.77-b03, mixed mode)
Comment 7 Stephan Herrmann CLA 2017-07-04 10:31:57 EDT
Oomph may help to avoid the issue, but I still suspect that in some situation the JVM is not correctly recognized in the first place - theory speaking :)
Comment 8 Alexander Veit CLA 2017-07-04 14:21:01 EDT
Thank you for your suggested workaround.

Meanwhile I've reconfigured all the ~70 projects in the affected workspace to use project specific settings with Java 8 (1.8) compiler set explicitly.

I hope to get some time to switch back all projects in order to test your workaround soon.

With a directly installed JDK the problem also occurred. In fact I tried to switch back and forth between two installations as standard JDK in Eclipse to resolve the error.

An argument against the theory of a badly installed JDK is the fact that another workspace on the same machine with even more projects never showed this error.
Comment 9 Alexander Veit CLA 2017-07-06 16:13:17 EDT
I've switched all projects in the affected workspace back to workspace settings and started Eclipse Oxygen with the suggested

 -Djdt.default.test.compliance=1.8

The workspace now ran for two days without showing the bug.
Comment 10 Stephan Herrmann CLA 2017-07-06 16:22:55 EDT
(In reply to Alexander Veit from comment #9)
> I've switched all projects in the affected workspace back to workspace
> settings and started Eclipse Oxygen with the suggested
> 
>  -Djdt.default.test.compliance=1.8
> 
> The workspace now ran for two days without showing the bug.

Thanks!
If that is indeed the situation that previously showed the bug, then indeed all is pointing to a problem with recognizing the current JVM.

@Sarika, @Andrey, is there any logging of JVM detection that users could turn on for further analysis?
Comment 11 Sarika Sinha CLA 2017-07-07 01:25:51 EDT
When you face the problem, can you see what do you have in this file -
<Workspace>\.metadata\.plugins\org.eclipse.jdt.launching\.install.xml

And do you have any value for "java.home" set in System property ?
Comment 12 Alexander Veit CLA 2017-07-18 02:33:49 EDT
The problem does not occur with -Djdt.default.test.compliance=1.8 set.

However, my current .install.xml in the workspace affected is

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<dirs>
<entry loc="/usr/lib/jvm/java-8-oracle" stamp="1494402901000"/>
<entry loc="/java/jdk1.8.0_131" stamp="1496226655000"/>
<entry loc="/usr/lib/jvm/jdk-8-oracle-x64" stamp="1478073855000"/>
</dirs>

The first two entries point to an existing directory. The third entry does not exist neither as a directory nor as a sysmolic link.


The environment variable JAVA_HOME has the value /usr/lib/jvm/java-8-oracle.

As far as I can see the system property java.home is not set explicitely.
Comment 13 Stephan Herrmann CLA 2017-07-18 12:54:41 EDT
(In reply to Alexander Veit from comment #12)
> The problem does not occur with -Djdt.default.test.compliance=1.8 set.

Thanks, this supports my theory that computing the default compliance might indeed be broken. 

I'll leave it to Sarika to comment on the other observations :)
Comment 14 Sarika Sinha CLA 2017-10-11 00:31:58 EDT
(In reply to Stephan Herrmann from comment #10)
> (In reply to Alexander Veit from comment #9)
> > I've switched all projects in the affected workspace back to workspace
> > settings and started Eclipse Oxygen with the suggested
> > 
> >  -Djdt.default.test.compliance=1.8
> > 
> > The workspace now ran for two days without showing the bug.
> 
> Thanks!
> If that is indeed the situation that previously showed the bug, then indeed
> all is pointing to a problem with recognizing the current JVM.
> 
> @Sarika, @Andrey, is there any logging of JVM detection that users could
> turn on for further analysis?

We need this. Created Bug 525841.
Comment 15 Alexander Veit CLA 2017-12-18 13:37:04 EST
Again ran into the problem. This time non on Linux but on a Windows 7 machine.

/--- .install.xml ---
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<dirs>
<entry loc="C:\java\jdk8" stamp="1512223991417"/>
</dirs>
\--------------------

C:\java\jdk8 is a symlink (mklink /D c:\java\jdkk8 c:\java\jdk1.8.0_152).

As far as I can tell -Djava.home is not set explicitely. But the environment variable JAVA_HOME is set to C:\java\jdk8.
Comment 16 Stephan Herrmann CLA 2018-01-06 12:43:22 EST
(In reply to Sarika Sinha from comment #14)
> (In reply to Stephan Herrmann from comment #10)
> > (In reply to Alexander Veit from comment #9)
> > > I've switched all projects in the affected workspace back to workspace
> > > settings and started Eclipse Oxygen with the suggested
> > > 
> > >  -Djdt.default.test.compliance=1.8
> > > 
> > > The workspace now ran for two days without showing the bug.
> > 
> > Thanks!
> > If that is indeed the situation that previously showed the bug, then indeed
> > all is pointing to a problem with recognizing the current JVM.
> > 
> > @Sarika, @Andrey, is there any logging of JVM detection that users could
> > turn on for further analysis?
> 
> We need this. Created Bug 525841.

@Sarika, after you closed the other bug as wontfix, can you recommend how users can provide us the information we need?

Also, I'm not sure knowing which JVM was used is sufficient, we may also need to know (a) did we correctly figure out the version of that JVM? (b) did that JVM version help to set a good default compliance?
Comment 17 Sarika Sinha CLA 2018-01-07 23:30:50 EST
I will try to add some logs related to the identified JRE and the version.
Comment 18 Sarika Sinha CLA 2018-01-19 01:59:18 EST
(In reply to Stephan Herrmann from comment #16)
> 
> @Sarika, after you closed the other bug as wontfix, can you recommend how
> users can provide us the information we need?
> 
> Also, I'm not sure knowing which JVM was used is sufficient, we may also
> need to know (a) did we correctly figure out the version of that JVM? (b)
> did that JVM version help to set a good default compliance?

Working on this, I am planning to put these things ( If VM logging property is enabled)-
1. Log the version details and java home location when we populate the vm library cache
2. When the default vm is used - log the details

Will this information be enough? Or some more information to be logged?
Comment 19 Eclipse Genie CLA 2018-01-31 05:47:16 EST
New Gerrit change created: https://git.eclipse.org/r/116424
Comment 21 Sarika Sinha CLA 2018-02-01 00:39:42 EST
-Djdt.debug.launching.vmLogging=true

can be used to enable VMLogging.
Comment 22 Alexander Veit CLA 2018-07-09 05:54:31 EDT
After updating to Eclipse Photon the problem occurs again.

Setting -Djdt.debug.launching.vmLogging=true produces multiple entries in the error log:

```
Default Install retrieved:/usr/lib/jvm/java-8-oracle

An exception stack trace is not available.

eclipse.buildId=4.8.0.I20180611-0500
java.version=1.8.0_171
java.vendor=Oracle Corporation
BootLoader constants: OS=linux, ARCH=x86_64, WS=gtk, NL=de_DE
Framework arguments:  -product org.eclipse.epp.package.jee.product
Command-line arguments:  -os linux -ws gtk -arch x86_64 -product org.eclipse.epp.package.jee.product
```

The directory /usr/lib/jvm/java-8-oracle contains the installed Oracle JDK.

The workaround with -Djdt.default.test.compliance=1.8 works in Photon.
Comment 23 Alexander Veit CLA 2019-10-28 05:01:52 EDT
Today the problem occurred with Eclipse 2019-09 and JDK 11. Despite JDK 11 being the one and only configured and also the default JDK, each project showed JDK 1.4 compliance.

This time

-Djdt.default.test.compliance=11

in eclipse.ini seems to fix the error.

I wonder why Eclipse has no appropriate fallback value if this property is not present. Even more wondrous is the fact that the projects do not use workspace settings when "project specific settings" isn't checked.
Comment 24 Sarika Sinha CLA 2019-11-05 00:52:02 EST
May be the problem is with org.eclipse.jdt.launching.JavaRuntime.updateCompliance(IVMInstall)

I am adding some new log statements to be enabled with -Djdt.debug.launching.vmLogging=true
I am removing the previous log messages as they are not helping us.

@Alexander
Will you be able to test with new I build ?
Comment 25 Eclipse Genie CLA 2019-11-05 01:10:46 EST
New Gerrit change created: https://git.eclipse.org/r/151995
Comment 27 Alexander Veit CLA 2020-09-21 08:00:53 EDT
After upgrading to Eclipse 2020-09 (JDK 11) the error occurred again.

Again each project showed JDK 1.4 compliance. And again

-Djdt.default.test.compliance=11

in eclipse.ini fixes the error.

I also set -Djdt.debug.launching.vmLogging=true. This showed the startup error

eclipse.buildId=4.17.0.I20200902-1800
java.version=11.0.3-internal
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=de_DE
Framework arguments:  -product org.eclipse.epp.package.jee.product
Command-line arguments:  -os win32 -ws win32 -arch x86_64 -product org.eclipse.epp.package.jee.product -data D:\prj\ix-trunk-develop\workspace

org.eclipse.jdt.launching
Error
Mon Sep 21 13:51:22 CEST 2020
Restoring vm library location:C:\java\jdk11

C:\java\jdk11 is a regular directory (no a symbolic link) in which JDK 11 is installed.
Comment 28 Eclipse Genie CLA 2022-12-20 13:49:01 EST
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.