added VersionUtil class and utility method for obtaining file version information#562
Merged
dblock merged 1 commit intojava-native-access:masterfrom Dec 14, 2015
mlfreeman2:versionutils
Merged
added VersionUtil class and utility method for obtaining file version information#562dblock merged 1 commit intojava-native-access:masterfrom mlfreeman2:versionutils
dblock merged 1 commit intojava-native-access:masterfrom
mlfreeman2:versionutils
Conversation
Contributor
There was a problem hiding this comment.
Instead of returning an int[], return a class - e.g.:
public class VersionInfo implements Serializable, Cloneable, Comparable<VersionInfo> {
private static final long serialVersionUID = ...generate it via the IDE...;
private int major = -1;
private int minor = -1;
private int buildNumber = -1;
private int revision = -1;
public VersionInfo() {
super();
}
public VersionInfo(int major, int minor, int buildNumber, int release) {
this.minor/major/build/release = ...respective parameter...
}
public int getMajor/Minor/BuildNumber/Release() {
return ...respective member...
}
public void setMajor/Minor/BuildNumber/Release(int value) {
this..minor/major/build/release = value;
}
@Override
public int hashCode() {
...
}
@Override
public boolean equals(Object o) {
...check if null, this == o and getClass() == o.getClass()...
return compare((VersionInfo) o) == 0;
}
@Override
public int compare(VersionInfo other) {
..check if other is null or this...
...compare major/minor/build/release - in this order...
}
@Override
public VersionInfo clone() {
try {
return getClass().cast(super.clone());
} catch(CloneNotSupportedException e) { // unexpected
throw new RuntimeException("Failed to clone: " + toString(), e);
}
}
@Override
public String toString() {
return getMajor() + "." + getMinor() + "." + getBuildNumber() + "." + getRevision();
}
}This way one does not need to remember which index in the array is the major/minor/build/revision...
Contributor
Author
There was a problem hiding this comment.
How does this sound as an option?
- Change the method name to
getFileVersionInfo() - Return the
VS_FIXEDFILEINFOthat I already have in the function. - Add the following four getters to
VS_FIXEDFILEINFO:
public int getFileVersionMajor() {
return dwFileVersionMS.intValue() >>> 16;
}
public int getFileVersionMinor() {
return dwFileVersionMS.intValue() & 0xffff;
}
public int getFileVersionRevision() {
return dwFileVersionLS.intValue() >>> 16;
}
public int getFileVersionBuild() {
return dwFileVersionLS.intValue() & 0xffff;
}
Member
|
This is great. Feel free to address @lgoldstein's minor test comments and please fix that period! (very important :)). |
Contributor
Author
|
@dblock, @lgoldstein - feedback should be addressed. |
dblock
added a commit
that referenced
this pull request
Dec 14, 2015
added VersionUtil class and utility method for obtaining file version information
Member
|
Merged. |
mstyura
pushed a commit
to mstyura/jna
that referenced
this pull request
Sep 9, 2024
Motivation: There are new releases of java. Modifications: Upgrade java versions to latest release Result: Use latest versions on the CI
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
It obtains the 'major', 'minor', 'revision', and 'build' version from a given file.
Added unit test for it - it does not require any new Win32 mappings for Version.dll