Javac compiler error discovered via project Kulla REPL?
Alex Buckley
alex.buckley at oracle.com
Thu Apr 16 20:43:17 UTC 2015
OK, so in the method invocation expression (whether standalone or on the
RHS of an assignment), javac should classify the identifier "Undefined"
as a PackageName -- see JLS 6.5.2. Since no package with that name
exists, an error is due - see JLS 6.5.3.1. It would be helpful for the
"cannot find symbol" message to indicate that neither a variable nor a
type nor a package called "Undefined" is in scope.
I expect that when javac's second error message improves, so will the
REPL's third error message.
Alex
On 4/16/2015 12:57 PM, Robert Field wrote:
> Actually, none of the below.
>
> They both give the same errors: both a variable ClassName and a class
> ClassName error. Which makes it even more potentially confusing.
>
> From Jan's bug report (showing the behavior of javac (no REPL)) (I've
> added bolding) --
>
> Consider this code:
> ---
> public class Test {
> private void test() {
> Undefined x = Undefined.create();
> }
> }
> ---
>
> When compiled, this code produces the following errors:
> ---
> Test.java:3: error: cannot find symbol
> Undefined x = Undefined.create();
> ^
> symbol: *class Undefined*
> location: class Test
> Test.java:3: error: cannot find symbol
> Undefined x = Undefined.create();
> ^
> symbol: *variable Undefined*
> location: class Test
> 2 errors
> ---
>
> The REPL does --
>
> -> Undefined x = Undefined.create()
> | Error:
> | cannot find symbol
> | symbol: class Undefined
> | Undefined x = Undefined.create();
> | ^-------^
> | Error:
> | cannot find symbol
> | symbol: class Undefined
> | Undefined x = Undefined.create();
> | ^-------^
> | Error:
> | cannot find symbol
> | symbol: variable Undefined
> | Undefined x = Undefined.create();
> | ^-------^
>
>
> ->
>
> The only differences are how the position is marked and the REPL gives
> the first one twice (because it has been taken apart and put back
> together with three occurrences of the name).
>
> Given just "Undefined.create()" both javac and REPL give just a
> "variable Undefined" error
>
> -Robert
>
>
> On 04/16/15 11:40, Alex Buckley wrote:
>> The situation seems to be that the REPL gives no error for the
>> identifier "ClassName" on the LHS of the assignment. Therefore, it
>> must have been possible to classify the identifier as a simple name,
>> in particular as a TypeName. Then, the use of the TypeName on the RHS
>> of the assignment cannot be an error.
>>
>> I can imagine an alternative situation: the identifier "ClassName" is
>> totally made up, and the REPL just happens to be reporting only one of
>> the two "cannot find symbol" errors indicated by JDK-8077970.
>>
>> Which situation is it?
>>
>> Alex
>>
>> On 4/16/2015 8:07 AM, Jan Lahoda wrote:
>>> Hello Martijn,
>>>
>>> I've filled:
>>> https://bugs.openjdk.java.net/browse/JDK-8077970
>>>
>>> Thanks,
>>> Jan
>>>
>>> On 16.4.2015 13:35, Martijn Verburg wrote:
>>>> Hi all,
>>>>
>>>> From the REPL hackday we had recently:
>>>>
>>>> "Following error message might be confusing, as the symbol might not
>>>> be a
>>>> variable:
>>>> -> ClassName x = ClassName.create()
>>>> | cannot find symbol
>>>> | symbol: variable ClassName
>>>> | ClassName x = ClassName.create();
>>>> | ^-------^
>>>> "
>>>>
>>>> Kulla team suggested this is a Java compiler (javac) error message
>>>> and it
>>>> should be submitted as a bug report against javac.
>>>>
>>>> Cheers,
>>>> Martijn
>>>>
>
More information about the kulla-dev
mailing list