Beispiel #1
0
 /**
  * Load an interprocedural property database.
  *
  * @param <DatabaseType> actual type of the database
  * @param <KeyType> type of key (e.g., method or field)
  * @param <Property> type of properties stored in the database
  * @param database the empty database object
  * @param resourceName name of resource to load the database from
  * @param description description of the database (for diagnostics)
  * @return the database object, or null if the database couldn't be loaded
  */
 public <
         DatabaseType extends PropertyDatabase<KeyType, Property>,
         KeyType extends FieldOrMethodDescriptor,
         Property>
     DatabaseType loadPropertyDatabaseFromResource(
         DatabaseType database, String resourceName, String description) {
   try {
     if (DEBUG) {
       System.out.println(
           "Loading default "
               + description
               + " from "
               + resourceName
               + " @ "
               + database.getClass().getResource(resourceName)
               + " ... ");
     }
     try (InputStream in = database.getClass().getResourceAsStream(resourceName)) {
       if (in == null) {
         AnalysisContext.logError(
             "Unable to load " + description + " from resource " + resourceName);
       } else {
         database.read(in);
       }
     }
     return database;
   } catch (IOException e) {
     getLookupFailureCallback().logError("Error loading " + description, e);
   } catch (PropertyDatabaseFormatException e) {
     getLookupFailureCallback().logError("Invalid " + description, e);
   }
   return null;
 }