Skip to content

scalac unable to parse java annotations in a file in the empty package with no imports #4071

Closed
@scabug

Description

@scabug

One wonders what our test suite is doing exactly given that this java file is verbatim from a currently active test.

% scalac29 test/files/jvm/t3003/Annot.java 
test/files/jvm/t3003/Annot.java:2: error: `package' expected but `public' found.
public @interface Annot {
^
test/files/jvm/t3003/Annot.java:4: error: identifier expected but eof found.
}
 ^
two errors found

Here is the file.

@java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.RUNTIME)
public @interface Annot {
    Class<?> optionType();
}

It is successfully parsed if written like this:

import java.lang.annotation.*;

@Retention(RetentionPolicy.RUNTIME)
public @interface Annot {
    Class<?> optionType();
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions