[2.0.5] Win11: Env.getOSVersion() gets incorrect version (10.0) --- Java/Windows problem (fixed with Java18??) - temp-fix in 2.0.6

Bug #1946925 reported by Chetan
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SikuliX
Fix Committed
Critical
RaiMan

Bug Description

tracked on GitHub: https://github.com/RaiMan/SikuliX1/issues/479
----------------------------------------------------------------

looks like there is an open bug for windows 11
that is expected to be fixed in java 18
https://bugs.openjdk.java.net/browse/JDK-8274840

IMHO this is not really a Java bug, but a quirk in Windows 11

systeminfo shows this (language German):

Betriebssystemname: Microsoft Windows 11 Pro
Betriebssystemversion: 10.0.22000 Nicht zutreffend Build 22000

So the version is actually shown as 10.0 which is reported by Java

----------------------------------------------------------------------

--- workaround ---
(based on Chetan's idea from comment #7)

windowsVersion = run("systeminfo").split("\n")[2].split(":")[1].strip()
print windowsVersion

will show on Win11: Microsoft Windows 11 Pro

(tested on Win11 and on Win10)
--------------------------------------------------------------

Env.getOSVersion() gets incorrect version for Windows 11

we are expecting version to be returned as 11 but get 10.0

OS: Win 11
Java : 14

Revision history for this message
Chetan (cshamdas) wrote :
description: updated
Revision history for this message
RaiMan (raimund-hocke) wrote : Re: [2.0.5] Win11: Env.getOSVersion() gets incorrect version (10.0)

Since I am still not able to test a Win11 system (update not yet available), I cannot test it.

But internally simply the Java SystemProperty os.version is reported.

So you might check this value on your system.
Looks like a Java problem.

summary: - Env.getOSVersion() gets incorrect version for Windows 11
+ [2.0.5] Win11: Env.getOSVersion() gets incorrect version (10.0)
Changed in sikuli:
status: New → Opinion
importance: Undecided → Medium
assignee: nobody → RaiMan (raimund-hocke)
milestone: none → 2.0.6
Revision history for this message
Chetan (cshamdas) wrote :

yes right below is the output. however will updating java create issues on UI automation on windows 10 or it is safe to update

C:\Users\labuser\Desktop>"C:\Program Files\Java\jdk-14.0.2\bin\java" Main
Name: Windows 10
Version: 10.0
Architecture: amd64

Revision history for this message
Chetan (cshamdas) wrote :

tried with java 17 but still same issue. looks like java problem

Revision history for this message
Chetan (cshamdas) wrote :

looks like there is an open bug for windows 11 that is expected to be fixed in java 18
https://bugs.openjdk.java.net/browse/JDK-8274840

Revision history for this message
RaiMan (raimund-hocke) wrote : Re: [2.0.5] Win11: Env.getOSVersion() gets incorrect version (10.0) --- Java problem (fixed with Java18)

thanks for the info.

I will track it on GitHub

summary: - [2.0.5] Win11: Env.getOSVersion() gets incorrect version (10.0)
+ [2.0.5] Win11: Env.getOSVersion() gets incorrect version (10.0) --- Java
+ problem (fixed with Java18)
description: updated
RaiMan (raimund-hocke)
description: updated
Changed in sikuli:
status: Opinion → Confirmed
Revision history for this message
Chetan (cshamdas) wrote :

workaround for other user who may see similar issue
get OS details from sysinfo
        cmd='powershell\nsysteminfo | findstr /B /C:\"OS Name\"'
        cmdoutput=ExecuteWinCommand(cmd)

def ExecuteWinCommand(cmdToExecute):
    #cmdToExecute='cmd\nsysteminfo | findstr /B /C:\"OS Name\"'
    returnCode = runScript(cmdToExecute)
    commandOutput = RunTime.get().getLastCommandResult()
    sleep(2)
    logInfo("Command Output:" +str(commandOutput) +"return code" +str(returnCode))

    return commandOutput

Revision history for this message
RaiMan (raimund-hocke) wrote :

Thanks for this idea :-)

I will implement it for Win11 on the Java level in 2.0.6, so we have a general solution until it is finally fixed in Java 18 (hopefully ;-).

description: updated
Revision history for this message
RaiMan (raimund-hocke) wrote : Re: [2.0.5] Win11: Env.getOSVersion() gets incorrect version (10.0) --- Java/Windows problem (fixed with Java18??)

@Chetan
I reduced the workaround to a one-liner, that is independant from language setting.

description: updated
summary: - [2.0.5] Win11: Env.getOSVersion() gets incorrect version (10.0) --- Java
- problem (fixed with Java18)
+ [2.0.5] Win11: Env.getOSVersion() gets incorrect version (10.0) ---
+ Java/Windows problem (fixed with Java18??)
description: updated
RaiMan (raimund-hocke)
description: updated
RaiMan (raimund-hocke)
summary: [2.0.5] Win11: Env.getOSVersion() gets incorrect version (10.0) ---
- Java/Windows problem (fixed with Java18??)
+ Java/Windows problem (fixed with Java18??) - temp-fix in 2.0.6
Changed in sikuli:
status: Confirmed → Fix Committed
importance: Medium → Critical
Revision history for this message
Chetan (cshamdas) wrote :

thanks for taking it up Raiman. appreciated

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.