X-Git-Url: http://plrg.eecs.uci.edu/git/?p=jpf-core.git;a=blobdiff_plain;f=src%2Fmain%2Fgov%2Fnasa%2Fjpf%2Fvm%2FClassInfo.java;h=83b3f5b9f63e79a3d33246d341053016a5a59744;hp=d9e5331835833c8f8e7635daf78b2f584eca2de3;hb=d0a18eb873b7a2c18a61d0a6207e00cf04d50f44;hpb=97aa2f798ce7173f778234427b9b840f5886296d;ds=sidebyside diff --git a/src/main/gov/nasa/jpf/vm/ClassInfo.java b/src/main/gov/nasa/jpf/vm/ClassInfo.java index d9e5331..83b3f5b 100644 --- a/src/main/gov/nasa/jpf/vm/ClassInfo.java +++ b/src/main/gov/nasa/jpf/vm/ClassInfo.java @@ -1091,17 +1091,21 @@ public class ClassInfo extends InfoObject implements Iterable, Gener public MethodInfo getDefaultMethod (String uniqueName) { MethodInfo mi = null; - for (ClassInfo ci = this; ci != null; ci = ci.superClass){ - for (ClassInfo ciIfc : ci.interfaces){ - MethodInfo miIfc = ciIfc.getMethod(uniqueName, true); - if (miIfc != null && !miIfc.isAbstract()){ - if (mi != null && !mi.equals(miIfc)){ + for (ClassInfo ciIfc : this.getAllInterfaces()){ + MethodInfo miIfc = ciIfc.getMethod(uniqueName, false); + if (miIfc != null && !miIfc.isAbstract() && !miIfc.isPrivate() && !miIfc.isStatic()){ + if (mi != null && !mi.equals(miIfc)){ + if(miIfc.getClassInfo().isSubInterfaceOf(mi.getClassInfo())) { + mi = miIfc; + } else if(mi.getClassInfo().isSubInterfaceOf(miIfc.getClassInfo())) { + continue; + } else { // this has to throw a IncompatibleClassChangeError in the client since Java prohibits ambiguous default methods String msg = "Conflicting default methods: " + mi.getFullName() + ", " + miIfc.getFullName(); throw new ClassChangeException(msg); - } else { - mi = miIfc; } + } else { + mi = miIfc; } } } @@ -1109,6 +1113,11 @@ public class ClassInfo extends InfoObject implements Iterable, Gener return mi; } + private boolean isSubInterfaceOf(ClassInfo classInfo) { + assert this.isInterface() && classInfo.isInterface(); + return this == classInfo || this.getAllInterfaces().contains(classInfo); + } + /** * This retrieves the SAM from this functional interface. Note that this is only * called on functional interface expecting to have a SAM. This shouldn't expect