Re: [Jastadd] Problems with Literals after change to Java 7 frontend

From: Eric Bodden <>
Date: Mon, 14 Jan 2013 14:42:01 +0100

Hi Jesper.

Thanks a lot for the explanation. I hope that will help me debugging things.

I really wonder, though, what's a good use case for allowing
underscores in literals. What were they thinking?


On 14 January 2013 09:36, Jesper qvist <> wrote:
> Hi Eric,
> The numerical literal parsing code in JastAddJ was rebuilt for Java 7. The
> reason is that Java 7 added underscores in numeric literals. So, e.g. the
> literal 0x1__2 is legal and means the same thing as 0x12.
> In order to scan literals with underscores lookahead is required. This is
> easy to see: numeric literals may not begin or end with an underscore, so
> when the scanner encounters an underscore it can not know if that is an
> error, or a legal character - it depends on whether or not there is a valid
> digit after this underscore or after any number of intervening underscores.
> We could have changed the scanner to use some form of lookahead, but that
> would make the scanner much more complex and remove some of the advantage of
> having a generated scanner to boot. So, instead we've made the scanner
> simpler - it can now accept illegal numeric literals, the only requirement
> for the scanner is that it should be clearly a numeric literal and not any
> other type of token. So this inserts invalid literals in the AST, but they
> are rewritten to either an object of a subclass of NumericLiteral
> representing a valid numeric literal, or IllegalLiteral if there is a syntax
> error in the literal.
> The only additions to the AST relevant to literals are NumericLiteral and
> IllegalLiteral.
> The digits field represents the digits of a numeric literal stripped of
> underscores and prefixes or suffixes. This field is set during the parsing
> of a NumericLiteral. The rewrite rules for NumericLiterals are all in
> Java7Frontend/Literals.jrag.
> IntegerLiteral.buildIntegerLiteral and friends are used to build literal
> objects representing literals that have been parsed from bytecode.
> Hope this clears things up
> /Jesper
> On 2013-01-13 12:09, Eric Bodden wrote:
>> Hello.
>> After changing Soot/abc to the Java7Frontend I am having the problems
>> that all numerical constants in processed Java source code get
>> interpreted as having the value 0.
>> The problem seems to be due to the field
>> abc.ja.cjp.jrag.NumericLiteral.digits never being assigned a value. It
>> is initialized to "" but then never changed afterwards. In particular
>> the method IntegerLiteral.buildIntegerLiteral(..) seems never to be
>> called. I am afraid I don't quite understand the changes to literals
>> between the 1.5 and 7 frontends, so it's hard for me to debug this.
>> Does anyone have any idea what could be causing this?
>> Eric
> _______________________________________________
> JastAdd mailing list

Eric Bodden, Ph.D.,
Head of Secure Software Engineering Group at EC SPRIDE
Tel: +49 6151 16-75422    Fax: +49 6151 16-72051
Room 3.2.14, Mornewegstr. 30, 64293 Darmstadt
Received on Mon Jan 14 2013 - 14:43:37 CET

This archive was generated by hypermail 2.3.0 : Wed Apr 16 2014 - 17:19:06 CEST