Re: [abc] Jastadd compile bugs

From: Pavel Avgustinov <pavel.avgustinov@magdalen.oxford.ac.uk>
Date: Tue Jan 17 2006 - 10:22:28 GMT

A bug that prevents compilation of one of my test programs is this:

---
class Outer {
    class Inner {
        public Class foo() {
            return Integer.class;
        }
    }
}
---
Jastadd gives two messages of "*** Semantic Error: *** Inner classes may
not declare static members, unless they are compile-time constant
fields" on the opening '{' of the inner class. Indeed, the error message
is a quote from
http://java.sun.com/docs/books/jls/second_edition/html/classes.doc.html#262890.
However, both javac and abc compile this class without complaints.
It is interesting to note that if foo() is changed to return null,
jastadd compiles the program. It seems JastAdd's behaviour is a
combination of a misinterpretation of the spec and buggy code. For some
reason, the method in the inner class is considered static (that's the
bug). Given that, if it can determine that it is compile-time constant
(for some definition of 'compile-time constant method'), jastadd still
accepts it -- but the spec says static members must be compile-time
constant *fields*, so it should be rejected.. Indeed, abc and javac
reject the program if the method is explicitly marked as static.
(Incidentally, if the method is explicitly static jastadd rejects even
the 'return null' version.)
- P
Received on Tue Jan 17 10:22:52 2006

This archive was generated by hypermail 2.1.8 : Tue Jan 24 2006 - 17:10:09 GMT