Class Verifier

All Implemented Interfaces:
Constants, Registry, Report, Reporter, Closeable, AutoCloseable, Iterable<String>

public class Verifier extends Processor
  • Field Details

    • dot

      private final Jar dot
    • manifest

      private final Manifest manifest
    • main

      private final Domain main
    • r3

      private boolean r3
    • usesRequire

      private boolean usesRequire
    • EENAME

      static final Pattern EENAME
    • EES

      public static final String[] EES
    • ReservedFileNames

      public static final Pattern ReservedFileNames
    • CARDINALITY_PATTERN

      static final Pattern CARDINALITY_PATTERN
    • RESOLUTION_PATTERN

      static final Pattern RESOLUTION_PATTERN
    • BUNDLEMANIFESTVERSION

      static final Pattern BUNDLEMANIFESTVERSION
    • TOKEN

      public static final Pattern TOKEN
    • EXTENDED_S

      public static final String EXTENDED_S
      See Also:
    • EXTENDED_P

      public static final Pattern EXTENDED_P
    • QUOTEDSTRING

      public static final String QUOTEDSTRING
      See Also:
    • QUOTEDSTRING_P

      public static final Pattern QUOTEDSTRING_P
    • ARGUMENT_S

      public static final String ARGUMENT_S
      See Also:
    • ARGUMENT_P

      public static final Pattern ARGUMENT_P
    • SYMBOLICNAME_STRING

      public static final String SYMBOLICNAME_STRING
      See Also:
    • SYMBOLICNAME

      public static final Pattern SYMBOLICNAME
    • VERSION_STRING

      public static final String VERSION_STRING
      See Also:
    • VERSION_S

      public static final String VERSION_S
      See Also:
    • VERSION

      public static final Pattern VERSION
    • VERSION_P

      public static final Pattern VERSION_P
    • VERSIONRANGE

      public static final Pattern VERSIONRANGE
    • VERSION_RANGE_S

      public static final String VERSION_RANGE_S
      See Also:
    • VERSIONRANGE_P

      public static final Pattern VERSIONRANGE_P
    • FILTEROP

      static final Pattern FILTEROP
    • FILE

      static final Pattern FILE
    • WILDCARDPACKAGE

      static final Pattern WILDCARDPACKAGE
    • ISO639

      public static final Pattern ISO639
    • HEADER_PATTERN

      public static final Pattern HEADER_PATTERN
    • NUMBERPATTERN

      public static final Pattern NUMBERPATTERN
    • FLOATPATTERN

      public static final Pattern FLOATPATTERN
    • BOOLEANPATTERN

      public static final Pattern BOOLEANPATTERN
    • PACKAGEPATTERN

      public static final Pattern PACKAGEPATTERN
    • PACKAGEPATTERN_OR_EMPTY

      public static final Pattern PACKAGEPATTERN_OR_EMPTY
    • MULTIPACKAGEPATTERN

      public static final Pattern MULTIPACKAGEPATTERN
    • PATHPATTERN

      public static final Pattern PATHPATTERN
    • FQNPATTERN

      public static final Pattern FQNPATTERN
    • URLPATTERN

      public static final Pattern URLPATTERN
    • ANYPATTERN

      public static final Pattern ANYPATTERN
    • FILTERPATTERN

      public static final Pattern FILTERPATTERN
    • TRUEORFALSEPATTERN

      public static final Pattern TRUEORFALSEPATTERN
    • WILDCARDNAMEPATTERN

      public static final Pattern WILDCARDNAMEPATTERN
    • BUNDLE_ACTIVATIONPOLICYPATTERN

      public static final Pattern BUNDLE_ACTIVATIONPOLICYPATTERN
    • OSNAMES

      public static final String[] OSNAMES
    • PROCESSORNAMES

      public static final String[] PROCESSORNAMES
    • analyzer

      final Analyzer analyzer
    • dynamicImports

      private Instructions dynamicImports
    • frombuilder

      private boolean frombuilder
  • Constructor Details

  • Method Details

    • verifyHeaders

      private void verifyHeaders()
    • verifyNative

      public void verifyNative()
    • doNative

      public void doNative(String nc)
    • verifyFilter

      public boolean verifyFilter(String value)
    • validateFilter

      public static String validateFilter(String value)
    • verifyActivator

      private void verifyActivator() throws Exception
      Throws:
      Exception
    • registerActivatorErrorLocation

      private void registerActivatorErrorLocation(Reporter.SetLocation location, String activator, Verifier.ActivatorErrorType errorType) throws Exception
      Throws:
      Exception
    • verifyComponent

      private void verifyComponent()
    • verifyUnresolvedReferences

      private void verifyUnresolvedReferences() throws Exception
      Check for unresolved imports. These are referrals that are not imported by the manifest and that are not part of our bundle class path. The are calculated by removing all the imported packages and contained from the referred packages.
      Throws:
      Exception
    • isDynamicImport

      private boolean isDynamicImport(Descriptors.PackageRef pack)
    • hasOverlap

      private boolean hasOverlap(Set<?> a, Set<?> b)
    • verify

      public void verify() throws Exception
      Throws:
      Exception
    • doVerifierPlugins

      private void doVerifierPlugins()
    • verifyPathNames

      void verifyPathNames()
      Verify of the path names in the JAR are valid on all OS's (mainly windows)
    • verifyImports

      private void verifyImports()
      Verify that the imports properly use version ranges.
    • verifyExports

      private void verifyExports()
      Verify that the exports only use versions.
    • showUnicode

      private Object showUnicode(String key)
    • verifyRequirements

      private void verifyRequirements() throws IllegalArgumentException, Exception
      Throws:
      IllegalArgumentException
      Exception
    • verifyAttrs

      void verifyAttrs(String key, Attrs attrs)
      Parameters:
      attrs -
    • verifyCapabilities

      private void verifyCapabilities()
    • verifyNamespace

      private void verifyNamespace(String ns, String type)
    • verify

      private void verify(Attrs attrs, String ad, Pattern pattern, boolean mandatory, String msg, String... args)
    • verifyType

      private void verifyType(Attrs.Type type, String string)
    • verifyDirectives

      private void verifyDirectives(String header, String directives, Pattern namePattern, String type) throws Exception
      Verify if the header does not contain any other directives
      Parameters:
      header -
      directives -
      namePattern -
      type -
      Throws:
      Exception
    • verifyDirectives

      private void verifyDirectives(String header, Function<String,String> directives, Pattern namePattern, String type) throws Exception
      Verify if the header does not contain any other directives
      Parameters:
      header -
      directives -
      namePattern -
      type -
      Throws:
      Exception
    • verifyUses

      private void verifyUses()
      Verify the use clauses
    • verifyActivationPolicy

      public boolean verifyActivationPolicy()
    • verifyActivationPolicy

      public boolean verifyActivationPolicy(String policy)
    • verifyBundleClasspath

      public void verifyBundleClasspath()
    • verifyDynamicImportPackage

      private void verifyDynamicImportPackage()
                DynamicImport-Package ::= dynamic-description
                    ( ',' dynamic-description )*
      
                dynamic-description::= wildcard-names ( ';' parameter )*
                wildcard-names ::= wildcard-name ( ';' wildcard-name )*
                wildcard-name ::= package-name
                               | ( package-name '.*' ) // See 1.4.2
                               | '*'
       
    • verifyManifestFirst

      private void verifyManifestFirst()
    • verifySymbolicName

      private void verifySymbolicName()
    • isBsn

      public static boolean isBsn(String name)
      Parameters:
      name - the String to test
      Returns:
      true if the given name matches a Bundle Symbolic Name, otherwise false
    • verifyFilter

      public static int verifyFilter(String expr, int index)
               filter ::= ’(’ filter-comp ’)’
               filter-comp ::= and | or | not | operation
               and ::= ’&’ filter-list
               or ::= ’|’ filter-list
               not ::= ’!’ filter
               filter-list ::= filter | filter filter-list
               operation ::= simple | present | substring
               simple ::= attr filter-type value
               filter-type ::= equal | approx | greater | less
               equal ::= ’=’
               approx ::= ’˜=’
               greater ::= ’>=’
               less ::= ’<=’
               present ::= attr ’=*’
               substring ::= attr ’=’ initial any final
               inital ::= () | value
               any ::= ’*’ star-value
               star-value ::= () | value ’*’ star-value
               final ::= () | value
               value ::= <see text>
       
      Parameters:
      expr - the String to test
      index - the index within expr to start with
      Returns:
      the index of the last character within expr that was evaluated
    • verifyFilterOperation

      private static int verifyFilterOperation(String expr, int index)
    • verifyHeader

      private boolean verifyHeader(String name, Pattern regex, boolean error)
    • verify

      private static boolean verify(String value, Pattern regex)
    • verifyListHeader

      private boolean verifyListHeader(String name, Pattern regex, boolean error)
    • isVersion

      public static boolean isVersion(String version)
    • isIdentifier

      public static boolean isIdentifier(String value)
    • isMember

      public static boolean isMember(String value, String[] matches)
    • isFQN

      public static boolean isFQN(String name)
    • verifyChecksums

      public void verifyChecksums(boolean all) throws Exception
      Verify the checksums from the manifest against the real thing.
      Parameters:
      all - true if each resource must be digested, otherwise false
      Throws:
      Exception
    • isExtended

      public static boolean isExtended(String key)
      Verify the EXTENDED_S syntax
      Parameters:
      key - the String to test
      Returns:
      true if the given String matches the EXTENDED_S syntax, otherwise false
    • isArgument

      public static boolean isArgument(String arg)
      Verify the ARGUMENT_S syntax
      Parameters:
      arg - the String to test
      Returns:
      true if the given String matches the ARGUMENT_S syntax, otherwise false
    • isQuotedString

      public static boolean isQuotedString(String s)
      Verify the QUOTEDSTRING syntax
      Parameters:
      s - the String to test
      Returns:
      true if the given String matches the QUOTEDSTRING syntax, otherwise false
    • isVersionRange

      public static boolean isVersionRange(String range)
      Verify the VERSION_RANGE_S syntax
      Parameters:
      range - the String to test
      Returns:
      true if the given String matches the VERSION_RANGE_S syntax, otherwise false
    • verifyMetaPersistence

      public void verifyMetaPersistence() throws Exception
      Verify the Meta-Persistence header
      Throws:
      Exception
    • isFrombuilder

      public boolean isFrombuilder()
      Returns:
      the frombuilder
    • setFrombuilder

      public void setFrombuilder(boolean frombuilder)
      Parameters:
      frombuilder - the frombuilder to set
    • isNumber

      public static boolean isNumber(String number)
    • isSpaceSeparated

      public static boolean isSpaceSeparated(String r)
      The -runvm header is often wrongly used as a space separated header instead of a properties. This checks if a header uses commas to separate the parts or spaces.
      Parameters:
      r - a header
      Returns:
      true if spaces are used for separation, false if 1 parameter or commas used