Giter Club home page Giter Club logo

Comments (4)

eiiches avatar eiiches commented on June 14, 2024

Thank you for reporting this.

We can't just leave out the thread's context class loader.

In #3, we've decided to use the thread's context class loader in preference to the class's class loader. If this doesn't work in OSGi, we probably need some means to explicitly specify from which class loader to load functions.

How about:

  1. Mark no-arg Scope() constructor as @deprecated.
  2. Add public loadFunctions(ClassLoader) method which does loadMacros() and loadBuiltinsFunctions() internally with a specified class loader.
  3. Optionally add public loadFunctions() which calls loadFunctions(ClassLoader) with a default class loader (which is the thread's context class loader if set, or the class's class loader otherwise).

This can be used like this:

root = new Scope(null)
root.loadFunctions(Scope.class.getClassLoader()) // relatively heavy operation
scope = new Scope(root)

from jackson-jq.

nickbreentvnz avatar nickbreentvnz commented on June 14, 2024

Ah! I hadn't considered loading of custom function definitions. I've read #3 and it makes perfect sense.

In this case it's reasonable to assume that more than one class loader maybe required to load any and all function definitions.

Querying both classloaders would work too.

  1. The Scope Class Loader to load the standard definitions.
  2. The context class loader for custom definitions.

I can put another PR together for that if you like.

from jackson-jq.

eiiches avatar eiiches commented on June 14, 2024

In this case it's reasonable to assume that more than one class loader maybe required to load any and all function definitions.

I agree. In that case, probably we can call loadFunctions(ClassLoader) multiple times with the class loaders.

Querying both classloaders would work too.

I'd rather like to take an explicit loadFunctions(ClassLoader) approach because similar issues can happen sometime again. As to whether loadFunctions(/* no-arg *) should query both class loaders not just one of them, I am not sure. I kind of prefer to re-use the current heuristic (the thread's context class loader if set or the Scope's class loader otherwise) by default.

I can put another PR together for that if you like.

That's great! I'd appreciate it :)

from jackson-jq.

nickbreentvnz avatar nickbreentvnz commented on June 14, 2024

I've updated the PR with those changes.

I've included a couple of minor modifications to the POMs too; to support OSGi bundle JAR and wrapped the nexus plugin in a (default active) profile too. Hope those changes are acceptable.

from jackson-jq.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.