public String resolve(String projectName, String headerFile) { /* First search using the main resolver. */ HeaderSearchResult mainResult = mainResolver.resolveHeader(projectName, headerFile); if (mainResult.header.isPresent()) { return mainResult.header.get(); } /* Then search using the fallback resolvers, if any. */ List<String> fallbackLocations = new ArrayList<>(); for (HeaderResolver resolver : fallbackResolvers) { HeaderSearchResult result = resolver.resolveHeader(projectName, headerFile); fallbackLocations.addAll(result.locations); if (result.header.isPresent()) { return result.header.get(); } } /* If the header was not found at any of the specified locations an error is thrown. */ throw VMError.shouldNotReachHere("Header file " + headerFile + " not found at main search location(s): \n" + String.join("\n", mainResult.locations) + (fallbackLocations.size() > 0 ? "\n or any of the fallback locations: \n" + String.join("\n", fallbackLocations) : "") + "\n Use option -H:CLibraryPath to specify header file search locations."); }