Hi Christian,

thanks for your feedback, I hope you're doing well!

> I have some concerns that the caching of non-existing classes could be
> exploited and bloat the cache. Maybe we’d need to use WeakHashMap
> (and/or soft references) instead?

I didn't think about that, I'll try to come up with a better solution.

>> I'm not sure why BaseX tries to load our xqm as Java Modules, but
>> what I noticed is that Reflect.forName caches the positive case
>> (i.e., the class is found), but not the negative case (i.e., the class is 
>> not found).
>
> Sounds like an interesting finding; maybe there’s something we can
> optimize here. Could you possibly provide us a little self-contained
> example that demonstrates the behavior?

Sure. This is what I'm doing:

Given the following module (installed with module install foo.xqm):

module namespace uc = 'http://unifits.com/common';
declare function uc:remove-elements($input as element(), $remove-names as 
xs:string*) as element() {
  element {node-name($input) }
  {$input/@*,
    for $child in $input/node()[not(local-name() = $remove-names)]
    return
      if ($child instance of element())
      then uc:remove-elements($child, $remove-names)
      else $child
   }
};


if I start BaseXGui in debug mode, and set a breakpoint in
Reflect.forName(), every time I execute a query such as

import module namespace uc = 'http://unifits.com/common';
/

the breakpoint is hit, i.e. Class.forName() is called. 
I *think* this might have to do with the fact that the function above is
recursive, but I have to admit that I don't really grasp the code that
does the module loading/parsing.

Thanks,
-tom

Reply via email to