Re: PL/Java new build plugin

From: Chapman Flack <chap(at)anastigmatix(dot)net>
To: Kartik Ohri <kartikohri13(at)gmail(dot)com>
Cc: pljava-dev(at)lists(dot)postgresql(dot)org
Subject: Re: PL/Java new build plugin
Date: 2020-07-18 20:28:52
Message-ID: 5F135B84.8070302@anastigmatix.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pljava-dev

On 07/18/20 15:49, Kartik Ohri wrote:
> inside out. maven.plugin.classpath is not something that maven declares. It
> is declared by the maven antrun plugin for use by ant tasks [2]
> <https://github.com/apache/maven-antrun-plugin/blob/8e5b3c613e96c20881347ec16813864a2d8ef0bb/src/main/java/org/apache/maven/plugins/antrun/AntRunMojo.java#L383>.

Aha! And it generates that using getPathFromArtifacts(), which just goes
through its own dependency list and collects the jar names (which are
maybe the exact same jar names its current ClassRealm loader is using).

I wonder what would happen just making a dead-simple ClassLoader with
two "parents" and otherwise no functionality of its own. Of course it
could only have one real parent and an instance field for the 'extra' one.

Create it so one 'parent' is the ClassRealm loader that loaded us, and the
other is from getSystemClassLoader() (they changed the official name to
"application class loader" but didn't rename the method). Have its findClass
method just say "either parent A has it or parent B has it or I haven't
heard of it, sorry."

(In fact, findClass doesn't get called until the 'real' parent has already
been checked, so it doesn't need to do anything besides check the 'extra'
parent and return what it finds, if anything.)

That would leave the question of which parent should be the real one and
which should be the extra one, since the real one is the one that gets
searched first. In Java tradition, the app loader would be the real one.
For Maven it might be better to make the ClassRealm the real one, so
everything Maven constructed gets used, except when it fails to find
something.

I think you can pass a chosen ClassLoader directly to the
ScriptEngineManager constructor, so this special loader wouldn't need
to be used anywhere but there.

What Could Possibly Go Wrong?™

Regards,
-Chap

In response to

Responses

Browse pljava-dev by date

  From Date Subject
Next Message Kartik Ohri 2020-07-19 06:28:11 Re: PL/Java new build plugin
Previous Message Kartik Ohri 2020-07-18 19:49:42 Re: PL/Java new build plugin