the true literal

S

Stefan Ram

The JLS says:
»While true and false might appear to be keywords,
they are technically Boolean literals (§3.10.3).«

Yeah, the JLS says so, but this is false!

In 3.10.3, it is correct, but there in 3.9 (as quoted
above) it is false. I just spotted the error.

They are /not/ »Boolean literals«, they are »boolean literals«.
¯ ¯
 
S

Stefan Ram

Yeah, the JLS says so, but this is false!

And I found yet another error in Java SE!

According to JLS7 3.10.1, »0« is a literal.

The documentation of

javax.lang.model.SourceVersion.isKeyword

says:

»public static boolean isKeyword(CharSequence s)
Returns whether or not s is a keyword or literal
in the latest source version. ¯¯¯¯¯¯¯¯¯¯
Parameters: s - the string to check
Returns: true if s is a keyword or literal, false
otherwise.«. ¯¯¯¯¯¯¯¯¯¯

Thus, according to the documentation, the following
program should print »true«, but it prints »false«:

public final class Main
{ public static void main( final java.lang.String[] args )
{ java.lang.System.out.println( javax.lang.model.SourceVersion.isKeyword( "0" )); }}
 
S

Stefan Ram

Returns whether or not s is a keyword or literal ....
{ java.lang.System.out.println( javax.lang.model.SourceVersion.isKeyword( "0" )); }}

And in case you have not guessed so already:
The documentation should read:

»Returns whether or not s is a keyword or "true",
"false", or "null"«.

Another »famous« documentation error is:

»void println(boolean x)
Prints a boolean and then terminate the line.«.

The »s« which ends »Prints« also should be added to the word
»terminate«. This error is famous insofar as I am showing it
in my classes (because I want to show them the documentation
for println) for many years and am explaining how it arose.
(When the author of the docs read that the verbs had to be
third-person, he started to edit them from second person to
third person, but overlooked some.) Yes, it is still there,
right now. It also is prominent insofar as it can be found
in most of the overloaded println method documentations and
println /is/ a famous Java method, println and main possibly
are the most famous.
 
S

Stefan Ram

The documentation should read:
»Returns whether or not s is a keyword or "true",
"false", or "null"«.

Also, the »or not « should be deleted:

»Returns whether s is a keyword or
one of: "true", "false", or "null"«.

(To see this, observe that the question:

»Have you been there at that time?«

can be answered with »yes« or »no«, while

»Have you been there at that time or not?«

cannot be answered with »yes« or »no«.

Since, »isKeyword« returns a boolean value,
it effectively give a yes/no-answer, so a
corresponding question is appropriate.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

literals and keywords 8
What is a literal? 12
Trying to return true if a sub array exists at given index 1
The True Religion 0
The True Religion 3
The True Religion 0
Compound literal without initializer? 3
Java 1

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top