docs: @SuppressWarnings({"checkstyle:cyclomaticcomplexity", "checkstyle:variabledeclarationusagedistance",
  			"checkstyle:npathcomplexity"})
  	private static void initializeSREs() {
  		ISREInstall[] newSREs = new ISREInstall[0];
  		boolean savePrefs = false;
  		LOCK.lock();
  		final String previousDefault = defaultSREId;
  		try {
  			if (platformSREInstalls == null) {
  				platformSREInstalls = new HashSet<>();
  				ALL_SRE_INSTALLS.clear();
  
  				// Install the SREs from the Eclipse extension points
  				if (enableSreExtensionPoints) {
  					initializeSREExtensions();
  				}
  				// install the SREs from the user-defined preferences.
  				final String predefinedDefaultId = Strings.nullToEmpty(initializePersistedSREs());
  
  				newSREs = new ISREInstall[ALL_SRE_INSTALLS.size()];
  
  				// Verify default SRE is valid
  				ISREInstall initDefaultSRE = null;
  				final Iterator<ISREInstall> iterator = ALL_SRE_INSTALLS.values().iterator();
  				for (int i = 0; iterator.hasNext(); ++i) {
  					final ISREInstall sre = iterator.next();
  					newSREs[i] = sre;
  					if (sre.getValidity().isOK()) {
  						if (initDefaultSRE == null
  								&& sre.getId().equals(predefinedDefaultId)) {
  							initDefaultSRE = sre;
  						}
  					}
  				}
  
  				final String oldDefaultId = initDefaultSRE == null ? null : initDefaultSRE.getId();
  				defaultSREId = oldDefaultId;
  				savePrefs = true;
  			}
  
  			if (Strings.isNullOrEmpty(defaultSREId)) {
  				ISREInstall firstSRE = null;
  				ISREInstall firstValidSRE = null;
  				final Iterator<ISREInstall> iterator = ALL_SRE_INSTALLS.values().iterator();
  				while (firstValidSRE == null && iterator.hasNext()) {
  					final ISREInstall sre = iterator.next();
  					if (firstSRE == null) {
  						firstSRE = sre;
  					}
  					if (sre.getValidity().isOK()) {
  						firstValidSRE = sre;
  					}
  				}
  				if (firstValidSRE == null) {
  					firstValidSRE = firstSRE;
  				}
  				if (firstValidSRE != null) {
  					savePrefs = true;
  					defaultSREId = firstValidSRE.getId();
  				}
  			}
  		} finally {
  			LOCK.unlock();
  		}
  
  		// Save the preferences.
  		if (savePrefs) {
  			safeSaveSREConfiguration();
  		}
  
  		if (newSREs.length > 0) {
  			for (final ISREInstall sre : newSREs) {
  				fireSREAdded(sre);
  			}
  		}
  
  		if (!Objects.equal(previousDefault, defaultSREId)) {
  			fireDefaultSREChanged(
  					getSREFromId(previousDefault),
  					getSREFromId(defaultSREId));
  		}
  	}