-
Notifications
You must be signed in to change notification settings - Fork 218
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
INVALID_HANDLE_VALUE is 64bit, GetConsoleMode() always returns failure #1012
Comments
Screenshot of my guess at the problematic area. The 3 handles in |
Could you explain how you use jansi, what the behaviour with the previous jansi, and the current behaviour ? |
Good catch. That should be fixed.
Are you referring to the
Can you run |
I am a new user of both jansi and when researching it org.jline as found as I am looking for a cross-platform (main desktops) CLI solution that meets modern requirements that supports native. My example starter program looks like (I am to be using picocli.ansi=true support in due course):
I have been using a number of terminal scenarios:
When working (only with jansi:jansi) all have consistently reported type==Redirected. I have no idea what that term means on windows and can only assume it is the default for windows. But I see colour output, so mark that as working. When using org.jline everything looks good in the detection process (correct org.jline:jang all-in-one-jar-deps) is finding the -- Feedback (as a new user) should you be interested. The project could do with a clear example that is focused on more basic features, such as ANSI output, curses like output, other output only matters, which I found jansi documentation covers better. Including details of the correct JAR dependency combinations to use for output only use cases and considerations in the choice of options there may be. It could also do with a more straightforward breakdown of every output JAR, covering its purpose, the project has a few too many JAR output artifacts to not explain this. The topics the info per JAR might cover are:
A dependency graph if all JARs were included, maybe confirming how things are organised, visible crossing out any that should not be included as well. With a note as to why, for example |
Yes, that is the site where GetConsoleMode is being called and always returning from isWindowsSystemStream with FALSE.
Maybe that is a good thing to place into a main heading in the Wiki "Diagnostic" with example of use, expected output for each main platform. Maybe also a code snippet to invoke output within a more complex client application, to run that diagnostics within the context of a larger application ? Then also maybe another page for "Configuration" with a breakdown of the various System Properties that affect behaviour and other similar things. At the moment I run with debugger and read source and then guess that the property function is doing and its allowed range of values.
The output looks good to me. This was Windows Terminal. Also works directly from cmd.exe and jdk-21. My specific use case wants to see it working under IDE like shell environments, so the shell presented. |
I've raised a first PR #1015 to fix the |
I'm getting back to your issue, but I'm not sure to see the exact problems. Did you at least succeeded in running your simple JLine app in a basic environment ? The fact that Jansi returns When launching with gradle, you may hit problems with grade and the terminal. Have a look at https://stackoverflow.com/questions/13172137/console-application-with-java-and-gradle |
Thanks you for your responses, good to see the INVALID_HANDLE_VALUE fix. Give me a week or so to properly experiment with jbang and jline (using output only APIs), across Win64/linux64 and multiple JVMs and options on Native (GraalVM, Kotlin/Native - if I get chance on this). I am still in the stages of learning limitations and caveats with various options, while trying to look for a unified seamless API use. |
https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types confirms HANDLE is of type
typedef PVOID HANDLE;
so 64bit on 64bit windows, and along
in Java.INVALID_HANDLE_VALUE
this is of typeHANDLE
https://github.com/jline/jline3/blob/master/native/src/main/native/kernel32.c#L765
This looks to be using a Java int to store a windows HANDLE type, that could be 64bits on Win64. Code using this may appear to work due to int to long signed promotion of size occurring.
If this is intentional maybe a comment would help prevent it being looked at again.
The other values such as
STD_OUTPUT_HANDLE
are not actually system handle, they are variables that happen to have HANDLE in their name of type DWORD, so all is ok there.This was spotted while reviewing to debug why I am unable to verify org.jline as working on 64bit windows.
From what I can see
GetConsoleMode()
always returns a failure indication. Not sure if that is from Windows or JNI wrapper. It would be nice if this particular failure also recorded the GetLastError() in the diagnostic logging. Handle 0x10123 Error 0x80000004 as it seems intrinsic to it detecting and working.This results with DumbTerminal type=Unsupported.
When I use https://github.com/fusesource/jansi latest release (by just switching dependency away from
org.jline:jansi:3.26.1
) that is working. AnsiConsole.out().type==Redirected.The text was updated successfully, but these errors were encountered: