Very niche question about BaseX 9.5.1 and java bindings
Monday, 22 August 2022 · 3 messages
AB
Andy Bunce22 Aug 2022 16:11 #
Hi,
I am trying to write a Java property file using v9.5.1 and no new Java code. The code below runs in 9.7.3. Although it only uses 9.5 features in 9.5.1 it produces the error message
props:store·java.io.Writer·String cannot be called with (Writer, String). but
https://docs.oracle.com/javase/8/docs/api/java/util/Properties.html#store-java.io.Writer-java.lang.String-
I assume this is a 9.5.1 java binding bug?
Any workaround suggestions or details of what the problem is? /Andy
-----------------------------------------------
(:~ Using Basex 9.5.1
and assuming a file "test.properties" in folder containing this module:)
import module namespace props = "java:java.util.Properties";
declare variable $source:=
file:resolve-path("test.properties",file:base-dir()) !(prof:void(props:load·java.io.Reader(Q{java:java.io.FileReader}new(.))),.)
;
props:store·java.io.Writer·String( Q{java:java.io.FileWriter}new($source), "The saucer has landed")
AB
Andy Bunce22 Aug 2022 16:17 #
Got it I think...
props:store·java.io.Writer·*java.lang.String*(
Q{java:java.io.FileWriter}new($source), "The saucer has landed")
Quoted text · Andy Bunce · 30 lines
On Mon, 22 Aug 2022 at 15:11, Andy Bunce <bunce.andy at gmail.com> wrote: > Hi, > > I am trying to write a Java property file using v9.5.1 and no new Java > code. > The code below runs in 9.7.3. Although it only uses 9.5 features in 9.5.1 > it produces the error message > > props:store·java.io.Writer·String cannot be called with (Writer, String). > but > https://docs.oracle.com/javase/8/docs/api/java/util/Properties.html#store-java.io.Writer-java.lang.String- > > I assume this is a 9.5.1 java binding bug? > Any workaround suggestions or details of what the problem is? > /Andy > > ----------------------------------------------- > (:~ Using Basex 9.5.1 > and assuming a file "test.properties" in folder containing this module:) > import module namespace props = "java:java.util.Properties"; > declare variable $source:= > file:resolve-path("test.properties",file:base-dir()) > > !(prof:void(props:load·java.io.Reader(Q{java:java.io.FileReader}new(.))),.) > > ; > > props:store·java.io.Writer·String( Q{java:java.io.FileWriter}new($source), > "The saucer has landed") >
CG
Christian Grün22 Aug 2022 16:26 #
Hi Andy, exactly: In previous versions, the java.lang standard package needed to be specified. Best, Christian
Quoted text · Andy Bunce · 37 lines
Andy Bunce <bunce.andy at gmail.com> schrieb am Mo., 22. Aug. 2022, 16:18: > Got it I think... > props:store·java.io.Writer·*java.lang.String*( > Q{java:java.io.FileWriter}new($source), "The saucer has landed") > > On Mon, 22 Aug 2022 at 15:11, Andy Bunce <bunce.andy at gmail.com> wrote: > >> Hi, >> >> I am trying to write a Java property file using v9.5.1 and no new Java >> code. >> The code below runs in 9.7.3. Although it only uses 9.5 features in 9.5.1 >> it produces the error message >> >> props:store·java.io.Writer·String cannot be called with (Writer, String). >> but >> https://docs.oracle.com/javase/8/docs/api/java/util/Properties.html#store-java.io.Writer-java.lang.String- >> >> I assume this is a 9.5.1 java binding bug? >> Any workaround suggestions or details of what the problem is? >> /Andy >> >> ----------------------------------------------- >> (:~ Using Basex 9.5.1 >> and assuming a file "test.properties" in folder containing this module:) >> import module namespace props = "java:java.util.Properties"; >> declare variable $source:= >> file:resolve-path("test.properties",file:base-dir()) >> >> !(prof:void(props:load·java.io.Reader(Q{java:java.io.FileReader}new(.))),.) >> >> ; >> >> props:store·java.io.Writer·String( >> Q{java:java.io.FileWriter}new($source), "The saucer has landed") >> >
Written for BaseX 10.1. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery