Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #35730

Re: Is You Is Or Is You Ain't A Literal?

Path csiph.com!aioe.org!.POSTED!not-for-mail
From Arne Vajhøj <arne@vajhoej.dk>
Newsgroups comp.lang.java.programmer
Subject Re: Is You Is Or Is You Ain't A Literal?
Date Wed, 5 Oct 2016 20:21:25 -0400
Organization Aioe.org NNTP Server
Lines 43
Message-ID <nt45e5$vcr$1@gioia.aioe.org> (permalink)
References <literal-20161005222352@ram.dialup.fu-berlin.de>
NNTP-Posting-Host PBuS014lhzVyHjLbXmo/ZQ.user.gioia.aioe.org
Mime-Version 1.0
Content-Type text/plain; charset=windows-1252; format=flowed
Content-Transfer-Encoding 8bit
X-Complaints-To abuse@aioe.org
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0
X-Notice Filtered by postfilter v. 0.8.2
Xref csiph.com comp.lang.java.programmer:35730

Show key headers only | View raw


On 10/5/2016 5:30 PM, Stefan Ram wrote:
>   Is »2« a literal?
>
>   I think JLS 3.10.1 says "yes".
>
>   But there also is a test method:
>
> javax.lang.model
>
> Enum SourceVersion
>
> public static boolean isKeyword( java.lang.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.
>
>   So,
>
> public final class Main
> { public static void main( final java.lang.String args[] )
>   { java.lang.System.out.println
>     ( javax.lang.model.SourceVersion.isKeyword( "2" )); }}
>
> false
>
>   So, »2« is not a literal?

2 is a literal.

The documentation is bad/misleading.

A quick glance in the source code reveals what "or literal"
means.

It is only the 3 "name like" literals: null, true and false.

Arne

Back to comp.lang.java.programmer | Previous | Next | Find similar | Unroll thread


Thread

Re: Is You Is Or Is You Ain't A Literal? Arne Vajhøj <arne@vajhoej.dk> - 2016-10-05 20:21 -0400

csiph-web