Done: https://issues.apache.org/jira/browse/FELIX-4534

Thank you for your help and your reactivity.

Kind regards,

Ben

Le 13 juin 2014 à 15:06, Richard S. Hall <[email protected]> a écrit :

> It seems like the issue is that the OS name being put into the configMap is 
> being normalized twice, once when it it put into the map then once again when 
> it taken out of the map to be used.
> 
> The problem arises because the normalizeOSName() method doesn't recognize 
> already normalized name, thus it converts "windows7" to "win" even though 
> "windows7" is already normal.
> 
> So, for safety, it seems like we should just check if the name is already 
> normal and if so, do nothing. You could also argue it is not necessary to 
> normalize again since the values in the map are already normalized, which 
> would also solve the issue.
> 
> Perhaps you can open up an issue for this against the framework?
> 
> -> richard
> 
> On 6/12/14, 17:42 , Benoît Thiébault wrote:
>> OK
>> 
>> Line 4481:
>> 
>> String s = null;
>> s = R4LibraryClause.normalizeOSName(System.getProperty("os.name"));
>> m_configMutableMap.put(FelixConstants.FRAMEWORK_OS_NAME, s);
>> 
>> Here, "System.getProperty("os.name")" gives "Windows 7" (with a space)
>> So "s" is "windows7" without a space.
>> 
>> When method match is called (later, thus) it calls :
>> normalizeOSName((String) configMap.get(Constants.FRAMEWORK_OS_NAME)); <=> 
>> normalizeOSName("windows7") without the space.
>> 
>> This returns "win" instead of "windows7".
>> 
>> Here is your bug!
>> 
>> Possible fixes:
>> - completely ignore all spaces by removing them systematically in the input: 
>> value.replaceAll(" ", "");
>> Not very clean
>> - replace
>> if ((value.indexOf(" 7") >= 0) || value.equals("win7"))
>> with
>> if ((value.indexOf("7") >= 0))
>> (no space), but you will have a problem when Windows 2017 is out
>> - other possibilities?
>> 
>> Kind regards,
>> 
>> Ben
>> 
>> Le 12 juin 2014 à 23:26, Richard Hall <[email protected]> a écrit :
>> 
>>> It is initialized in Felix.java. Search for os.name to find where.
>>> On Jun 12, 2014 5:15 PM, "Benoît Thiébault" <[email protected]> wrote:
>>> 
>>>> OK, here are my latests findings.
>>>> 
>>>> I added a few System.out.println in the public static String
>>>> normalizeOSName(String value) method. Namely:
>>>> 
>>>> if (value.startsWith("win")) {
>>>>            String os = "win";
>>>> 
>>>> System.out.println("R4LibraryClause.normalizeOSName():value.startsWith('win')");
>>>>            System.out.println("value:" + value);
>>>> [...]
>>>>            System.out.println("Returned OS:" + os);
>>>>            return os;
>>>>        }
>>>> 
>>>> I also removed the bundle containing the native libraries from the
>>>> "bundles" folder in order to install it manually.
>>>> 
>>>> 1) When the framework starts, it starts all the bundles and calls the
>>>> normalizeOSName a first time. Code output:
>>>> R4LibraryClause.normalizeOSName():value.startsWith('win')
>>>> value:windows 7 <- notice the space between "windows" and "7"
>>>> Returned OS:windows7
>>>> 
>>>> -> OK
>>>> 
>>>> 2) I then install the native bundle: "install
>>>> file:org-keridwen-vtk-win7-64b-2.0.3-SNAPSHOT.jar"
>>>> 
>>>> The normalizeOSName method is called twice in a raw (I guess by the parse
>>>> method first, then by the match method). Code output:
>>>> R4LibraryClause.normalizeOSName():value.startsWith('win') <- first call,
>>>> works
>>>> value:win7 <- OK for the if statement line 392
>>>> Returned OS:windows7
>>>> os.name:Windows 7 <- System.out.println at the start of the match method
>>>> os.arch:amd64
>>>> R4LibraryClause.normalizeOSName():value.startsWith('win') <- second call,
>>>> fails
>>>> value:windows7 <- NOT OK, there is no space between "windows" and "7",
>>>> line 392 won't catch it
>>>> Returned OS:win <- NOT OK
>>>> normal_osname:win;
>>>> normal_processor:x86-64;
>>>> normal_osversion:6.1.0;
>>>> normal_language:fr;
>>>> currentOSName:win
>>>> osname[0]:windows7
>>>> R4LibraryClause.match()-checkOSNames returned false
>>>> 
>>>> So the parse() method succeeds while the match() method does not. The
>>>> input map configMap is suspect #1. Don't really know where it is 
>>>> initialized
>>>> 
>>>> Kind regards,
>>>> 
>>>> Ben
>>>> 
>>>> Le 12 juin 2014 à 22:33, Benoît Thiébault <[email protected]> a écrit
>>>> :
>>>> 
>>>>> Hi Richard,
>>>>> 
>>>>> Here is what I did: I added a few System.out.println in the
>>>> R4LibraryClause.match() and checkOSNames() methods and recompiled Felix
>>>> Framework (4.5.0-SNAPSHOT thus)
>>>>> The modified code:
>>>>> public boolean match(final Map configMap) throws BundleException {
>>>>>       System.out.println("os.name:" + System.getProperty("os.name"));
>>>>>       System.out.println("os.arch:" + System.getProperty("os.arch"));
>>>>>       final String normal_osname = normalizeOSName((String)
>>>> configMap.get(Constants.FRAMEWORK_OS_NAME));
>>>>>       System.out.println("normal_osname:" + normal_osname + ";");
>>>>>       final String normal_processor = normalizeProcessor((String)
>>>> configMap.get(Constants.FRAMEWORK_PROCESSOR));
>>>>>       System.out.println("normal_processor:" + normal_processor + ";");
>>>>>       final String normal_osversion = normalizeOSVersion((String)
>>>> configMap.get(Constants.FRAMEWORK_OS_VERSION));
>>>>>       System.out.println("normal_osversion:" + normal_osversion + ";");
>>>>>       final String normal_language = (String)
>>>> configMap.get(Constants.FRAMEWORK_LANGUAGE);
>>>>>       System.out.println("normal_language:" + normal_language + ";");
>>>>> 
>>>>>       // Check library's osname.
>>>>>       if (!checkOSNames(normal_osname, getOSNames())) {
>>>>>           System.out.println("R4LibraryClause.match()-checkOSNames
>>>> returned false");
>>>>>           return false;
>>>>>       }
>>>>> 
>>>>>       // Check library's processor.
>>>>>       if (!checkProcessors(normal_processor, getProcessors())) {
>>>>>           System.out.println("R4LibraryClause.match()-checkProcessors
>>>> returned false");
>>>>>           return false;
>>>>>       }
>>>>> 
>>>>>       // Check library's osversion if specified.
>>>>>       if ((getOSVersions() != null) && (getOSVersions().length > 0)
>>>>>               && !checkOSVersions(normal_osversion, getOSVersions())) {
>>>>>           System.out.println("R4LibraryClause.match()-checkOSVersion
>>>> returned false");
>>>>>           return false;
>>>>>       }
>>>>> 
>>>>>       // Check library's language if specified.
>>>>>       if ((getLanguages() != null) && (getLanguages().length > 0) &&
>>>> !checkLanguages(normal_language, getLanguages())) {
>>>>>           System.out.println("R4LibraryClause.match()-checkLanguages
>>>> returned false");
>>>>>           return false;
>>>>>       }
>>>>> 
>>>>>       // Check library's selection-filter if specified.
>>>>>       if ((getSelectionFilter() != null) &&
>>>> (getSelectionFilter().length() >= 0)
>>>>>               && !checkSelectionFilter(configMap,
>>>> getSelectionFilter())) {
>>>> System.out.println("R4LibraryClause.match()-checkSelectionFilter returned
>>>> false");
>>>>>           return false;
>>>>>       }
>>>>> 
>>>>>       System.out.println("R4LibraryClause.match() -> returned true");
>>>>>       return true;
>>>>>   }
>>>>> 
>>>>> private boolean checkOSNames(final String currentOSName, final String[]
>>>> osnames) {
>>>>>       final boolean win32 = currentOSName.startsWith("win") &&
>>>> !currentOSName.equals("windowsce");
>>>>>       System.out.println("currentOSName:" + currentOSName);
>>>>>       for (int i = 0; (osnames != null) && (i < osnames.length); i++) {
>>>>>           System.out.println("osname[" + i + "]:" + osnames[i]);
>>>>>           if (osnames[i].equals(currentOSName) ||
>>>> ("win32".equals(osnames[i]) && win32)) {
>>>>>               return true;
>>>>>           }
>>>>>       }
>>>>>       return false;
>>>>>   }
>>>>> 
>>>>> The output when run on Windows:
>>>>> os.name:Windows 7
>>>>> os.arch:amd64
>>>>> normal_osname:win;
>>>>> normal_processor:x86-64;
>>>>> normal_osversion:6.1.0;
>>>>> normal_language:fr;
>>>>> currentOSName:win
>>>>> osname[0]:windows7
>>>>> R4LibraryClause.match()-checkOSNames returned false
>>>>> 
>>>>> So the problem seems to be the normal_osname that is win and not
>>>> windows7…
>>>>> Do you confirm?
>>>>> 
>>>>> Kind regards,
>>>>> Ben
>>>>> 
>>>>> Le 12 juin 2014 à 21:48, Richard S. Hall <[email protected]> a écrit
>>>> :
>>>>>> Perhaps you start the JVM up suspended with debug enabled and set a
>>>> break point up at R4LibraryClause.match() and see precisely why it is
>>>> failing?
>>>>>> The code in there is pretty self explanatory.
>>>>>> 
>>>>>> -> richard
>>>> --
>>>> Dr Benoît Thiébault
>>>> Project Manager
>>>> 
>>>>  Artenum Toulouse - Science & Groupware
>>>>  http://www.artenum.com
>>>> 
>>>>      Bâtiment Calfocenter
>>>>      10, rue Marguerite-Long
>>>>      31320 Castanet-Tolosan
>>>>      France
>>>>      Phone: +33 (0)5 82 95 19 00
>>>> 
>>>> 
>>>> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
> 

-- 
Dr Benoît Thiébault
Project Manager

  Artenum Toulouse - Science & Groupware
  http://www.artenum.com

      Bâtiment Calfocenter
      10, rue Marguerite-Long
      31320 Castanet-Tolosan
      France
      Phone: +33 (0)5 82 95 19 00


Reply via email to