From 01e3d31f1a006c3f86c09223c9f735cfee545572 Mon Sep 17 00:00:00 2001 From: Daniel Holle Date: Wed, 6 Mar 2024 14:10:47 +0100 Subject: [PATCH] Add Object methods to every interface, fixes #125 --- .../java/de/dhbwstuttgart/syntaxtree/factory/ASTFactory.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/de/dhbwstuttgart/syntaxtree/factory/ASTFactory.java b/src/main/java/de/dhbwstuttgart/syntaxtree/factory/ASTFactory.java index 27ac8dbb..eb1538d0 100644 --- a/src/main/java/de/dhbwstuttgart/syntaxtree/factory/ASTFactory.java +++ b/src/main/java/de/dhbwstuttgart/syntaxtree/factory/ASTFactory.java @@ -95,7 +95,11 @@ public class ASTFactory { var signature = methodSignatures.get(new Pair<>(constructor.getName(), org.objectweb.asm.Type.getConstructorDescriptor(constructor))); createConstructor(constructor, signature, jreClass).map(c -> konstruktoren.add(c)); } + Set allMethods = new HashSet<>(Arrays.asList(jreClass.getMethods())); + if (jreClass.isInterface()) + allMethods.addAll(Arrays.asList(Object.class.getMethods())); // For some reason interfaces don't inherit from Object + Set allDeclaredMethods = new HashSet<>(Arrays.asList(jreClass.getDeclaredMethods())); Set allInheritedMethods = new HashSet<>(allMethods); allInheritedMethods.removeAll(allDeclaredMethods);