@@ -90,8 +90,14 @@ private TargetPlatformHelper() { // static use only
9090 "(_\\ d+(?<!x86_64|ia64_32)(\\ .\\ d+(\\ .\\ d+(\\ .[a-zA-Z0-9_-]+)?)?)?(\\ .\\ w+)?$)|(\\ .(?:jar|war|zip)$)" , //$NON-NLS-1$
9191 Pattern .CASE_INSENSITIVE );
9292
93+ /**
94+ * Pattern for matching escaped colons and forward slash+colon combinations
95+ * in bundle paths.
96+ */
97+ private static final Pattern PATTERN_PATH_COLON = Pattern .compile ("\\ \\ :|/:" );//$NON-NLS-1$
98+
9399 private static Map <String , String > fgCachedLocations ;
94- private static Map <ITargetHandle , List <TargetDefinition >> fgCachedTargetDefinitionMap = new HashMap <>();
100+ private static final Map <ITargetHandle , List <TargetDefinition >> fgCachedTargetDefinitionMap = new HashMap <>();
95101
96102 public static Properties getConfigIniProperties () {
97103 File iniFile = new File (TargetPlatform .getLocation (), "configuration/config.ini" ); //$NON-NLS-1$
@@ -161,7 +167,7 @@ public static String stripPathInformation(String osgiBundles) {
161167 StringTokenizer tokenizer = new StringTokenizer (osgiBundles , "," ); //$NON-NLS-1$
162168 while (tokenizer .hasMoreElements ()) {
163169 String token = tokenizer .nextToken ();
164- token = token .replaceAll ("\\ \\ :|/:" , ":" ); //$NON-NLS-1$ //$NON-NLS-2 $
170+ token = PATTERN_PATH_COLON . matcher ( token ) .replaceAll (":" ); //$NON-NLS-1$
165171
166172 // read up until the first @, if there
167173 int atIndex = token .indexOf ('@' );
@@ -317,7 +323,7 @@ public static Set<String> getApplicationNameSet() {
317323
318324 public static String [] getApplicationNames () {
319325 Set <String > result = getApplicationNameSet ();
320- return result .toArray (new String [result . size ()] );
326+ return result .toArray (String []:: new );
321327 }
322328
323329 public static Set <String > getProductNameSet () {
@@ -424,32 +430,19 @@ public static String getTargetVersionString() {
424430 Version vid = new Version (version );
425431 int major = vid .getMajor ();
426432 int minor = vid .getMinor ();
427- if (major == 3 && minor == 0 ) {
428- return ICoreConstants .TARGET30 ;
429- }
430- if (major == 3 && minor == 1 ) {
431- return ICoreConstants .TARGET31 ;
432- }
433- if (major == 3 && minor == 2 ) {
434- return ICoreConstants .TARGET32 ;
435- }
436- if (major == 3 && minor == 3 ) {
437- return ICoreConstants .TARGET33 ;
438- }
439- if (major == 3 && minor == 4 ) {
440- return ICoreConstants .TARGET34 ;
441- }
442- if (major == 3 && minor == 5 ) {
443- return ICoreConstants .TARGET35 ;
444- }
445- if (major == 3 && minor == 6 ) {
446- return ICoreConstants .TARGET36 ;
447- }
448- if (major == 3 && minor == 7 ) {
449- return ICoreConstants .TARGET37 ;
450- }
451- if (major == 3 && minor == 8 ) {
452- return ICoreConstants .TARGET38 ;
433+ if (major == 3 ) {
434+ return switch (minor ) {
435+ case 0 -> ICoreConstants .TARGET30 ;
436+ case 1 -> ICoreConstants .TARGET31 ;
437+ case 2 -> ICoreConstants .TARGET32 ;
438+ case 3 -> ICoreConstants .TARGET33 ;
439+ case 4 -> ICoreConstants .TARGET34 ;
440+ case 5 -> ICoreConstants .TARGET35 ;
441+ case 6 -> ICoreConstants .TARGET36 ;
442+ case 7 -> ICoreConstants .TARGET37 ;
443+ case 8 -> ICoreConstants .TARGET38 ;
444+ default -> ICoreConstants .TARGET_VERSION_LATEST ;
445+ };
453446 }
454447 }
455448 return ICoreConstants .TARGET_VERSION_LATEST ;
@@ -693,17 +686,11 @@ public static Map<ITargetHandle, List<TargetDefinition>> getTargetDefinitionMap(
693686 * in target platform preference page, target location and target status
694687 * bar.
695688 */
696- public static void addTargetDefinitionMap (TargetDefinition targetDefinition ) {
697- if (fgCachedTargetDefinitionMap .containsKey (targetDefinition .getHandle ())) {
698- List <TargetDefinition > targets = fgCachedTargetDefinitionMap .get (targetDefinition .getHandle ());
699- if (!targets .contains (targetDefinition )) {
700- targets .add (0 , targetDefinition );
701- }
702-
703- } else {
704- List <TargetDefinition > target = new ArrayList <>();
705- target .add (targetDefinition );
706- fgCachedTargetDefinitionMap .put (targetDefinition .getHandle (), target );
689+ public static synchronized void addTargetDefinitionMap (TargetDefinition targetDefinition ) {
690+ ITargetHandle handle = targetDefinition .getHandle ();
691+ List <TargetDefinition > targets = fgCachedTargetDefinitionMap .computeIfAbsent (handle , k -> new ArrayList <>());
692+ if (!targets .contains (targetDefinition )) {
693+ targets .add (0 , targetDefinition );
707694 }
708695 }
709696}
0 commit comments