@Test publicvoid checkLoaderDelegation() {
ModuleLayer boot = ModuleLayer.boot();
MREFS.stream()
.forEach(md -> md.requires().stream().forEach(req ->
{ // check if M requires D and D's loader must be either the // same or an ancestor of M's loader
ClassLoader loader1 = boot.findLoader(md.name());
ClassLoader loader2 = boot.findLoader(req.name()); if (loader1 != loader2 && !isAncestor(loader2, loader1)) { thrownew Error(loader1.getName() + "/" + md.name() + " can't delegate to find classes from " +
loader2.getName() + "/" + req.name());
}
}));
}
// Returns true if p is an ancestor of cl i.e. class loader 'p' can // be found in the cl's delegation chain privatestaticboolean isAncestor(ClassLoader p, ClassLoader cl) { if (p != null && cl == null) { returnfalse;
}
ClassLoader acl = cl; do {
acl = acl.getParent(); if (p == acl) { returntrue;
}
} while (acl != null); returnfalse;
}
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.8 Sekunden
(vorverarbeitet am 2026-06-10)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.