Fix issue with incremental compilation and JSBody annotation
@@ -77,7 +77,6 @@ class JSClassProcessor {
private final List<Instruction> replacement = new ArrayList<>();
private final JSTypeHelper typeHelper;
private final Diagnostics diagnostics;
- private int methodIndexGenerator;
private final Map<MethodReference, MethodReader> overriddenMethodCache = new HashMap<>();
private JSValueMarshaller marshaller;
private IncrementalDependencyRegistration incrementalCache;
@@ -576,9 +575,12 @@ class JSClassProcessor {
? ValueType.VOID
: ValueType.parse(JSObject.class);
+ ClassReader ownerClass = classSource.get(methodToProcess.getOwnerName());
+ int methodIndex = indexOfMethod(ownerClass, methodToProcess);
+
// create proxy method
MethodReference proxyMethod = new MethodReference(methodToProcess.getOwnerName(),
- methodToProcess.getName() + "$js_body$_" + methodIndexGenerator++, proxyParamTypes);
+ methodToProcess.getName() + "$js_body$_" + methodIndex, proxyParamTypes);
String script = bodyAnnot.getValue("script").getString();
String[] parameterNames = paramsValue != null ? paramsValue.getList().stream()
.map(AnnotationValue::getString)
@@ -617,6 +619,17 @@ class JSClassProcessor {
}
}
+ private int indexOfMethod(ClassReader cls, MethodReader method) {
+ int index = 0;
+ for (MethodReader m : cls.getMethods()) {
+ if (m.getDescriptor().equals(method.getDescriptor())) {
+ return index;
+ }
+ ++index;
+ }
+ return -1;
+ }
+
void createJSMethods(ClassHolder cls) {
for (MethodHolder method : cls.getMethods().toArray(new MethodHolder[0])) {
MethodReference methodRef = method.getReference();
