private List<String> getNativePaths() { ModuleRevision revision = generation.getRevision(); ModuleWiring wiring = revision.getWiring(); if (wiring == null) { // unresolved? should not be possible return Collections.emptyList(); } if ((revision.getTypes() & BundleRevision.TYPE_FRAGMENT) != 0) { List<ModuleWire> hosts = wiring.getRequiredModuleWires(HostNamespace.HOST_NAMESPACE); if (hosts == null) { // unresolved or invalid? should not be possible return Collections.emptyList(); } if (!hosts.isEmpty()) { // just use the first host wiring wiring = hosts.get(0).getProviderWiring(); } } List<ModuleWire> nativeCode = wiring.getRequiredModuleWires(NativeNamespace.NATIVE_NAMESPACE); if (nativeCode.isEmpty()) { return Collections.emptyList(); } // just taking the first paths for the revision, we sorted correctly when transforming to the // requirement for (ModuleWire moduleWire : nativeCode) { if (moduleWire.getRequirement().getRevision().equals(revision)) { @SuppressWarnings("unchecked") List<String> result = (List<String>) nativeCode .get(0) .getRequirement() .getAttributes() .get(REQUIREMENT_NATIVE_PATHS_ATTRIBUTE); if (result != null) return result; // this must be a multi-clause Bundle-NativeCode header, need to check for the correct one // in the index try { FilterImpl filter = FilterImpl.newInstance( moduleWire .getRequirement() .getDirectives() .get(NativeNamespace.REQUIREMENT_FILTER_DIRECTIVE)); int index = -1; Map<String, Object> capabilityAttrs = moduleWire.getCapability().getAttributes(); for (FilterImpl child : filter.getChildren()) { index++; if (child.matches(capabilityAttrs)) { break; } } if (index != -1) { @SuppressWarnings("unchecked") List<String> indexResult = (List<String>) nativeCode .get(0) .getRequirement() .getAttributes() .get(REQUIREMENT_NATIVE_PATHS_ATTRIBUTE + '.' + index); if (indexResult != null) return indexResult; } } catch (InvalidSyntaxException e) { throw new RuntimeException(e); } } } return Collections.emptyList(); }