fix: bug with parameterized/array names in finder function

This commit is contained in:
zaaarf 2023-03-18 21:29:13 +01:00
parent fd06fe810d
commit 1c072781f3
No known key found for this signature in database
GPG key ID: 82240E075E31FA4C
2 changed files with 7 additions and 2 deletions

View file

@ -8,7 +8,6 @@ import ftbsc.lll.processor.annotations.Find;
import ftbsc.lll.processor.annotations.Injector;
import ftbsc.lll.processor.annotations.Patch;
import ftbsc.lll.processor.annotations.Target;
import ftbsc.lll.processor.tools.ArrayContainer;
import ftbsc.lll.processor.tools.obfuscation.ObfuscationMapper;
import ftbsc.lll.proxies.FieldProxy;
import ftbsc.lll.proxies.MethodProxy;

View file

@ -7,6 +7,7 @@ import ftbsc.lll.proxies.FieldProxy;
import javax.lang.model.element.ExecutableElement;
import javax.lang.model.element.Modifier;
import javax.lang.model.type.ArrayType;
import javax.lang.model.type.TypeMirror;
import javax.lang.model.util.Elements;
import java.lang.annotation.Annotation;
@ -128,9 +129,14 @@ public class JavaPoetUtils {
b.addStatement(insn + "($T.class)", t);
else {
ArrayContainer arr = new ArrayContainer(t);
TypeName type = TypeName.get(arr.innermostComponent);
while(type instanceof ArrayTypeName)
type = ((ArrayTypeName) type).componentType;
if(type instanceof ParameterizedTypeName)
type = ((ParameterizedTypeName) type).rawType;
b.addStatement(
insn + "($S, $L)",
arr.innermostComponent,
type,
arr.arrayLevel
);
}