diff --git a/core/src/main/java/org/teavm/backend/javascript/rendering/Renderer.java b/core/src/main/java/org/teavm/backend/javascript/rendering/Renderer.java index 3c6e5e1b8..88f90b7c2 100644 --- a/core/src/main/java/org/teavm/backend/javascript/rendering/Renderer.java +++ b/core/src/main/java/org/teavm/backend/javascript/rendering/Renderer.java @@ -19,7 +19,6 @@ import com.carrotsearch.hppc.ObjectIntHashMap; import com.carrotsearch.hppc.ObjectIntMap; import java.io.IOException; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collection; import java.util.HashMap; import java.util.HashSet; @@ -632,17 +631,33 @@ public class Renderer implements RenderingManager { MethodDependencyInfo getNameMethod = context.getDependencyInfo().getMethod( new MethodReference(Class.class, "getName", String.class)); if (getNameMethod != null) { - classesRequiringName.addAll(Arrays.asList(getNameMethod.getVariable(0).getClassValueNode().getTypes())); + addClassesRequiringName(classesRequiringName, getNameMethod.getVariable(0).getClassValueNode().getTypes()); } MethodDependencyInfo getSimpleNameMethod = context.getDependencyInfo().getMethod( new MethodReference(Class.class, "getSimpleName", String.class)); if (getSimpleNameMethod != null) { - classesRequiringName.addAll(Arrays.asList( - getSimpleNameMethod.getVariable(0).getClassValueNode().getTypes())); + addClassesRequiringName(classesRequiringName, + getSimpleNameMethod.getVariable(0).getClassValueNode().getTypes()); } return classesRequiringName; } + private void addClassesRequiringName(Set target, String[] source) { + for (String typeName : source) { + if (typeName.startsWith("[")) { + if (!typeName.endsWith(";")) { + continue; + } + int index = 0; + while (typeName.charAt(index) == '[') { + ++index; + } + typeName = typeName.substring(index, typeName.length() - 1).replace('/', '.'); + } + target.add(typeName); + } + } + private void collectMethodsToCopyFromInterfaces(ClassReader cls, List targetList) { Set implementedMethods = new HashSet<>(); implementedMethods.addAll(targetList.stream().map(method -> method.getDescriptor())