Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JavaVersion: find a better way to keep up with Java SE release cadence #2578

Open
cdietrich opened this issue Oct 25, 2017 · 10 comments
Open

Comments

@cdietrich
Copy link
Contributor

cdietrich commented Oct 25, 2017

Adapting constants and switches at 50 places is bad. So we need a better way for that

see changes for eclipse/xtext-core#500

same for the consumption of asm

@cdietrich
Copy link
Contributor Author

We all gonna die ...

@cdietrich
Copy link
Contributor Author

places to look at

  • org.eclipse.xtext.xbase.ui.builder.XbaseBuilderPreferenceAccess.fromCompilerSourceLevel(String)
  • org.eclipse.xtext.xbase.compiler.InMemoryJavaCompiler.toClassFmt(JavaVersion)
  • org.eclipse.xtext.xbase.testing.InMemoryJavaCompiler.toClassFmt(JavaVersion)
  • org.eclipse.xtext.java.resource.JavaDerivedStateComputer.toJdtVersion(JavaVersion)
  • org.eclipse.xtext.xbase.idea.facet.XbaseGeneratorConfigProvider.getTargetJavaVersion(XbaseGeneratorConfigurationState, Module)

maybe others

@cdietrich
Copy link
Contributor Author

having an enum is bad as well. we would need to ship a new xtext version every 6 months

cdietrich referenced this issue in eclipse/xtext-core Jan 15, 2018
Signed-off-by: Christian Dietrich <[email protected]>
cdietrich referenced this issue in eclipse/xtext-eclipse Jan 15, 2018
cdietrich referenced this issue in eclipse/xtext-core Jan 15, 2018
Signed-off-by: Christian Dietrich <[email protected]>
cdietrich referenced this issue in eclipse/xtext-eclipse Jan 15, 2018
cdietrich referenced this issue in eclipse/xtext-core Jan 15, 2018
Signed-off-by: Christian Dietrich <[email protected]>
cdietrich referenced this issue in eclipse/xtext-eclipse Jan 15, 2018
cdietrich referenced this issue in eclipse/xtext-core Jan 15, 2018
[#517] Move More Code to JavaVersion
@cdietrich
Copy link
Contributor Author

will do it the manual way at least for 9+10

@cdietrich
Copy link
Contributor Author

@szarnekow the main different for the places is the error treatment

	private def long toClassFmt(JavaVersion version) {
		switch(version) {
			case JAVA5: return ClassFileConstants.JDK1_5
			case JAVA6: return ClassFileConstants.JDK1_6
			case JAVA7: return ClassFileConstants.JDK1_7
			case JAVA8: return ((ClassFileConstants.MAJOR_VERSION_1_7 + 1) << 16) + ClassFileConstants.MINOR_VERSION_0 // ClassFileConstants.JDK1_8
			case JAVA9: return ((ClassFileConstants.MAJOR_VERSION_1_7 + 2) << 16) + ClassFileConstants.MINOR_VERSION_0 // ClassFileConstants.JDK1_9
		}
	}

vs

protected def long toJdtVersion(JavaVersion version) {
        switch (version) {
            case JAVA5:
                ClassFileConstants.JDK1_5
            case JAVA6:
                ClassFileConstants.JDK1_6
            case JAVA7:
                ClassFileConstants.JDK1_7
            case JAVA8: {
                try {
                    ClassFileConstants.getField('JDK1_8').getLong(null)
                } catch (NoSuchFieldException e) {
                    ClassFileConstants.JDK1_7
                }
            }
            case JAVA9: {
                try {
                    ClassFileConstants.getField('JDK9').getLong(null)
                } catch (NoSuchFieldException e) {
                    ClassFileConstants.JDK1_7
                }
            }
        }
    }

do you remember why it is done this way. and if there is no reason what is the preferred way to unify the behaviours

@szarnekow
Copy link
Contributor

Should be fine to do it without reflection.

cdietrich referenced this issue in eclipse/xtext-core Mar 27, 2018
cdietrich referenced this issue in eclipse/xtext-extras Mar 27, 2018
cdietrich referenced this issue in eclipse/xtext-eclipse Mar 27, 2018
cdietrich referenced this issue in eclipse/xtext-eclipse Mar 27, 2018
cdietrich referenced this issue in eclipse/xtext-xtend Mar 27, 2018
cdietrich referenced this issue in eclipse/xtext-eclipse Mar 27, 2018
@cdietrich cdietrich self-assigned this Mar 27, 2018
@cdietrich cdietrich added this to the milestone Mar 27, 2018
cdietrich referenced this issue in eclipse/xtext-eclipse Mar 27, 2018
cdietrich referenced this issue in eclipse/xtext-core Mar 28, 2018
[eclipse/xtext-core#517] Moved Class File Constant Calculation to JavaVersion Enum
cdietrich referenced this issue in eclipse/xtext-extras Mar 28, 2018
cdietrich referenced this issue in eclipse/xtext-eclipse Mar 28, 2018
cdietrich referenced this issue in eclipse/xtext-extras Mar 28, 2018
[eclipse/xtext-core#517] Moved Class File Constant Calculation to JavaVersion Enum
cdietrich referenced this issue in eclipse/xtext-eclipse Mar 28, 2018
[eclipse/xtext-core#517] Moved Class File Constant Calculation to JavaVersion Enum
@cdietrich
Copy link
Contributor Author

unified the code a bit more => fewer places that need adaption

@cdietrich cdietrich modified the milestone: Apr 23, 2018
@ArneDeutsch
Copy link
Contributor

Hi Christian. I checked the code you referenced. For me it seems you have enhanced the solution as far as possible. Doing it better then with the enum seems not possible to me. Even some configuration file with constants for new java versions would need some update. On the other hand the values can not be reliable be computed as the format has been changed in the past and probably will change in the future as well.

Is here anything left that we can do to improve the situation that I do not see?

@cdietrich
Copy link
Contributor Author

this ticket is to think about a non enum based solution or a enum based solution that works with feature patches

@cdietrich cdietrich removed their assignment May 29, 2018
@cdietrich cdietrich modified the milestones: Release_2.15, Release_2.16 Aug 31, 2018
@cdietrich
Copy link
Contributor Author

we will support lts versions only. next likely 21

@cdietrich cdietrich transferred this issue from eclipse/xtext-core Apr 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants