-
Notifications
You must be signed in to change notification settings - Fork 486
feat(FeatureClassLoader): support class loading of Java 9+ #426
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
Changes from 4 commits
9fce763
ac3a496
e28d8c3
f4efc4a
e0af947
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* Copyright 2016 DiffPlug | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.diffplug.spotless; | ||
|
||
/** | ||
* Helper class providing Java version information | ||
* | ||
*/ | ||
public final class JavaVersion { | ||
bender316 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
private static final String JAVA_VERSION; | ||
|
||
private static final int MAJOR_VERSION; | ||
|
||
static { | ||
JAVA_VERSION = System.getProperty("java.version"); | ||
final String[] versionStrings = JAVA_VERSION.split("\\."); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we write like, double version = Double.parseDouble(System.getProperty("java.specification.version"));
if(version > 1.8) {
//Do something
} else {
//Do something
} Just curious, why? and why not? It eliminates the need of this Utility class. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems like java.specification.version just returns 1.x or 11 (in cases of new versioning) and not the full version. I didn't know about this property. So IMO we could use this and get rid of the JavaVersion class. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, apologies @mohamedanees6, I didn't notice Your call @bender316 :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will switch to the proposal above and remove the JavaVersion class. |
||
int major = Integer.parseInt(versionStrings[0]); | ||
// Java version prior to 10 used 1.x versioning | ||
if (major == 1) { | ||
major = Integer.parseInt(versionStrings[1]); | ||
} | ||
MAJOR_VERSION = major; | ||
} | ||
|
||
/** | ||
* @return the full Java version (e.g. 1.8.0_211) | ||
*/ | ||
public static String getJavaVersion() { | ||
return JAVA_VERSION; | ||
} | ||
|
||
/** | ||
* @return the major version of the java release (e.g. 8 or 11) | ||
*/ | ||
public static int getMajorVersion() { | ||
return MAJOR_VERSION; | ||
} | ||
|
||
} |
Uh oh!
There was an error while loading. Please reload this page.