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

ICU-21295 Fix for Java version number overflow problem in 58 #1460

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import com.ibm.icu.text.UTF16;
import com.ibm.icu.text.UnicodeSet;
import com.ibm.icu.util.VersionInfo;

/**
* @author Niti Hantaweepant
Expand Down Expand Up @@ -65,13 +64,10 @@ public CharsetUTF16(String icuCanonicalName, String javaCanonicalName, String[]
this.endianXOR = ENDIAN_XOR_LE;
}

/* UnicodeBig and UnicodeLittle requires maxBytesPerChar set to 4 in Java 5 or less */
if ((VersionInfo.javaVersion().getMajor() == 1 && VersionInfo.javaVersion().getMinor() <= 5)
&& (isEndianSpecified && version == 1)) {
maxBytesPerChar = 4;
} else {
maxBytesPerChar = 2;
}
// UnicodeBig and UnicodeLittle used to require maxBytesPerChar set to 4 in Java 5 or less,
// but it's no longer necessary for newer Java versions. Java 5 or older runtime is no
// longer supported.
maxBytesPerChar = 2;

minBytesPerChar = 2;
maxCharsPerByte = 1;
Expand Down
50 changes: 0 additions & 50 deletions icu4j/main/classes/core/src/com/ibm/icu/util/VersionInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -342,56 +342,6 @@ public static VersionInfo getInstance(int major)
return getInstance(major, 0, 0, 0);
}

private static volatile VersionInfo javaVersion;

/**
* @internal
* @deprecated This API is ICU internal only.
*/
@Deprecated
public static VersionInfo javaVersion() {
if (javaVersion == null) {
synchronized(VersionInfo.class) {
if (javaVersion == null) {
String s = System.getProperty("java.version");
// clean string
// preserve only digits, separated by single '.'
// ignore over 4 digit sequences
// does not test < 255, very odd...

char[] chars = s.toCharArray();
int r = 0, w = 0, count = 0;
boolean numeric = false; // ignore leading non-numerics
while (r < chars.length) {
char c = chars[r++];
if (c < '0' || c > '9') {
if (numeric) {
if (count == 3) {
// only four digit strings allowed
break;
}
numeric = false;
chars[w++] = '.';
++count;
}
} else {
numeric = true;
chars[w++] = c;
}
}
while (w > 0 && chars[w-1] == '.') {
--w;
}

String vs = new String(chars, 0, w);

javaVersion = VersionInfo.getInstance(vs);
}
}
}
return javaVersion;
}

/**
* Returns the String representative of VersionInfo in the format of
* "major.minor.milli.micro"
Expand Down