feat: support GroovyTransformJar packer

This commit is contained in:
ReaJason
2025-12-08 01:43:41 +08:00
parent 8b8cc7173d
commit 102173b924
10 changed files with 259 additions and 27 deletions
@@ -0,0 +1,28 @@
package com.reajason.javaweb.asm;
import lombok.SneakyThrows;
import net.bytebuddy.ByteBuddy;
import org.junit.jupiter.api.Test;
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* @author ReaJason
* @since 2025/12/6
*/
class ClassAnnotationUtilsTest {
@Test
@SneakyThrows
void test() {
String interfaceName = "javax.script.ScriptEngineFactory";
byte[] bytes = new ByteBuddy().redefine(ClassInterfaceUtilsTest.EmptyInterface.class).make().getBytes();
List<ClassAnnotationUtils.AnnotationInfo> rawAnnotations = ClassAnnotationUtils.getAnnotations(bytes);
byte[] newBytes = ClassAnnotationUtils.setAnnotation(bytes, interfaceName);
List<ClassAnnotationUtils.AnnotationInfo> annotations = ClassAnnotationUtils.getAnnotations(newBytes);
assertEquals(0, rawAnnotations.size());
assertEquals(1, annotations.size());
assertEquals("Ljavax/script/ScriptEngineFactory;", annotations.get(0).desc);
}
}