public boolean verifyActivationPolicy() { String policy = getHeader(Constants.BUNDLE_ACTIVATIONPOLICY); if (policy == null) return true; return verifyActivationPolicy(policy); }
public boolean verifyActivationPolicy() { String policy = getHeader(Constants.BUNDLE_ACTIVATIONPOLICY); if (policy == null) return true; return verifyActivationPolicy(policy); }
public void verifyNative() { String nc = getHeader("Bundle-NativeCode"); doNative(nc); }
public void verifyNative() { String nc = getHeader("Bundle-NativeCode"); doNative(nc); }
private void verifySymbolicName() { Map<String, Map<String, String>> bsn = parseHeader(getHeader(Analyzer.BUNDLE_SYMBOLICNAME)); if (!bsn.isEmpty()) { if (bsn.size() > 1) error("More than one BSN specified " + bsn); String name = (String) bsn.keySet().iterator().next(); if (!SYMBOLICNAME.matcher(name).matches()) { error("Symbolic Name has invalid format: " + name); } } }
public void verifyBundleClasspath() { Map<String, Map<String, String>> bcp = parseHeader(getHeader(Analyzer.BUNDLE_CLASSPATH)); if (bcp.isEmpty() || bcp.containsKey(".")) return; for (String path : dot.getResources().keySet()) { if (path.endsWith(".class")) { warning("The Bundle-Classpath does not contain the actual bundle JAR (as specified with '.' in the Bundle-Classpath) but the JAR does contain classes. Is this intentional?"); return; } } }
private void verifySymbolicName() { Map<String, Map<String, String>> bsn = parseHeader(getHeader(Analyzer.BUNDLE_SYMBOLICNAME)); if (!bsn.isEmpty()) { if (bsn.size() > 1) error("More than one BSN specified " + bsn); String name = (String) bsn.keySet().iterator().next(); if (!isBsn(name)) { error("Symbolic Name has invalid format: " + name); } } }
/** * Invalid imports are imports that we never refer to. They can be * calculated by removing the refered packages from the imported packages. * This leaves packages that the manifest imported but that we never use. */ private void verifyInvalidImports() { Set<String> invalidImport = newSet(mimports.keySet()); invalidImport.removeAll(referred.keySet()); // TODO Added this line but not sure why it worked before ... invalidImport.removeAll(contained.keySet()); String bactivator = getHeader(Analyzer.BUNDLE_ACTIVATOR); if (bactivator != null) { int n = bactivator.lastIndexOf('.'); if (n > 0) { invalidImport.remove(bactivator.substring(0, n)); } } if (isPedantic() && !invalidImport.isEmpty()) warning("Importing packages that are never refered to by any class on the Bundle-Classpath" + bundleClasspath + ": " + invalidImport); }
/** * Invalid imports are imports that we never refer to. They can be * calculated by removing the refered packages from the imported packages. * This leaves packages that the manifest imported but that we never use. */ private void verifyInvalidImports() { Set<String> invalidImport = newSet(mimports.keySet()); invalidImport.removeAll(referred.keySet()); // TODO Added this line but not sure why it worked before ... invalidImport.removeAll(contained.keySet()); String bactivator = getHeader(Analyzer.BUNDLE_ACTIVATOR); if (bactivator != null) { int n = bactivator.lastIndexOf('.'); if (n > 0) { invalidImport.remove(bactivator.substring(0, n)); } } if (isPedantic() && !invalidImport.isEmpty()) warning("Importing packages that are never refered to by any class on the Bundle-Classpath" + bundleClasspath + ": " + invalidImport); }
private void verifyComponent() { String serviceComponent = getHeader("Service-Component"); if (serviceComponent != null) { Map<String, Map<String, String>> map = parseHeader(serviceComponent); for (String component : map.keySet()) { if (component.indexOf("*") < 0 && !dot.exists(component)) { error("Service-Component entry can not be located in JAR: " + component); } else { // validate component ... } } } }
private void verifyComponent() { String serviceComponent = getHeader("Service-Component"); if (serviceComponent != null) { Map<String, Map<String, String>> map = parseHeader(serviceComponent); for (String component : map.keySet()) { if (component.indexOf("*") < 0 && !dot.exists(component)) { error("Service-Component entry can not be located in JAR: " + component); } else { // validate component ... } } } }
public Verifier(Jar jar, Properties properties) throws Exception { this.dot = jar; this.properties = properties; this.manifest = jar.getManifest(); if (manifest == null) { manifest = new Manifest(); error("This file contains no manifest and is therefore not a bundle"); } main = this.manifest.getMainAttributes(); verifyHeaders(main); r3 = getHeader(Analyzer.BUNDLE_MANIFESTVERSION) == null; usesRequire = getHeader(Analyzer.REQUIRE_BUNDLE) != null; fragment = getHeader(Analyzer.FRAGMENT_HOST) != null; bundleClasspath = getBundleClassPath(); mimports = parseHeader(manifest.getMainAttributes().getValue( Analyzer.IMPORT_PACKAGE)); mdynimports = parseHeader(manifest.getMainAttributes().getValue( Analyzer.DYNAMICIMPORT_PACKAGE)); mexports = parseHeader(manifest.getMainAttributes().getValue( Analyzer.EXPORT_PACKAGE)); ignore = parseHeader(manifest.getMainAttributes().getValue( Analyzer.IGNORE_PACKAGE)); }
private void verifyActivator() { String bactivator = getHeader("Bundle-Activator"); if (bactivator != null) { Clazz cl = loadClass(bactivator); if (cl == null) { int n = bactivator.lastIndexOf('.'); if (n > 0) { String pack = bactivator.substring(0, n); if (mimports.containsKey(pack)) return; error("Bundle-Activator not found on the bundle class path nor in imports: " + bactivator); } else error("Activator uses default package and is not local (default package can not be imported): " + bactivator); } } }
private void verifyActivator() { String bactivator = getHeader("Bundle-Activator"); if (bactivator != null) { Clazz cl = loadClass(bactivator); if (cl == null) { int n = bactivator.lastIndexOf('.'); if (n > 0) { String pack = bactivator.substring(0, n); if (mimports.containsKey(pack)) return; error("Bundle-Activator not found on the bundle class path nor in imports: " + bactivator); } else error("Activator uses default package and is not local (default package can not be imported): " + bactivator); } } }
public void verifyBundleClasspath() { Map<String, Map<String, String>> bcp = parseHeader(getHeader(Analyzer.BUNDLE_CLASSPATH)); if (bcp.isEmpty() || bcp.containsKey(".")) return; for ( String path : bcp.keySet() ) { if ( path.endsWith("/")) error("A Bundle-ClassPath entry must not end with '/': %s", path); if ( dot.getDirectories().containsKey(path)) // We assume that any classes are in a directory // and therefore do not care when the bundle is included return; } for (String path : dot.getResources().keySet()) { if (path.endsWith(".class")) { warning("The Bundle-Classpath does not contain the actual bundle JAR (as specified with '.' in the Bundle-Classpath) but the JAR does contain classes. Is this intentional?"); return; } } }
public Verifier(Jar jar, Properties properties) throws Exception { this.dot = jar; this.properties = properties; this.manifest = jar.getManifest(); if (manifest == null) { manifest = new Manifest(); error("This file contains no manifest and is therefore not a bundle"); } main = this.manifest.getMainAttributes(); verifyHeaders(main); r3 = getHeader(Analyzer.BUNDLE_MANIFESTVERSION) == null; usesRequire = getHeader(Analyzer.REQUIRE_BUNDLE) != null; fragment = getHeader(Analyzer.FRAGMENT_HOST) != null; bundleClasspath = getBundleClassPath(); mimports = parseHeader(manifest.getMainAttributes().getValue( Analyzer.IMPORT_PACKAGE)); mdynimports = parseHeader(manifest.getMainAttributes().getValue( Analyzer.DYNAMICIMPORT_PACKAGE)); mexports = parseHeader(manifest.getMainAttributes().getValue( Analyzer.EXPORT_PACKAGE)); ignore = parseHeader(manifest.getMainAttributes().getValue( Analyzer.IGNORE_PACKAGE)); }
String dynamicImportPackage = getHeader("DynamicImport-Package"); if (dynamicImportPackage == null) return;
String dynamicImportPackage = getHeader("DynamicImport-Package"); if (dynamicImportPackage == null) return;
public void verify() throws IOException { if (classSpace == null) classSpace = analyzeBundleClasspath(dot, parseHeader(getHeader(Analyzer.BUNDLE_CLASSPATH)), contained, referred, uses); verifyManifestFirst(); verifyActivator(); verifyActivationPolicy(); verifyComponent(); verifyNative(); verifyInvalidExports(); verifyInvalidImports(); verifyUnresolvedReferences(); verifySymbolicName(); verifyListHeader("Bundle-RequiredExecutionEnvironment", EENAME, false); verifyHeader("Bundle-ManifestVersion", BUNDLEMANIFESTVERSION, false); verifyHeader("Bundle-Version", VERSION, true); verifyListHeader("Bundle-Classpath", FILE, false); verifyDynamicImportPackage(); verifyBundleClasspath(); if (usesRequire) { if (!getErrors().isEmpty()) { getWarnings() .add( 0, "Bundle uses Require Bundle, this can generate false errors because then not enough information is available without the required bundles"); } } }
public void verify() throws Exception { if (classSpace == null) classSpace = analyzeBundleClasspath(dot, parseHeader(getHeader(Analyzer.BUNDLE_CLASSPATH)), contained, referred, uses);