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
[jvm] Field annotations not exported correctly with RententionPolicy.RUNTIME #11370
Comments
This could be related to any number of things; the fact the annotation is an inner class, the fact the annotation is on a field, the fact that the annotation is marked as |
Pretty sure it's just the I did notice while messing around with it that the metadatas were in the constant pool on the correct version and not on the Haxe exported version so maybe that's related. |
The problem here is that I don't have a good solution (other than typed metadata) off the top of my head, other than allowing something like |
Interesting, I will look into modifying the test case to see if non-inner annotations work properly, and whether they work if fully qualified. If they do, that fixes some (but not all) of my use cases. |
I just remembered that @:strict(CoolClass_Entry({name: "Outer"}))
public var outer:String;
@:strict(CoolClass_Entry({name: "Inter"}))
public var inner:String;
@:strict(CoolClass_Comment())
public var comment:CoolClass_Comment;
|
However, with the other annotation I tested with, I'm having issues getting it to compile. In this example case: @:strict(org.spongepowered.asm.mixin.Mixin({
value: net.minecraft.client.renderer.entity.player.PlayerRenderer,
priority: 1000,
})) I receive these messages:
Mixin definitely has those fields however. Also, when I tried to make
|
Also what tool is that you're using? |
Of note, The only difference that could be found in the compiled JAR is that in the correct JAR, the annotation is in Mixin has a retention policy of |
|
RetentionPolicy is an annotation which dictates whether and how annotations are visible to the application via reflection. https://stackoverflow.com/a/23013020/5583560 The fact that the Mixin annotation needs to be invisible under the specific category of annotations is not particularly surprising to me. If you aren't aware, SpongePowered/Mixin is a library which applies traits via ASM/bytecode manipulation; this is extremely useful if, say, you need to modify the behavior of a compiled JAR file. I would not be surprised if it was reading bytecode to detect annotations rather than the standard method of reflection. It may help to experiment with some more minimal reproductions but I'm not sure if those need to be done with the Mixin JAR or the standard example. |
Ah, so if we have I'm happy to have test cases using the Mixin JAR if we can figure out a way to make this work on our CI. Ideally without having to install large amounts of Java tooling... and the fact that https://files.minecraftforge.net/maven/ currently gives me a blank page with a 404 resource error in the console isn't very encouraging. |
I'd recommend using Fabric's Maven for it. https://maven.fabricmc.net/net/fabricmc/sponge-mixin/0.12.5%2Bmixin.0.8.5/ |
Not sure if it's still useful but I was able to create a minimal (or as minimal as feasible) project which includes:
|
Use Case
I am working with a library which utilizes annotations on a class's static fields to manage a configuration, with the benefit being that you can access the config value by querying the static field.
Example
Using
field.isAnnotationPresent()
on the fields ofMyClass
returns false, when it returns true on a pure Java implementation.Minimal Reproduction
https://github.com/EliteMasterEric/Issue-11370
The text was updated successfully, but these errors were encountered: