Bug 548309 - Update code to make use of Java 8 features
Summary: Update code to make use of Java 8 features
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.13   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: 4.16 M3   Edit
Assignee: Fabrice Tiercelin CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 563532
  Show dependency tree
 
Reported: 2019-06-16 09:56 EDT by Carsten Hammer CLA
Modified: 2021-01-20 06:55 EST (History)
6 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Carsten Hammer CLA 2019-06-16 09:56:38 EDT
While the minimum BREE is 1.5 and higher in some cases the code is based on Java 1.4. Where it helps to improve readability, performance or in another way it might be useful to update the existing code base.
Comment 2 Eclipse Genie CLA 2019-06-20 13:52:02 EDT
New Gerrit change created: https://git.eclipse.org/r/144548
Comment 3 Eclipse Genie CLA 2019-06-20 13:52:05 EDT
New Gerrit change created: https://git.eclipse.org/r/144549
Comment 4 Eclipse Genie CLA 2019-06-20 13:52:07 EDT
New Gerrit change created: https://git.eclipse.org/r/144553
Comment 5 Eclipse Genie CLA 2019-06-20 13:52:09 EDT
New Gerrit change created: https://git.eclipse.org/r/144552
Comment 6 Eclipse Genie CLA 2019-06-20 13:52:12 EDT
New Gerrit change created: https://git.eclipse.org/r/144551
Comment 7 Eclipse Genie CLA 2019-06-20 13:52:14 EDT
New Gerrit change created: https://git.eclipse.org/r/144550
Comment 8 Eclipse Genie CLA 2019-06-20 13:52:16 EDT
New Gerrit change created: https://git.eclipse.org/r/144557
Comment 9 Eclipse Genie CLA 2019-06-20 13:52:19 EDT
New Gerrit change created: https://git.eclipse.org/r/144556
Comment 10 Eclipse Genie CLA 2019-06-20 13:52:21 EDT
New Gerrit change created: https://git.eclipse.org/r/144555
Comment 11 Eclipse Genie CLA 2019-06-20 13:52:23 EDT
New Gerrit change created: https://git.eclipse.org/r/144554
Comment 12 Eclipse Genie CLA 2019-06-20 13:52:26 EDT
New Gerrit change created: https://git.eclipse.org/r/144560
Comment 13 Eclipse Genie CLA 2019-06-20 13:52:28 EDT
New Gerrit change created: https://git.eclipse.org/r/144559
Comment 14 Eclipse Genie CLA 2019-06-20 13:52:41 EDT
New Gerrit change created: https://git.eclipse.org/r/144563
Comment 15 Eclipse Genie CLA 2019-06-20 13:52:43 EDT
New Gerrit change created: https://git.eclipse.org/r/144562
Comment 16 Eclipse Genie CLA 2019-06-20 13:52:45 EDT
New Gerrit change created: https://git.eclipse.org/r/144561
Comment 17 Eclipse Genie CLA 2019-06-20 13:52:48 EDT
New Gerrit change created: https://git.eclipse.org/r/144558
Comment 18 Eclipse Genie CLA 2019-06-20 13:52:50 EDT
New Gerrit change created: https://git.eclipse.org/r/144564
Comment 19 Carsten Hammer CLA 2019-06-21 02:06:44 EDT
https://git.eclipse.org/r/#/c/144558/ and https://git.eclipse.org/r/#/c/144552/ contain a bugfix for a missing usage of the loopcounter. Already discussed in https://git.eclipse.org/r/#/c/144113/. see https://bugs.eclipse.org/bugs/show_bug.cgi?id=205556 (hint from @Stephan Herrmann).
Comment 20 Andrey Loskutov CLA 2019-06-22 02:12:41 EDT
(In reply to Eclipse Genie from comment #1)
> Gerrit change https://git.eclipse.org/r/144106 was merged to [master].
> Commit:
> http://git.eclipse.org/c/jdt/eclipse.jdt.ui.git/commit/
> ?id=2231ff2f407b52e6c83aced9d5893e055ad028d8

This causes ant build failures:


Buildfile: C:\git\eclipse.jdt.ui\org.eclipse.jdt.ui\scripts\build_jar-in-jar-loader.xml

properties:

init:

clean:
      [delete] Deleting: C:\git\eclipse.jdt.ui\org.eclipse.jdt.ui\jar-in-jar-loader.zip

jar-in-jar-loader_zip:
       [mkdir] Created dir: C:\git\eclipse.jdt.ui\org.eclipse.jdt.ui\temp.folder\jar-in-jar-loader.zip.bin
       [javac] Compiling 5 source files to C:\git\eclipse.jdt.ui\org.eclipse.jdt.ui\temp.folder\jar-in-jar-loader.zip.bin
       [javac] ----------
       [javac] 1. ERROR in C:\git\eclipse.jdt.ui\org.eclipse.jdt.ui\jar in jar loader\org\eclipse\jdt\internal\jarinjarloader\RsrcURLConnection.java (at line 42)
       [javac] 	@Override
       [javac] 	^^^^^^^^^
       [javac] Syntax error, annotations are only available if source level is 1.5 or greater
       [javac] ----------
       [javac] 2. ERROR in C:\git\eclipse.jdt.ui\org.eclipse.jdt.ui\jar in jar loader\org\eclipse\jdt\internal\jarinjarloader\RsrcURLConnection.java (at line 46)
       [javac] 	@Override
       [javac] 	^^^^^^^^^
       [javac] Syntax error, annotations are only available if source level is 1.5 or greater
       [javac] ----------
       [javac] ----------
       [javac] 3. ERROR in C:\git\eclipse.jdt.ui\org.eclipse.jdt.ui\jar in jar loader\org\eclipse\jdt\internal\jarinjarloader\RsrcURLStreamHandler.java (at line 40)
       [javac] 	@Override
       [javac] 	^^^^^^^^^
       [javac] Syntax error, annotations are only available if source level is 1.5 or greater
       [javac] ----------
       [javac] 4. ERROR in C:\git\eclipse.jdt.ui\org.eclipse.jdt.ui\jar in jar loader\org\eclipse\jdt\internal\jarinjarloader\RsrcURLStreamHandler.java (at line 45)
       [javac] 	@Override
       [javac] 	^^^^^^^^^
       [javac] Syntax error, annotations are only available if source level is 1.5 or greater
       [javac] ----------
       [javac] ----------
       [javac] 5. ERROR in C:\git\eclipse.jdt.ui\org.eclipse.jdt.ui\jar in jar loader\org\eclipse\jdt\internal\jarinjarloader\RsrcURLStreamHandlerFactory.java (at line 37)
       [javac] 	@Override
       [javac] 	^^^^^^^^^
       [javac] Syntax error, annotations are only available if source level is 1.5 or greater
       [javac] ----------
       [javac] 5 problems (5 errors)

BUILD FAILED
C:\git\eclipse.jdt.ui\org.eclipse.jdt.ui\scripts\build_jar-in-jar-loader.xml:22: Compile failed; see the compiler error output for details.

Total time: 375 milliseconds
Comment 21 Eclipse Genie CLA 2019-06-22 02:20:19 EDT
New Gerrit change created: https://git.eclipse.org/r/144674
Comment 22 Andrey Loskutov CLA 2019-06-22 02:22:03 EDT
(In reply to Eclipse Genie from comment #21)
> New Gerrit change created: https://git.eclipse.org/r/144674

This fixes ant build failures.
Comment 23 Eclipse Genie CLA 2019-06-22 02:30:44 EDT
New Gerrit change created: https://git.eclipse.org/r/144675
Comment 24 Carsten Hammer CLA 2019-06-22 02:53:00 EDT
(In reply to Andrey Loskutov from comment #22)
> (In reply to Eclipse Genie from comment #21)
> > New Gerrit change created: https://git.eclipse.org/r/144674
> 
> This fixes ant build failures.

Thanks Andrey for taking care!
Comment 25 Andrey Loskutov CLA 2019-06-23 14:16:00 EDT
(In reply to Carsten Hammer from comment #24)
> (In reply to Andrey Loskutov from comment #22)
> > (In reply to Eclipse Genie from comment #21)
> > > New Gerrit change created: https://git.eclipse.org/r/144674
> > 
> > This fixes ant build failures.
> 
> Thanks Andrey for taking care!

See test fails at https://git.eclipse.org/r/144675 (with re-generated loader). 

We should either revert original changes to the code or update test expectations and declare that jar-in-jar loader doesn't support Java before 6.

I would vote for the latter. I don't think anyone uses such old Java - and if, old Eclipse can still be used to debug such applications.

@all on CC: any objections to restrict jar-in-jar loader to Java 6+?
Comment 26 Carsten Hammer CLA 2019-06-23 14:41:55 EDT
I think there are some eclipse platform or equinox projects with bree 1.5. maybe update everything to minimum 1.6?
Comment 27 Andrey Loskutov CLA 2019-06-24 04:54:06 EDT
(In reply to Carsten Hammer from comment #26)
> I think there are some eclipse platform or equinox projects with bree 1.5.
> maybe update everything to minimum 1.6?

It is not about plugins version, it is about jar-in-jar loader feature (see bug 262746), which is supposed to be used outside of Eclipse, just to package and run *some* arbitrary Java code on any Java 3+ JVM. With the changes above the loader is restricting this feature to Java 6+ JVM.

The loader is used by this code: Export -> Java -> Runnable Jar File -> "Package required libraries into generated Jar".

@Dani, JDT committers: any concerns to restrict the jar-in-jar loader code to run on Java 6+ JVM's only? I assume no real development happens with Java 3 - 5 JVM's today, but I can imagine that there are legacy applications around that could not run anymore on old JVM's, once they are re-exported from Eclipse 4.13.

If no one has objections, we should fix the failing tests in https://git.eclipse.org/r/144675 & merge the patches: 

https://git.eclipse.org/r/144674 and https://git.eclipse.org/r/144675

@Carsten, please update https://git.eclipse.org/r/144675 to fix JDT tests.
Comment 28 Carsten Hammer CLA 2019-06-24 09:19:02 EDT
(In reply to Andrey Loskutov from comment #27)
> (In reply to Carsten Hammer from comment #26)
> > I think there are some eclipse platform or equinox projects with bree 1.5.
> > maybe update everything to minimum 1.6?
> 
> It is not about plugins version, it is about jar-in-jar loader feature (see
> bug 262746), which is supposed to be used outside of Eclipse, just to
> package and run *some* arbitrary Java code on any Java 3+ JVM. With the
> changes above the loader is restricting this feature to Java 6+ JVM.
>
I did not talk about plugin versions. I was talking about java versions, something like Bundle-RequiredExecutionEnvironment: J2SE-1.5 in some Eclipse projects.
Don't know how to find them but something like this can be found in several projects.

https://git.eclipse.org/r/plugins/gitiles/tycho/org.eclipse.tycho/+/8d41301f617e06008c47d937cb7fb6e73492ac07/tycho-surefire/org.eclipse.tycho.surefire.osgibooter/META-INF/MANIFEST.MF
Comment 29 Andrey Loskutov CLA 2019-06-24 09:24:51 EDT
(In reply to Carsten Hammer from comment #28)
> (In reply to Andrey Loskutov from comment #27)
> > (In reply to Carsten Hammer from comment #26)
> > > I think there are some eclipse platform or equinox projects with bree 1.5.
> > > maybe update everything to minimum 1.6?
> > 
> > It is not about plugins version, it is about jar-in-jar loader feature (see
> > bug 262746), which is supposed to be used outside of Eclipse, just to
> > package and run *some* arbitrary Java code on any Java 3+ JVM. With the
> > changes above the loader is restricting this feature to Java 6+ JVM.
> >
> I did not talk about plugin versions. I was talking about java versions,
> something like Bundle-RequiredExecutionEnvironment: J2SE-1.5 in some Eclipse
> projects.
> Don't know how to find them but something like this can be found in several
> projects.
> 
> https://git.eclipse.org/r/plugins/gitiles/tycho/org.eclipse.tycho/+/
> 8d41301f617e06008c47d937cb7fb6e73492ac07/tycho-surefire/org.eclipse.tycho.
> surefire.osgibooter/META-INF/MANIFEST.MF

Again, the jar-in-jar loader is NOT used for bundles, it is used to run *standalone* Java jar applications. So it is totally unrelated what some bundle defined as a minimum JVM runtime version.
Comment 30 Carsten Hammer CLA 2019-06-24 09:34:26 EDT
(In reply to Andrey Loskutov from comment #29)
> 
> Again, the jar-in-jar loader is NOT used for bundles, it is used to run
> *standalone* Java jar applications. So it is totally unrelated what some
> bundle defined as a minimum JVM runtime version.

Does this mean there is another jar-in-jar loader implementation for bundles like this:
https://downloads.efxclipse.bestsolution.at/p2-repos/openjfx-11/repository/plugins/
?
Comment 31 Andrey Loskutov CLA 2019-06-24 09:40:25 EDT
(In reply to Carsten Hammer from comment #30)
> (In reply to Andrey Loskutov from comment #29)
> > 
> > Again, the jar-in-jar loader is NOT used for bundles, it is used to run
> > *standalone* Java jar applications. So it is totally unrelated what some
> > bundle defined as a minimum JVM runtime version.
> 
> Does this mean there is another jar-in-jar loader implementation for bundles
> like this:
> https://downloads.efxclipse.bestsolution.at/p2-repos/openjfx-11/repository/
> plugins/
> ?

I have no idea what this repository does or provides, sorry. Tom is the vendor, not me :-)
Comment 32 Carsten Hammer CLA 2019-06-24 09:47:58 EDT
It contains javafx packaged as jar in jar bundles. Eclipse has some problems to handle it though. You cannot browse the content.
Comment 35 Andrey Loskutov CLA 2019-06-27 08:42:57 EDT
(In reply to Andrey Loskutov from comment #27)
> If no one has objections, we should fix the failing tests in
> https://git.eclipse.org/r/144675 & merge the patches: 
> 
> https://git.eclipse.org/r/144674 and https://git.eclipse.org/r/144675
> 
> @Carsten, please update https://git.eclipse.org/r/144675 to fix JDT tests.

I've fixed tests and merged the ant build scripts updates. From now on jar-in-jar loader used by Eclipse "fat jar export" requires Java 6+ as runtime JVM.
Comment 36 Carsten Hammer CLA 2019-07-02 12:16:58 EDT
Do you prefer me to abandon the the attached gerrits for now? In a few days I will not able to react to requests for several weeks and it might the annoying to have such a long gerrit queue with no important change. You can always pick it up again...
Comment 37 Carsten Hammer CLA 2019-08-16 13:45:03 EDT
I abandoned all gerrits. If someone is interested to review I can reopen of course.
Comment 38 Carsten Hammer CLA 2019-09-15 07:35:34 EDT
I reopened some of the gerrits to be able to rebase them for 4.14.
Although I split already all bigger gerrits into smaller pieces some are still quite big (though trivial - most of them). 
Would be great if someone could pick this up or tell me if there is any chance at all to get it in.
Comment 39 Carsten Hammer CLA 2019-09-23 14:17:28 EDT
rebased some more of the split gerrits
Comment 41 Alexander Kurtakov CLA 2019-09-28 04:18:58 EDT
(In reply to Eclipse Genie from comment #40)
> Gerrit change https://git.eclipse.org/r/144560 was merged to [master].
> Commit:
> http://git.eclipse.org/c/jdt/eclipse.jdt.ui.git/commit/
> ?id=78203681c7b9af35b27578abd2642750ea4a1e27

this caused https://download.eclipse.org/eclipse/downloads/drops4/I20190928-0205/compilelogs/plugins/org.eclipse.ltk.core.refactoring_3.10.300.v20190927-1943/@dot.html
Comment 42 Carsten Hammer CLA 2019-09-28 06:05:57 EDT
Does this mean this code is waiting since 2006 to be changed?
see https://bugs.eclipse.org/bugs/show_bug.cgi?id=130909

		for (int c= 0; c < changeGroups.length; c++) {
			TextEditBasedChangeGroup group= changeGroups[c];
			TextEdit[] edits= group.getTextEdits();
			for (int e= 0; e < edits.length; e++) {

				// TODO: enable once following bug is fixed
				// https://bugs.eclipse.org/bugs/show_bug.cgi?id=130909
				// Assert.isTrue(root == edits[e].getRoot(), "Wrong root edit"); //$NON-NLS-1$
			}
		}
Comment 43 Carsten Hammer CLA 2019-09-28 07:05:37 EDT
Added gerrit to activate assertion
see https://git.eclipse.org/r/#/c/150299/
Comment 44 Eclipse Genie CLA 2019-09-29 06:01:53 EDT
New Gerrit change created: https://git.eclipse.org/r/150326
Comment 50 Eclipse Genie CLA 2019-10-20 06:17:41 EDT
New Gerrit change created: https://git.eclipse.org/r/144113
Comment 58 Eclipse Genie CLA 2019-11-21 15:04:35 EST
New Gerrit change created: https://git.eclipse.org/r/144558
Comment 59 Eclipse Genie CLA 2019-12-12 00:22:04 EST
New Gerrit change created: https://git.eclipse.org/r/154374
Comment 62 Simeon Andreev CLA 2019-12-20 09:20:02 EST
A ton of commits here don't reference this bug, which is absurd.

Anyway I updated to 4.15 and I see bug 558510 due to changes here. Please either fix or revert your changes from:

https://git.eclipse.org/r/#/c/152786/4/org.eclipse.jface.text/src/org/eclipse/jface/text/TextViewer.java
Comment 66 Eclipse Genie CLA 2020-01-05 05:34:26 EST
New Gerrit change created: https://git.eclipse.org/r/155221
Comment 67 Eclipse Genie CLA 2020-01-05 06:23:07 EST
New Gerrit change created: https://git.eclipse.org/r/155222
Comment 73 Eclipse Genie CLA 2020-01-07 09:46:58 EST
New Gerrit change created: https://git.eclipse.org/r/155401
Comment 75 Dani Megert CLA 2020-01-07 09:52:07 EST
(In reply to Eclipse Genie from comment #72)
> Gerrit change https://git.eclipse.org/r/144548 was merged to [master].
> Commit:
> http://git.eclipse.org/c/jdt/eclipse.jdt.ui.git/commit/?id=a93ffe117af8abfc1d5f03f8fb805cf27942c8c2
> 
That changes violated https://www.eclipse.org/lists/eclipse-dev/msg11277.html and got reverted for M1.
Comment 76 Eclipse Genie CLA 2020-01-11 05:18:34 EST
New Gerrit change created: https://git.eclipse.org/r/155637
Comment 84 Eclipse Genie CLA 2020-02-23 04:15:15 EST
New Gerrit change created: https://git.eclipse.org/r/158147
Comment 85 Eclipse Genie CLA 2020-02-23 04:15:21 EST
New Gerrit change created: https://git.eclipse.org/r/158146
Comment 86 Eclipse Genie CLA 2020-02-23 04:15:26 EST
New Gerrit change created: https://git.eclipse.org/r/158151
Comment 87 Eclipse Genie CLA 2020-02-23 04:15:31 EST
New Gerrit change created: https://git.eclipse.org/r/158150
Comment 88 Eclipse Genie CLA 2020-02-23 04:15:37 EST
New Gerrit change created: https://git.eclipse.org/r/158149
Comment 89 Eclipse Genie CLA 2020-02-23 04:15:43 EST
New Gerrit change created: https://git.eclipse.org/r/158148
Comment 90 Eclipse Genie CLA 2020-02-23 04:15:48 EST
New Gerrit change created: https://git.eclipse.org/r/158152
Comment 91 Dani Megert CLA 2020-02-23 04:34:08 EST
Please defer those changes to 4.15. We're in RC phase now.
Comment 92 Eclipse Genie CLA 2020-02-23 04:49:06 EST
New Gerrit change created: https://git.eclipse.org/r/158153
Comment 93 Eclipse Genie CLA 2020-02-23 04:49:12 EST
New Gerrit change created: https://git.eclipse.org/r/158157
Comment 94 Eclipse Genie CLA 2020-02-23 04:49:17 EST
New Gerrit change created: https://git.eclipse.org/r/158156
Comment 95 Eclipse Genie CLA 2020-02-23 04:49:23 EST
New Gerrit change created: https://git.eclipse.org/r/158155
Comment 96 Eclipse Genie CLA 2020-02-23 04:49:28 EST
New Gerrit change created: https://git.eclipse.org/r/158154
Comment 97 Eclipse Genie CLA 2020-02-23 04:49:39 EST
New Gerrit change created: https://git.eclipse.org/r/158160
Comment 98 Eclipse Genie CLA 2020-02-23 04:49:45 EST
New Gerrit change created: https://git.eclipse.org/r/158159
Comment 99 Eclipse Genie CLA 2020-02-23 04:49:55 EST
New Gerrit change created: https://git.eclipse.org/r/158158
Comment 100 Eclipse Genie CLA 2020-02-23 04:50:00 EST
New Gerrit change created: https://git.eclipse.org/r/158162
Comment 101 Eclipse Genie CLA 2020-02-23 04:50:05 EST
New Gerrit change created: https://git.eclipse.org/r/158161
Comment 102 Eclipse Genie CLA 2020-02-23 04:50:11 EST
New Gerrit change created: https://git.eclipse.org/r/158165
Comment 103 Eclipse Genie CLA 2020-02-23 04:50:18 EST
New Gerrit change created: https://git.eclipse.org/r/158164
Comment 104 Eclipse Genie CLA 2020-02-23 04:50:24 EST
New Gerrit change created: https://git.eclipse.org/r/158163
Comment 105 Eclipse Genie CLA 2020-02-23 04:50:31 EST
New Gerrit change created: https://git.eclipse.org/r/158168
Comment 106 Eclipse Genie CLA 2020-02-23 04:50:37 EST
New Gerrit change created: https://git.eclipse.org/r/158167
Comment 107 Eclipse Genie CLA 2020-02-23 04:50:44 EST
New Gerrit change created: https://git.eclipse.org/r/158166
Comment 108 Eclipse Genie CLA 2020-03-06 11:33:39 EST
New Gerrit change created: https://git.eclipse.org/r/158927
Comment 133 Eclipse Genie CLA 2020-03-25 13:30:59 EDT
New Gerrit change created: https://git.eclipse.org/r/160003
Comment 136 Fabrice Tiercelin CLA 2020-03-26 13:35:46 EDT
All gerrits are merged, aren't they?
Comment 137 Carsten Hammer CLA 2020-03-26 13:40:52 EDT
Yes, time to close. Of course there is more to do like introduce switch expressions or lambdas but I think it is now much better, thanks Fabrice!
Comment 138 Eclipse Genie CLA 2020-04-15 08:06:25 EDT
New Gerrit change created: https://git.eclipse.org/r/160987
Comment 141 Noopur Gupta CLA 2021-01-20 05:36:22 EST
One of these commits to "use jdk 5 for-each loop" caused a warning in the code:

The local variable fChange is hiding a field from type ChangeCorrectionProposalCore

at org.eclipse.jdt.internal.ui.propertiesfileeditor.PropertiesQuickAssistProcessor, line 367.

Please ensure no new warnings are added before releasing the patches.
Comment 142 Eclipse Genie CLA 2021-01-20 05:40:18 EST
New Gerrit change created: https://git.eclipse.org/r/c/jdt/eclipse.jdt.ui/+/175091