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

Runtime invisible annotation support, aka "class"-level annotations #53

Closed
0x3C50 opened this issue Dec 22, 2023 · 4 comments
Closed

Runtime invisible annotation support, aka "class"-level annotations #53

0x3C50 opened this issue Dec 22, 2023 · 4 comments
Assignees
Labels
enhancement New feature or request

Comments

@0x3C50
Copy link

0x3C50 commented Dec 22, 2023

Hi,

I'm currently looking for an assembler to use for writing tests for a transpiler I am developing, and came across this project.

The transpiler searches for methods to transpile based on an annotation either present on the declaring type of a method, or on the method itself. The annotation has retention level CLASS; it is invisible at runtime, but still present in the class file.

Objectweb's ASM represents these annotations as entries in the "invisible annotation" list, and my transpiler checks for the annotation in that list.

Your project seems to treat every annotation in the source file as a runtime visible annotation tho, which results in all annotations being present in the "visible annotation" list, instead of the "invisible annotation" list.

Example:

Source:

@Target({ElementType.TYPE})
@Retention(RetentionPolicy.CLASS)
@interface Annot {}

@Annot
public class Hi {}

Jasm:

@Annot
public class Hi extends java/lang/Object {
  public <init>()V {
    aload 0
    invokespecial java/lang/Object.<init>()V
    return
  }
}

Compiling and loading the source version, there is one annotation in the "invisible annotation" list, that being Annot. Doing the same thing for the jasm version results in the Annot annotation being placed in the "visible annotation" list instead.

Code responsible: JasmAssemblingVisitor at line 83: visitor.visitAnnotation(..., true). true means "runtime visible".

I understand this is just a minor nitpick, but I still wanted to make sure you know about this. Is runtime invisible annotation support planned?

@roscopeco
Copy link
Owner

Thanks for raising this, runtime invisible annotations is something that was planned, but hasn't happened as it hasn't been needed. I'll take a look at this over the holidays and look to get it into a release early in the new year.

@roscopeco roscopeco added the enhancement New feature or request label Dec 22, 2023
@roscopeco roscopeco self-assigned this Dec 22, 2023
@0x3C50
Copy link
Author

0x3C50 commented Jan 21, 2024

Since I've not seen any updates to this issue in a while, I've taken the liberty to make my own small implementation of a hidden annotation syntax. The actual syntax is debatable, but as far as I have tested it, it seems to work.

A hidden annotation can be created by prefixing the @ with a #, like so: #@some/hidden/Annotation(value="hello").

Hidden Annotations patch.txt

@roscopeco
Copy link
Owner

Since I've not seen any updates to this issue in a while, I've taken the liberty to make my own small implementation of a hidden annotation syntax. The actual syntax is debatable, but as far as I have tested it, it seems to work.

A hidden annotation can be created by prefixing the @ with a #, like so: #@some/hidden/Annotation(value="hello").

Hidden Annotations patch.txt

Thank you! Unfortunately life got in the way and I haven't gotten back to this yet, so thanks for jumping in and sending a patch! I'll get this applied soon 👍

@roscopeco
Copy link
Owner

roscopeco commented Jan 28, 2024

Thanks again for this @0x3C50 , it's now merged to develop. Will cut a release to include soon 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants