Giter VIP home page Giter VIP logo

Comments (3)

anthonyvdotbe avatar anthonyvdotbe commented on August 26, 2024 1

Can the implementation return null, though? I'm not seeing how the implementation could return null in https://github.com/openjdk/jdk/blob/20cb6e786fbf6d924c509e28d6fded86d61a5f84/src/java.base/share/classes/java/io/Console.java#L431-L435

At line 431, c can be null and istty can be false, which causes c to still be null at line 435. Or am I missing something?

from error-prone.

cushon avatar cushon commented on August 26, 2024

Thanks, 'no longer returns null' could have been something like 'no longer returns null when the standard streams are redirected or connected to a virtual terminal'

Can the implementation return null, though? I'm not seeing how the implementation could return null in https://github.com/openjdk/jdk/blob/20cb6e786fbf6d924c509e28d6fded86d61a5f84/src/java.base/share/classes/java/io/Console.java#L431-L435

from error-prone.

cpovirk avatar cpovirk commented on August 26, 2024

Huh, thanks. I'd misread the code, too. Indeed, I can produce a null return:

$ cat SystemConsole.java
public class SystemConsole {
  public static void main(String[] args) {
    System.err.println(System.console());
  }
}

$ javac SystemConsole.java && ~/jdk-22-ea+19/bin/java -Djdk.console=nosuchthing SystemConsole > /dev/null
null

I'm hoping that that's at least possible only in the case that the user sets jdk.console (as above), but I wouldn't want to make further assumptions :)

from error-prone.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.