-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
impr: Add back annotation path handling with index support
- Loading branch information
Showing
9 changed files
with
118 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
...sition-jvm/src/main/java/me/darknet/assembler/compile/builder/BlwReplaceFieldBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package me.darknet.assembler.compile.builder; | ||
|
||
import dev.xdark.blw.classfile.generic.GenericFieldBuilder; | ||
import dev.xdark.blw.type.ClassType; | ||
|
||
public class BlwReplaceFieldBuilder extends GenericFieldBuilder { | ||
public BlwReplaceFieldBuilder(int accessFlags, String name, ClassType type) { | ||
super(accessFlags, name, type); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
jasm-composition-jvm/src/main/java/me/darknet/assembler/util/AnnotationInstaller.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package me.darknet.assembler.util; | ||
|
||
import dev.xdark.blw.annotation.AnnotationBuilder; | ||
import dev.xdark.blw.classfile.AnnotatedBuilder; | ||
import dev.xdark.blw.type.InstanceType; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public class AnnotationInstaller { | ||
public static <A extends AnnotationBuilder<A>> @NotNull A install(@NotNull AnnotatedBuilder<?, ?> annotated, | ||
@NotNull AnnotationKind kind, | ||
int index, @NotNull InstanceType type) { | ||
A builder = AnnotationBuilder.newAnnotationBuilder(type); | ||
switch (kind) { | ||
case VIS_ANNO -> { | ||
if (index < 0) { | ||
annotated.addVisibleRuntimeAnnotation(builder); | ||
} else { | ||
annotated.setVisibleRuntimeAnnotation(index, builder); | ||
} | ||
} | ||
case INVIS_ANNO -> { | ||
if (index < 0) { | ||
annotated.addInvisibleRuntimeAnnotation(builder); | ||
} else { | ||
annotated.setInvisibleRuntimeAnnotation(index, builder); | ||
} | ||
} | ||
default -> throw new IllegalArgumentException("Invalid anno-kind: " + kind); | ||
} | ||
return builder; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
jasm-core/src/main/java/me/darknet/assembler/util/AnnotationKind.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package me.darknet.assembler.util; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
/** | ||
* Annotation storage kind, where storage is just for the internal class model, | ||
* IE visibility and if it's a type-anno or not. | ||
*/ | ||
public enum AnnotationKind { | ||
VIS_ANNO("vis-a"), | ||
INVIS_ANNO("invis-a"), | ||
// TODO: Type annotation support in BLW | ||
// VIS_TYPE_ANNO("vis-t"), | ||
// INVIS_TYPE_ANNO("invis-t") | ||
; | ||
|
||
private final String display; | ||
|
||
AnnotationKind(String display) { | ||
this.display = display; | ||
} | ||
|
||
/** | ||
* @param name | ||
* Name of annotation kind. | ||
* | ||
* @return Kind matching the display or enum name. | ||
* Falls back to {@link #VIS_ANNO} if unrecognized. | ||
*/ | ||
public static @NotNull AnnotationKind from(@Nullable String name) { | ||
for (AnnotationKind value : values()) | ||
if (value.display.equalsIgnoreCase(name) || value.name().equalsIgnoreCase(name)) | ||
return value; | ||
return VIS_ANNO; | ||
} | ||
} |