Hi Christian,
I'm not seeing any exceptions in the console window, even when enabling the debug setting. I'm using the AdoptOpenJDK 1.8. I also have AdoptOpenJDK 11, but I assume that will have the issue you described.
It's a custom-built jar using Kotlin, built via gradle.
One thing that it could be is that I'm using Kotlin objects (not classes), e.g.:
package test
object Test { fun f(): String = "test" }
and using it like:
declare namespace Test = "java:test.Test";
declare function test:f() as xs:string {
Test::f(Test::INSTANCE())
};
The build.gradle file is simple. It looks something like this (removing things like the junit configuration):
-----
buildscript {
ext.kotlin_version = "1.4.32"
ext.kotlin_stdlib = "kotlin-stdlib"
ext.java_version = "1.8"
repositories { mavenCentral() }
dependencies { classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" }
}
apply plugin: 'kotlin'
repositories {
mavenCentral()
mavenLocal()
}
compileKotlin { kotlinOptions { jvmTarget = java_version } }
compileTestKotlin { kotlinOptions { jvmTarget = java_version } }
dependencies {
implementation "org.jetbrains.kotlin:$kotlin_stdlib:$kotlin_version"
}
-----
You'll need to copy the kotlin-stdlib-1.4.32.jar file in addition to the test.jar file to BaseX's lib directory.
Kind regards,
Reece
Hi Reece,
I’m sorry to hear that. Did you build a custom JAR file, or do you
encounter problems with the JDK?
Cheers,
Christian
On Thu, Apr 29, 2021 at 9:48 PM Reece Dunn <msclrhd@googlemail.com> wrote:
>
> Hi Christian,
>
> Thanks for the response. Unfortunately, I've not been able to get the reloading working.
>
> Kind regards,
> Reece
>
> On Wed, 21 Apr 2021 at 18:49, Christian Grün <christian.gruen@gmail.com> wrote:
>>
>> Hi Reece,
>>
>> If you install your Java code as JAR file in the repository [1], the
>> code will be loaded and unloaded every time when your query is
>> executed. If you get an error message…
>>
>> java.lang.reflect.InaccessibleObjectException: Unable to make field
>> private final jdk.internal.loader.URLClassPath
>> java.net.URLClassLoader.ucp accessible: module java.base does not
>> "opens java.net" to unnamed module @79e2c065
>>
>> …unloading fails [2], as you’re probably using a more recent version
>> of the JDK, which restricts reflective access to internal variables.
>> You can get around this by adding Java flags at startup time:
>>
>> --add-opens java.base/java.net=ALL-UNNAMED
>> --add-opens java.base/jdk.internal.loader=ALL-UNNAMED
>>
>> Maybe there are better solutions to unload JAR files today.
>> Suggestions are welcome!
>>
>> Hope this helps,
>> Christian
>>
>> [1] https://docs.basex.org/wiki/Repository#Java
>> [2] https://github.com/BaseXdb/basex/blob/master/basex-core/src/main/java/org/basex/util/JarLoader.java#L34
>>
>>
>>
>> On Tue, Apr 20, 2021 at 6:44 PM Reece Dunn <msclrhd@googlemail.com> wrote:
>> >
>> > Hi all,
>> >
>> > I'm working on a Java class that I'm importing into an XQuery, so I can do additional processing on the data that isn't easily expressible in XQuery (or XSLT). In order to get BaseX to pick up a modified version of the jar file I'm building, I'm restarting the BaseX http server.
>> >
>> > This makes it slower to turn around testing the changes. Is there a better way of doing this?
>> >
>> > Kind regards,
>> > Reece