Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Java parser skips over annotations, all @interfaces have the default @Retention #8928

Closed
scabug opened this issue Oct 20, 2014 · 3 comments
Closed
Assignees
Labels
Milestone

Comments

@scabug
Copy link

scabug commented Oct 20, 2014

Since scala/scala#4026 we respect @Retention on java annotation classes.

When the annotation class is parsed from source, the meta-annotation is skipped. In #8926 we changed the default visibility back to RUNTIME for annotations without a @Retention meta-attribute.

Instead, we should extend the java parser.

@scabug
Copy link
Author

scabug commented Oct 20, 2014

Imported From: https://issues.scala-lang.org/browse/SI-8928?orig=1
Reporter: @lrytz
Affected Versions: 2.11.3
See #8926, #5333

@scabug
Copy link
Author

scabug commented Nov 18, 2014

@scabug
Copy link
Author

scabug commented Apr 12, 2015

@soc said:
Note to future self: WIP is https://github.com/soc/scala/commits/SI-8928

hrhino added a commit to hrhino/scala that referenced this issue May 7, 2017
This causes the java parser to get somewhat more complex, but
allows for macros and compiler plugins to correctly inspect
java-defined classes for annotations.

Moved a few utility methods into {Parsers,Scanners}Common as well,
so I can reuse them in the java ones.

This involves a change to the t4788 tests, as SAnnotation now
correctly has RetentionPolicy.SOURCE, and is therefore ignored
by the check in BCodeHelpers#BCAnnotGen.shouldEmitAnnotation;
also, ASM Textifier emits an // invisible marker now that
CAnnotation has RetentionPolicy.CLASS. I'm not sure what the
chances that anyone is relying upon this behavior are, but
since it does the Right Thing for separate compilation runs,
they probably should not be too disappointed.

Review by @densh

Fixes scala/bug#8928
hrhino added a commit to hrhino/scala that referenced this issue May 7, 2017
This causes the java parser to get somewhat more complex, but
allows for macros and compiler plugins to correctly inspect
java-defined classes for annotations.

Moved a few utility methods into {Parsers,Scanners}Common as well,
so I can reuse them in the java ones.

This involves a change to the t4788 tests, as SAnnotation now
correctly has RetentionPolicy.SOURCE, and is therefore ignored
by the check in BCodeHelpers#BCAnnotGen.shouldEmitAnnotation;
also, ASM Textifier emits an // invisible marker now that
CAnnotation has RetentionPolicy.CLASS. I'm not sure what the
chances that anyone is relying upon this behavior are, but
since it does the Right Thing for separate compilation runs,
they probably should not be too disappointed.

Review by densh

Fixes scala/bug#8928
hrhino added a commit to hrhino/scala that referenced this issue May 8, 2017
This causes the java parser to get somewhat more complex, but
allows for macros and compiler plugins to correctly inspect
java-defined classes for annotations.

Moved a few utility methods into {Parsers,Scanners}Common as well,
so I can reuse them in the java ones.

This involves a change to the t4788 tests, as SAnnotation now
correctly has RetentionPolicy.SOURCE, and is therefore ignored
by the check in BCodeHelpers#BCAnnotGen.shouldEmitAnnotation;
also, ASM Textifier emits an // invisible marker now that
CAnnotation has RetentionPolicy.CLASS. I'm not sure what the
chances that anyone is relying upon this behavior are, but
since it does the Right Thing for separate compilation runs,
they probably should not be too disappointed.

Review by densh

Fixes scala/bug#8928
hrhino added a commit to hrhino/scala that referenced this issue May 9, 2017
This causes the java parser to get somewhat more complex, but
allows for macros and compiler plugins to correctly inspect
java-defined classes for annotations.

Moved a few utility methods into {Parsers,Scanners}Common as well,
so I can reuse them in the java ones.

This involves a change to the t4788 tests, as SAnnotation now
correctly has RetentionPolicy.SOURCE, and is therefore ignored
by the check in BCodeHelpers#BCAnnotGen.shouldEmitAnnotation;
also, ASM Textifier emits an // invisible marker now that
CAnnotation has RetentionPolicy.CLASS. I'm not sure what the
chances that anyone is relying upon this behavior are, but
since it does the Right Thing for separate compilation runs,
they probably should not be too disappointed.

Review by densh

Fixes scala/bug#8928
@hrhino hrhino self-assigned this Jun 29, 2017
hrhino added a commit to hrhino/scala that referenced this issue Jun 29, 2017
This causes the java parser to get somewhat more complex, but
allows for macros and compiler plugins to correctly inspect
java-defined classes for annotations.

Moved a few utility methods into {Parsers,Scanners}Common as well,
so I can reuse them in the java ones.

This involves a change to the t4788 tests, as SAnnotation now
correctly has RetentionPolicy.SOURCE, and is therefore ignored
by the check in BCodeHelpers#BCAnnotGen.shouldEmitAnnotation;
also, ASM Textifier emits an // invisible marker now that
CAnnotation has RetentionPolicy.CLASS. I'm not sure what the
chances that anyone is relying upon this behavior are, but
since it does the Right Thing for separate compilation runs,
they probably should not be too disappointed.

The new tests are run-tests not just pos-tests at the suggestion
of retronym, to ensure that everything works the same at runtime
as it does at compile time. As a matter of fact, it doesn't: the
compile-time universe maintains ordering of annotation values in
the tree, while the runtime universe uses java reflection to get
at the values and therefore cannot know of their order. The test
contains one exception for that.

Review by densh, retronym

Fixes scala/bug#8928
hrhino added a commit to hrhino/scala that referenced this issue Jul 6, 2017
This causes the java parser to get somewhat more complex, but
allows for macros and compiler plugins to correctly inspect
java-defined classes for annotations.

Moved a few utility methods into {Parsers,Scanners}Common as well,
so I can reuse them in the java ones.

This involves a change to the t4788 tests, as SAnnotation now
correctly has RetentionPolicy.SOURCE, and is therefore ignored
by the check in BCodeHelpers#BCAnnotGen.shouldEmitAnnotation;
also, ASM Textifier emits an // invisible marker now that
CAnnotation has RetentionPolicy.CLASS. I'm not sure what the
chances that anyone is relying upon this behavior are, but
since it does the Right Thing for separate compilation runs,
they probably should not be too disappointed.

The new tests are run-tests not just pos-tests at the suggestion
of retronym, to ensure that everything works the same at runtime
as it does at compile time. As a matter of fact, it doesn't: the
compile-time universe maintains ordering of annotation values in
the tree, while the runtime universe uses java reflection to get
at the values and therefore cannot know of their order. The test
contains one exception for that.

Review by densh, retronym

Fixes scala/bug#8928
dwijnand pushed a commit to dwijnand/scala that referenced this issue Feb 27, 2020
This causes the java parser to get somewhat more complex, but
allows for macros and compiler plugins to correctly inspect
java-defined classes for annotations.

Moved a few utility methods into {Parsers,Scanners}Common as well,
so I can reuse them in the java ones.

This involves a change to the t4788 tests, as SAnnotation now
correctly has RetentionPolicy.SOURCE, and is therefore ignored
by the check in BCodeHelpers#BCAnnotGen.shouldEmitAnnotation;
also, ASM Textifier emits an // invisible marker now that
CAnnotation has RetentionPolicy.CLASS. I'm not sure what the
chances that anyone is relying upon this behavior are, but
since it does the Right Thing for separate compilation runs,
they probably should not be too disappointed.

The new tests are run-tests not just pos-tests at the suggestion
of retronym, to ensure that everything works the same at runtime
as it does at compile time. As a matter of fact, it doesn't: the
compile-time universe maintains ordering of annotation values in
the tree, while the runtime universe uses java reflection to get
at the values and therefore cannot know of their order. The test
contains one exception for that.

Review by densh, retronym

Fixes scala/bug#8928

