Brain-Dead

Java is somewhat brain-dead at times. For instance:

while(c=System.in.read()>-1){
  System.out.print(backspaceChar);
}

Doesn’t do what you’d expect. (hide console input) It appears that System.in is being silently buffered.

So a little googling: http://java.sun.com/developer/technicalArticles/Security/pwordmask/

Sun’s recommendation is a busy-wait loop in a separate thread that constantly rewrites the previous character?!? I mean, seriously, WTF?!?

Edit: It looks like Sun implemented a new API for non-echoing prompts in v1.6: http://java.sun.com/javase/6/docs/api/java/io/Console.html

But this is still crappy. Introducing a new API to partially work around the broken functionality of an old API is how you get bloated monstrosities to begin with.

Leave a Reply


<Kered.org>   © Copyright 2000-2005 by Derek Anderson
Get Firefox