java/com/googlecode/prolog_cafe/lang/PrologClassLoader.java [103:162]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  private CacheEntry findPredicate(String pkg, String functor, int arity)
      throws ClassNotFoundException {
    Key key = new Key(pkg, functor, arity);
    CacheEntry entry = predicateCache.get(key);
    if (entry == null) {
      Class<?> clazz;
      try {
        clazz = Class.forName(
            encode(pkg, functor, arity),
            false /* avoid resolve */,
            this);
      } catch (ClassNotFoundException cnfe) {
        predicateCache.put(key, NotFound.INSTANCE);
        throw cnfe;
      }

      if (!Predicate.class.isAssignableFrom(clazz)) {
        predicateCache.put(key, NotFound.INSTANCE);
        throw new ClassNotFoundException(clazz.getName(),
          new ClassCastException("Does not extend " + Predicate.class));
      }

      Class<?>[] params = new Class[arity + 1];
      for (int i = 0; i < arity; i++)
        params[i] = Term.class;
      params[arity] = Operation.class;

      Constructor<Predicate> cons;
      try {
        cons = (Constructor<Predicate>) clazz.getDeclaredConstructor(params);
      } catch (NoSuchMethodException e) {
        predicateCache.put(key, NotFound.INSTANCE);
        throw new ClassNotFoundException("Wrong constructor on " + clazz.getName(), e);

      } catch (SecurityException e) {
        predicateCache.put(key, NotFound.INSTANCE);
        throw new ClassNotFoundException("Constructor not visible " + clazz.getName(), e);
      }
      cons.setAccessible(true);

      try {
        Class.forName(clazz.getName(), true /* resolve now */, this);
      } catch (ClassNotFoundException e) {
        predicateCache.put(key, NotFound.INSTANCE);
        throw new ClassNotFoundException("Cannot initialize " + clazz.getName(), e);

      } catch (RuntimeException e) {
        predicateCache.put(key, NotFound.INSTANCE);
        throw new ClassNotFoundException("Cannot initialize " + clazz.getName(), e);

      } catch (LinkageError e) {
        predicateCache.put(key, NotFound.INSTANCE);
        throw new ClassNotFoundException("Cannot initialize " + clazz.getName(), e);
      }

      entry = new ValidPredicate(cons);
      predicateCache.put(key, entry);
    }
    return entry;
  }
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



src/lang/PrologClassLoader.java [103:162]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  private CacheEntry findPredicate(String pkg, String functor, int arity)
      throws ClassNotFoundException {
    Key key = new Key(pkg, functor, arity);
    CacheEntry entry = predicateCache.get(key);
    if (entry == null) {
      Class<?> clazz;
      try {
        clazz = Class.forName(
            encode(pkg, functor, arity),
            false /* avoid resolve */,
            this);
      } catch (ClassNotFoundException cnfe) {
        predicateCache.put(key, NotFound.INSTANCE);
        throw cnfe;
      }

      if (!Predicate.class.isAssignableFrom(clazz)) {
        predicateCache.put(key, NotFound.INSTANCE);
        throw new ClassNotFoundException(clazz.getName(),
          new ClassCastException("Does not extend " + Predicate.class));
      }

      Class<?>[] params = new Class[arity + 1];
      for (int i = 0; i < arity; i++)
        params[i] = Term.class;
      params[arity] = Operation.class;

      Constructor<Predicate> cons;
      try {
        cons = (Constructor<Predicate>) clazz.getDeclaredConstructor(params);
      } catch (NoSuchMethodException e) {
        predicateCache.put(key, NotFound.INSTANCE);
        throw new ClassNotFoundException("Wrong constructor on " + clazz.getName(), e);

      } catch (SecurityException e) {
        predicateCache.put(key, NotFound.INSTANCE);
        throw new ClassNotFoundException("Constructor not visible " + clazz.getName(), e);
      }
      cons.setAccessible(true);

      try {
        Class.forName(clazz.getName(), true /* resolve now */, this);
      } catch (ClassNotFoundException e) {
        predicateCache.put(key, NotFound.INSTANCE);
        throw new ClassNotFoundException("Cannot initialize " + clazz.getName(), e);

      } catch (RuntimeException e) {
        predicateCache.put(key, NotFound.INSTANCE);
        throw new ClassNotFoundException("Cannot initialize " + clazz.getName(), e);

      } catch (LinkageError e) {
        predicateCache.put(key, NotFound.INSTANCE);
        throw new ClassNotFoundException("Cannot initialize " + clazz.getName(), e);
      }

      entry = new ValidPredicate(cons);
      predicateCache.put(key, entry);
    }
    return entry;
  }
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