Co-authored-by: Jason Zaugg <jzaugg@gmail.com>
dwijnand pushed a commit to dwijnand/scala that referenced this issue Mar 2, 2020
This causes the java parser to get somewhat more complex, but
allows for macros and compiler plugins to correctly inspect
java-defined classes for annotations.

Moved a few utility methods into {Parsers,Scanners}Common as well,
so I can reuse them in the java ones.

This involves a change to the t4788 tests, as SAnnotation now
correctly has RetentionPolicy.SOURCE, and is therefore ignored
by the check in BCodeHelpers#BCAnnotGen.shouldEmitAnnotation;
also, ASM Textifier emits an // invisible marker now that
CAnnotation has RetentionPolicy.CLASS. I'm not sure what the
chances that anyone is relying upon this behavior are, but
since it does the Right Thing for separate compilation runs,
they probably should not be too disappointed.

The new tests are run-tests not just pos-tests at the suggestion
of retronym, to ensure that everything works the same at runtime
as it does at compile time. As a matter of fact, it doesn't: the
compile-time universe maintains ordering of annotation values in
the tree, while the runtime universe uses java reflection to get
at the values and therefore cannot know of their order. The test
contains one exception for that.

Review by densh, retronym

Fixes scala/bug#8928

Co-authored-by: Jason Zaugg <jzaugg@gmail.com>
@dwijnand dwijnand added the has PR label Mar 2, 2020
@dwijnand dwijnand self-assigned this Mar 2, 2020
dwijnand pushed a commit to dwijnand/scala that referenced this issue Mar 24, 2020
This causes the java parser to get somewhat more complex, but
allows for macros and compiler plugins to correctly inspect
java-defined classes for annotations.

Moved a few utility methods into {Parsers,Scanners}Common as well,
so I can reuse them in the java ones.

This involves a change to the t4788 tests, as SAnnotation now
correctly has RetentionPolicy.SOURCE, and is therefore ignored
by the check in BCodeHelpers#BCAnnotGen.shouldEmitAnnotation;
also, ASM Textifier emits an // invisible marker now that
CAnnotation has RetentionPolicy.CLASS. I'm not sure what the
chances that anyone is relying upon this behavior are, but
since it does the Right Thing for separate compilation runs,
they probably should not be too disappointed.

The new tests are run-tests not just pos-tests at the suggestion
of retronym, to ensure that everything works the same at runtime
as it does at compile time. As a matter of fact, it doesn't: the
compile-time universe maintains ordering of annotation values in
the tree, while the runtime universe uses java reflection to get
at the values and therefore cannot know of their order. The test
contains one exception for that.

Review by densh, retronym

Fixes scala/bug#8928

Co-authored-by: Jason Zaugg <jzaugg@gmail.com>
dwijnand added a commit to dwijnand/scala that referenced this issue Apr 22, 2020
This causes the java parser to get somewhat more complex, but
allows for macros and compiler plugins to correctly inspect
java-defined classes for annotations.

Moved a few utility methods into {Parsers,Scanners}Common as well,
so I can reuse them in the java ones.

This involves a change to the t4788 tests, as SAnnotation now
correctly has RetentionPolicy.SOURCE, and is therefore ignored
by the check in BCodeHelpers#BCAnnotGen.shouldEmitAnnotation;
also, ASM Textifier emits an // invisible marker now that
CAnnotation has RetentionPolicy.CLASS. I'm not sure what the
chances that anyone is relying upon this behavior are, but
since it does the Right Thing for separate compilation runs,
they probably should not be too disappointed.

The new tests are run-tests not just pos-tests at the suggestion
of retronym, to ensure that everything works the same at runtime
as it does at compile time. As a matter of fact, it doesn't: the
compile-time universe maintains ordering of annotation values in
the tree, while the runtime universe uses java reflection to get
at the values and therefore cannot know of their order. The test
contains one exception for that.

Review by densh, retronym

Fixes scala/bug#8928

Co-authored-by: Jason Zaugg <jzaugg@gmail.com>
Co-authored-by: Dale Wijnand <dale.wijnand@gmail.com>
@dwijnand dwijnand added this to the 2.12.12 milestone Jun 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants