Bug 560610 - "Bound mismatch" compilation error if analyseResourceLeaks option is enabled
Summary: "Bound mismatch" compilation error if analyseResourceLeaks option is enabled
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.15   Edit
Hardware: All All
: P3 critical (vote)
Target Milestone: 4.16 M1   Edit
Assignee: Stephan Herrmann CLA
QA Contact:
URL:
Whiteboard:
Keywords: regression
: 560585 (view as bug list)
Depends on:
Blocks:
 
Reported: 2020-02-27 10:19 EST by Martin Lippert CLA
Modified: 2020-04-07 07:45 EDT (History)
8 users (show)

See Also:
register.eclipse: review+


Attachments
Compiler options to disable (212.91 KB, image/png)
2020-02-27 11:47 EST, Andrey Loskutov CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Lippert CLA 2020-02-27 10:19:34 EST
I am using eclipse-SDK-I20200226-1800-macosx-cocoa-x86_64.

While I was trying ti find the root cause for #560585, I stumbled upon multiple wired compilation issues and errors that do not happen in the 2019-12 release. Since this is a PDE project, maybe the root cause is in PDE, but it surfaces through the Java code, therefore filing the issue here.

Steps to reproduce:
- use latest Eclipse SDK as your IDE
- target platform: download latest nightly build of STS4 on Eclipse 4.15 from here: http://dist.springsource.com/snapshot/STS4/nightly-distributions.html
- set the STS4 install as your target platform (not your IDE)
- git clone https://github.com/spring-projects/spring-ide.git
- Import As Existing Project "org.springframework.ide.eclipse.boot.dash" from the "plugins" folder.

(sorry, but I wasn't able to create a simple sample that reproduces this)

That should result in a PDE/Java project in your workspace. This works fine in Eclipse 2019-12 (even if the target platform is a newer Eclipse). In the latest 4.15 builds, this shows up with a compiler error on the enum:

org.springframework.ide.eclipse.boot.dash.model.RunState

When opening

org.springframework.ide.eclipse.boot.dash.model.AbstractLaunchConfigurationsDashElement

a similar error shows up at the bottom of that file on the overridden method.

This itself is strange, but when I change something in that file and press save, tons of errors show up about types that cannot be resolved. When doing a clean build, everything resolves fine again (another issue, I think).

I am not sure about the compiler error above, but the tons of errors about missing types is very similar to the bug that I reported today about cross-plugin resolution issues.

This might all be rooted in some strange things in my projects (since I am not able to reproduce this with a simple example), but I am super worried about the 4.15 release exactly the same steps behave just perfectly well in 2019-12...
Comment 1 Andrey Loskutov CLA 2020-02-27 10:34:34 EST
Which JDK are you using? Can you attach your error log please?
Comment 2 Julian Honnen CLA 2020-02-27 10:47:19 EST
I get the following compilation error with corretto 1.8.0 202:

Bound mismatch: The type Enum<E> is not a valid substitute for the bounded parameter <E extends Enum<E>> of the type RunState
Comment 3 Andrey Loskutov CLA 2020-02-27 11:02:06 EST
(In reply to Julian Honnen from comment #2)
> I get the following compilation error with corretto 1.8.0 202:
> 
> Bound mismatch: The type Enum<E> is not a valid substitute for the bounded
> parameter <E extends Enum<E>> of the type RunState

The error is reported on clean build only. Touching the org.springframework.ide.eclipse.boot.dash.model.RunState and saving it (just a space or comment change) fixes the error till next clean build.
Comment 4 Martin Lippert CLA 2020-02-27 11:03:29 EST
(In reply to Andrey Loskutov from comment #1)
> Which JDK are you using? Can you attach your error log please?

JDK is (for both the same, 2019-12 and 2020-03):
java.vm.vendor=Oracle Corporation
java.vm.version=13.0.1+9

Error Log doesn't reveal anything

More details/steps/observations:

open:

org.springframework.ide.eclipse.boot.dash.model.AbstractLaunchConfigurationsDashElement

The error shows up on the "supportedGoalStates" method at the bottom of that class. When I delete that method and instead copy it into the subclasses:

- BootProjectDashElement
- LaunchConfDashElement

All the errors go away, and working on the source works just fine. Even the "resolve types from different plugin" works again.

When undo-ing those changes, I get the wrong behavior again.
Comment 5 Stephan Herrmann CLA 2020-02-27 11:25:01 EST
Martin, to help me decide if I should urgently look at this, please give more details on what problems exactly you see. Just knowing that there are unexpected compile errors doesn't give a hint if one of my changes might be responsible.
Comment 6 Andrey Loskutov CLA 2020-02-27 11:29:20 EST
I've bisected this, regression is coming from bug 527761 commit 97609bfc7e97c6f6ae7ba958f656e2efd47c7fce.
Comment 7 Andrey Loskutov CLA 2020-02-27 11:35:02 EST
(In reply to Andrey Loskutov from comment #6)
> I've bisected this, regression is coming from bug 527761 commit
> 97609bfc7e97c6f6ae7ba958f656e2efd47c7fce.

More precisely, commenting out the new if block below fixes the error:

https://git.eclipse.org/r/#/c/155140/2/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java@2104
Comment 8 Martin Lippert CLA 2020-02-27 11:39:42 EST
(In reply to Stephan Herrmann from comment #5)
> Martin, to help me decide if I should urgently look at this, please give
> more details on what problems exactly you see. Just knowing that there are
> unexpected compile errors doesn't give a hint if one of my changes might be
> responsible.

This error shows up on the "RunStatus" enum:

===
Bound mismatch: The type Enum<E> is not a valid substitute for the bounded parameter <E extends Enum<E>> of the type RunState
===

The same error shows up on the method "supportedGoalStates" on "AbstractLaunchConfigurationsDashElement", but it shows up in the editor only.

When commenting out the method and pressing save on that source file, results in about 100 errors in that file, most of them:

"<type> cannot be resolved"

Does that help?

To me this looks like a small, but severe problem that seems to trigger other issues (like the type resolving between plugins), but that is a different piece of the puzzle here.
Comment 9 Andrey Loskutov CLA 2020-02-27 11:47:09 EST
Created attachment 281958 [details]
Compiler options to disable

Martin, please disable the options in the attached screenshot in your workspace (I did this for the concrete project only). This should fix the compilation error with the RunState / org.springframework.ide.eclipse.boot.dash project.

Please check if all other issues disappear, and if not, please post what else is not working.
Comment 10 Martin Lippert CLA 2020-02-27 11:56:46 EST
(In reply to Andrey Loskutov from comment #9)
> Created attachment 281958 [details]
> Compiler options to disable
> 
> Martin, please disable the options in the attached screenshot in your
> workspace (I did this for the concrete project only). This should fix the
> compilation error with the RunState /
> org.springframework.ide.eclipse.boot.dash project.
> 
> Please check if all other issues disappear, and if not, please post what
> else is not working.

This workaround indeed solves the issue and the other strange side effects are gone, too. So this is great news!!!
Comment 11 Martin Lippert CLA 2020-02-27 11:57:54 EST
*** Bug 560585 has been marked as a duplicate of this bug. ***
Comment 12 Stephan Herrmann CLA 2020-02-27 12:12:52 EST
Thanks for analysis so far.

I'm looking into it now
Comment 13 Stephan Herrmann CLA 2020-02-27 12:25:57 EST
As downloads/clone are taking a loooong time on my end ...

(In reply to Martin Lippert from comment #0)
> - git clone https://github.com/spring-projects/spring-ide.git
> - Import As Existing Project "org.springframework.ide.eclipse.boot.dash"
> from the "plugins" folder.

could s.o. attach just the needed project here?
Comment 14 Stephan Herrmann CLA 2020-02-27 12:44:13 EST
... should've said: please send a harddisk with everything installed.

Seems this bug set a record on size of downloads and git repo to clone just for investigating one compile error. Frankly I've never seen a git repo of that size.

Starting the work only now.
Comment 15 Eclipse Genie CLA 2020-02-27 13:00:23 EST
New Gerrit change created: https://git.eclipse.org/r/158525
Comment 16 Stephan Herrmann CLA 2020-02-27 13:03:42 EST
(In reply to Eclipse Genie from comment #15)
> New Gerrit change created: https://git.eclipse.org/r/158525

ParameterizedTypeBinding is affected by the same problem as detected regarding SourceTypeBinding in bug 558759 comment 10: method unResolvedMethods() intended for inspecting method bindings without triggering any resolution, did trigger resolving of lots of things, including a bound check involing enum RunState before that enum had its super class connected.

Fix is simple.

I'm trying to create a regression test for this.
Comment 17 Martin Lippert CLA 2020-02-27 13:07:09 EST
(In reply to Stephan Herrmann from comment #14)
> ... should've said: please send a harddisk with everything installed.

LOL... Indeed...

> Seems this bug set a record on size of downloads and git repo to clone just
> for investigating one compile error. Frankly I've never seen a git repo of
> that size.

Yeah, I am sorry for that, it is indeed an old repo, containing about 15 years of work on the various Spring IDE components... My bad that I wasn't able to strip this down to a simple sample project, because I had no idea where to start looking with regards to that error.

And many many many thanks for all involved here for the super quick turnaround on this, this is AWESOME !!!
Comment 18 Stephan Herrmann CLA 2020-02-27 14:19:02 EST
@Manoj: While jenkins is still testing, may I already ask you to start collecting the necessary approvals for inclusion in RC2?
@Andrey: as you already came near the buggy code, do you want to do a code review?

Description of problem and fix:

- The change for Bug 527761 uses method ReferenceBinding.unResolvedMethods()
  by the assumption that this method will not cause any unwanted resolving.
  Call site is the new method hasMethodWithNumArgs().

- In bug 558759 comment 10 I detected that SourceTypeBinding did not behave well:
  we *did* invoke unwanted resolving.
  I fixed that type. Now STB.hasMethodWithNumArgs() avoids calling that
  unhappy unResolvedMethods()

- In this bug we see that ParameterizedTypeBinding still suffers from the same
  problem, requiring another override of hasMethodWithNumArgs().
  Since this method doesn't care about any types, it is safe to just delegate
  to this.type, so that STB.hasMethodWithNumArgs() can take over.

The bug is a bit hard to reproduce since it happens only in a very specific call sequence, finally resulting in performing a bound check involving an enum class which did not yet have its superclass set.

I managed to reduce a small but quite complex test case (in path set #2).

Without the fix it spits out:

----------
1. ERROR in EN.java (at line 1)
	public enum EN {
	^
Bound mismatch: The type Enum<E> is not a valid substitute for the bounded parameter <E extends Enum<E>> of the type EN
----------

With the fix, the example is accepted, as is the original project referenced by Martin. 

I haven't analysed why this simple compiler bug caused floods of secondary compile errors, but after fixing the original bug the affected project is healthy again.
Comment 19 Andrey Loskutov CLA 2020-02-27 14:41:57 EST
(In reply to Stephan Herrmann from comment #18)
> @Andrey: as you already came near the buggy code, do you want to do a code
> review?

I did, but I didn't understand it (I'm not in this business), so sorry, no +1 from me. 

I personally would also love to see this fixed in 4.15, but if not, I can understand it because it is pretty late and a workaround is possible.
Comment 20 Till Brychcy CLA 2020-02-27 15:54:13 EST
(I've corrected the target to 4.15RC2)

+1 from me.
Comment 21 Stephan Herrmann CLA 2020-02-27 15:59:47 EST
(In reply to Till Brychcy from comment #20)
> (I've corrected the target to 4.15RC2)
> 
> +1 from me.

thanks for both :)
Comment 22 Andrey Loskutov CLA 2020-02-28 06:58:34 EST
Jay, we need approval to release it in RC2.
Comment 23 Stephan Herrmann CLA 2020-03-05 14:45:41 EST
This didn't make the cut for 4.15.
Comment 24 Jay Arthanareeswaran CLA 2020-03-05 23:21:02 EST
(In reply to Andrey Loskutov from comment #22)
> Jay, we need approval to release it in RC2.

*sigh*, looks like this was a casualty when bugzilla genie wasn't sending mails last week. Sorry about it.
Comment 26 Stephan Herrmann CLA 2020-03-10 10:28:54 EDT
(In reply to Eclipse Genie from comment #25)
> Gerrit change https://git.eclipse.org/r/158525 was merged to [master].
> Commit:
> http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/
> ?id=0868f3b2221bc1d98910c1d867395871c555bc88

Released for 4.16 M1
Comment 27 Martin Lippert CLA 2020-03-10 11:12:22 EDT
Thanks again to all involved here and especially Stephan for fixing this. Much much appreciated and great to see that the fix made it now into the repo.
Comment 28 Eclipse Genie CLA 2020-03-18 16:19:27 EDT
New Gerrit change created: https://git.eclipse.org/r/159664
Comment 29 Andrey Loskutov CLA 2020-03-18 16:25:46 EDT
(In reply to Eclipse Genie from comment #28)
> New Gerrit change created: https://git.eclipse.org/r/159664

Backport patch for 4.15 stream.
Comment 30 Manoj N Palat CLA 2020-04-07 07:27:16 EDT
Verified for Eclipse Version: 2020-06 (4.16) M3 with Build id: I20200406-0600
Comment 31 Manoj N Palat CLA 2020-04-07 07:45:03 EDT
(In reply to Manoj Palat from comment #30)
> Verified for Eclipse Version: 2020-06 (4.16) M3 with Build id: I20200406-0600

I mean 4.16 M1 - sorry for the typo/c&p