How to normalize Java "1.8.0_111(64bit)" to "8" (and other messy versions) for EOL matching
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
37m ago
by cleaning the raw version in two passes: first a common cleanup that applies to every product, then a product-specific mode chosen on the normalization rule. Lifecycle sources such as endoflife.date use cycles like 8, 11, 17, so 1.8.0_111 will never match unless you convert it.
Step 1: Common cleanup (all products)
_verText: function (s) {
s = String(s || '').trim();
s = s.replace(/\s*\(?\s*(x64|x86|64\s*bit|32\s*bit|amd64|i386|ia64)\s*\)?/gi, ''); // bitness
s = s.replace(/^v\.?\s*/i, ''); // leading v / v.
var m = s.match(/(\d+(?:\.\d+)+|\d+)/); // first numeric version
return m ? m[1] : ''; // 1.8.0_111(64bit) -> 1.8.0
}Step 2: Add a version mode field to your normalization rule
Add a choice field Version mode (u_version_mode) with: auto, java, year, major, regex, raw.
Step 3: Apply the mode after the cleanup
extractVersion: function (mode, raw, regex) {
if (mode === 'raw') return String(raw || '').trim();
if (mode === 'regex' && regex) { var r = String(raw).match(new RegExp(regex)); if (r) return r[1] || r[0]; }
var v = this._verText(raw);
if (mode === 'java') { var j = v.match(/^1\.([4-9])(?:[._].*)?$/); if (j) v = j[1]; } // 1.8.0 -> 8, 11.0.2 stays
if (mode === 'major') v = v.split('.')[0]; // 5.16.3 -> 5
if (mode === 'year') { var y = String(raw).match(/(19|20)\d{2}/); if (y) v = y[0]; } // Server 2012 R2 -> 2012
return v;
}
Step 4: Match by prefix on segment boundaries
Tip: for versions older than anything your lifecycle source still tracks (e.g. Perl 5.10 when the oldest tracked cycle is 5.26 and it has already ended), you can safely infer EOL instead of leaving them unmatched — make that behaviour a system property so it can be switched off.
If this helped, please mark it as Helpful 👍