Hi Gunther,

I agree, it wouldn’t make too much sense to add a default constructor
to your code as long as there is the one-argument constructor that
will be called by the parseXQuery function.

The reason why a default constructor is required in BaseX is because
"import module" will always create an instance of the imported Java
class, which can then be addressed in the XQuery code, using the
assigned prefix [1].

@Andy: For creating a BaseX module, you could add another simple Java
class, which will then call the actual parser class:

  import org.basex.query.value.item.Str;
  import org.basex.query.value.node.ANode;
  public class XQuery31Parser {
    public ANode parseXQuery(Str str) throws IOException {
      return CR_xquery_31_20151217.parseXQuery(str);
    }
  }

Hope this helps,
Christian

[1] http://docs.basex.org/wiki/Java_Bindings#Module_Imports



On Thu, Apr 7, 2016 at 11:54 PM, Gunther Rademacher <g...@gmx.net> wrote:
> Hi Andy, Christian,
>
> a default constructor is added implicitly, when a class does not provide any
> constructors itself. A REx-generated class however comes with a constructor.
> In that case any instantiation must provide arguments for some defined
> constructor.
>
> However I do not see a real reason for instantiating the class at load time.
> The generated parse function is static and it takes care of instantiating a
> parser object internally.
>
> I just did a quick test and found that I see this instantiating problem when
> using "import module namespace ...". No problem when using "declare
> namespace ...." or just an EQName literal instead. I have put my extension
> function class files into the classpath for checking this.
>
> Am I missing something here?
>
> Best regards
> Gunther
>
> Gesendet: Donnerstag, 07. April 2016 um 19:34 Uhr
> Von: "Christian Grün" <christian.gr...@gmail.com>
> An: "Andy Bunce" <bunce.a...@gmail.com>
> Cc: "Gunther Rademacher" <g...@gmx.net>, "basex-talk@mailman.uni-konstanz.de"
> <basex-talk@mailman.uni-konstanz.de>
> Betreff: Re: [basex-talk] Problem deleting jar packaged item from repo
>> I can't see why Java's Default Constructor [1] rule does not apply here?
>
> Well, me neither ;) Maybe it’s got to do with the way we instantiate
> the class via reflection? I didn’t track this down yet (I should
> probably do so).
>
>
>> /Andy
>> http://docs.oracle.com/javase/specs/jls/se7/html/jls-8.html#jls-8.8.9
>>
>> On 7 April 2016 at 17:58, Christian Grün <christian.gr...@gmail.com>
>> wrote:
>>>
>>> > No constructor is the issue. Adding
>>> > public CR_xquery_31_20151217() {}
>>> > to java src fixes it.
>>>
>>> Thanks! @Gunther: Do you think such a dummy constructor could be added
>>> to the Java class?
>>>
>>>
>>>
>>> > On 7 April 2016 at 16:05, Andy Bunce <bunce.a...@gmail.com> wrote:
>>> >>
>>> >> C:\Program Files (x86)\BaseX\bin
>>> >> +>basex -d
>>> >> BaseX 8.4.3 beta d7bbbe7 [Standalone]
>>> >> Try 'help' to get more information.
>>> >> > xquery import module namespace
>>> >> > p="org.basex.modules.CR_xquery_31_20151217";2
>>> >> Creating Database...
>>> >> . 27.04 ms (25844 KB)
>>> >> Creating Database...
>>> >> . 4.83 ms (25844 KB)
>>> >> Creating Database...
>>> >> . 5.0 ms (25844 KB)
>>> >> Creating Database...
>>> >> . 3.52 ms (26509 KB)
>>> >> Creating Database...
>>> >> . 4.36 ms (26509 KB)
>>> >> Creating Database...
>>> >> . 8.26 ms (26509 KB)
>>> >> Creating Database...
>>> >> . 8.37 ms (26509 KB)
>>> >> Creating Database...
>>> >> . 4.32 ms (27175 KB)
>>> >> Creating Database...
>>> >> . 11.38 ms (27175 KB)
>>> >> java.lang.InstantiationException:
>>> >> org.basex.modules.CR_xquery_31_20151217
>>> >> at java.lang.Class.newInstance(Unknown Source)
>>> >> at
>>> >> org.basex.query.util.pkg.ModuleLoader.addImport(ModuleLoader.java:124)
>>> >> at
>>> >> org.basex.query.QueryParser.importModule(QueryParser.java:772)
>>> >> at
>>> >> org.basex.query.QueryParser.importModules(QueryParser.java:758)
>>> >> at org.basex.query.QueryParser.parseMain(QueryParser.java:172)
>>> >> at
>>> >> org.basex.query.QueryContext.parseMain(QueryContext.java:223)
>>> >> at org.basex.query.QueryProcessor.parse(QueryProcessor.java:57)
>>> >> at org.basex.core.cmd.AQuery.parse(AQuery.java:145)
>>> >> at org.basex.core.cmd.AQuery.updates(AQuery.java:159)
>>> >> at org.basex.core.cmd.AQuery.updating(AQuery.java:267)
>>> >> at org.basex.core.Command.execute(Command.java:94)
>>> >> at
>>> >> org.basex.api.client.LocalSession.execute(LocalSession.java:132)
>>> >> at org.basex.api.client.Session.execute(Session.java:36)
>>> >> at org.basex.core.CLI.execute(CLI.java:103)
>>> >> at org.basex.core.CLI.execute(CLI.java:87)
>>> >> at org.basex.BaseX.console(BaseX.java:191)
>>> >> at org.basex.BaseX.<init>(BaseX.java:166)
>>> >> at org.basex.BaseX.main(BaseX.java:42)
>>> >> Caused by: java.lang.NoSuchMethodException:
>>> >> org.basex.modules.CR_xquery_31_20151217.<init>()
>>> >> at java.lang.Class.getConstructor0(Unknown Source)
>>> >> ... 18 more
>>> >> org.basex.query.QueryException: Could not instantiate
>>> >> org.basex.modules.CR_xquery_31_20151217:
>>> >> org.basex.modules.CR_xquery_31_20151217.
>>> >> at org.basex.query.QueryError.get(QueryError.java:1343)
>>> >> at
>>> >> org.basex.query.util.pkg.ModuleLoader.addImport(ModuleLoader.java:127)
>>> >> at
>>> >> org.basex.query.QueryParser.importModule(QueryParser.java:772)
>>> >> at
>>> >> org.basex.query.QueryParser.importModules(QueryParser.java:758)
>>> >> at org.basex.query.QueryParser.parseMain(QueryParser.java:172)
>>> >> at
>>> >> org.basex.query.QueryContext.parseMain(QueryContext.java:223)
>>> >> at org.basex.query.QueryProcessor.parse(QueryProcessor.java:57)
>>> >> at org.basex.core.cmd.AQuery.parse(AQuery.java:145)
>>> >> at org.basex.core.cmd.AQuery.updates(AQuery.java:159)
>>> >> at org.basex.core.cmd.AQuery.updating(AQuery.java:267)
>>> >> at org.basex.core.Command.execute(Command.java:94)
>>> >> at
>>> >> org.basex.api.client.LocalSession.execute(LocalSession.java:132)
>>> >> at org.basex.api.client.Session.execute(Session.java:36)
>>> >> at org.basex.core.CLI.execute(CLI.java:103)
>>> >> at org.basex.core.CLI.execute(CLI.java:87)
>>> >> at org.basex.BaseX.console(BaseX.java:191)
>>> >> at org.basex.BaseX.<init>(BaseX.java:166)
>>> >> at org.basex.BaseX.main(BaseX.java:42)
>>> >> Caused by: java.lang.InstantiationException:
>>> >> org.basex.modules.CR_xquery_31_20151217
>>> >> at java.lang.Class.newInstance(Unknown Source)
>>> >> at
>>> >> org.basex.query.util.pkg.ModuleLoader.addImport(ModuleLoader.java:124)
>>> >> ... 16 more
>>> >> Caused by: java.lang.NoSuchMethodException:
>>> >> org.basex.modules.CR_xquery_31_20151217.<init>()
>>> >> at java.lang.Class.getConstructor0(Unknown Source)
>>> >> ... 18 more
>>> >> org.basex.query.QueryException: Could not instantiate
>>> >> org.basex.modules.CR_xquery_31_20151217:
>>> >> org.basex.modules.CR_xquery_31_20151217.
>>> >> at org.basex.query.QueryError.get(QueryError.java:1343)
>>> >> at
>>> >> org.basex.query.util.pkg.ModuleLoader.addImport(ModuleLoader.java:127)
>>> >> at
>>> >> org.basex.query.QueryParser.importModule(QueryParser.java:772)
>>> >> at
>>> >> org.basex.query.QueryParser.importModules(QueryParser.java:758)
>>> >> at org.basex.query.QueryParser.parseMain(QueryParser.java:172)
>>> >> at
>>> >> org.basex.query.QueryContext.parseMain(QueryContext.java:223)
>>> >> at org.basex.query.QueryProcessor.parse(QueryProcessor.java:57)
>>> >> at org.basex.core.cmd.AQuery.parse(AQuery.java:145)
>>> >> at org.basex.core.cmd.AQuery.updates(AQuery.java:159)
>>> >> at org.basex.core.cmd.AQuery.updating(AQuery.java:267)
>>> >> at org.basex.core.Command.execute(Command.java:94)
>>> >> at
>>> >> org.basex.api.client.LocalSession.execute(LocalSession.java:132)
>>> >> at org.basex.api.client.Session.execute(Session.java:36)
>>> >> at org.basex.core.CLI.execute(CLI.java:103)
>>> >> at org.basex.core.CLI.execute(CLI.java:87)
>>> >> at org.basex.BaseX.console(BaseX.java:191)
>>> >> at org.basex.BaseX.<init>(BaseX.java:166)
>>> >> at org.basex.BaseX.main(BaseX.java:42)
>>> >> Caused by: java.lang.InstantiationException:
>>> >> org.basex.modules.CR_xquery_31_20151217
>>> >> at java.lang.Class.newInstance(Unknown Source)
>>> >> at
>>> >> org.basex.query.util.pkg.ModuleLoader.addImport(ModuleLoader.java:124)
>>> >> ... 16 more
>>> >> Caused by: java.lang.NoSuchMethodException:
>>> >> org.basex.modules.CR_xquery_31_20151217.<init>()
>>> >> at java.lang.Class.getConstructor0(Unknown Source)
>>> >> ... 18 more
>>> >> org.basex.core.BaseXException: Stopped at ., 1/68:
>>> >> [XQST0059] Could not instantiate
>>> >> org.basex.modules.CR_xquery_31_20151217:
>>> >> org.basex.modules.CR_xquery_31_20151217.
>>> >> at org.basex.core.Command.execute(Command.java:101)
>>> >> at
>>> >> org.basex.api.client.LocalSession.execute(LocalSession.java:132)
>>> >> at org.basex.api.client.Session.execute(Session.java:36)
>>> >> at org.basex.core.CLI.execute(CLI.java:103)
>>> >> at org.basex.core.CLI.execute(CLI.java:87)
>>> >> at org.basex.BaseX.console(BaseX.java:191)
>>> >> at org.basex.BaseX.<init>(BaseX.java:166)
>>> >> at org.basex.BaseX.main(BaseX.java:42)
>>> >> Caused by: org.basex.query.QueryException: Could not instantiate
>>> >> org.basex.modules.CR_xquery_31_20151217:
>>> >> org.basex.modules.CR_xquery_31_20151217.
>>> >> at org.basex.query.QueryError.get(QueryError.java:1343)
>>> >> at
>>> >> org.basex.query.util.pkg.ModuleLoader.addImport(ModuleLoader.java:127)
>>> >> at
>>> >> org.basex.query.QueryParser.importModule(QueryParser.java:772)
>>> >> at
>>> >> org.basex.query.QueryParser.importModules(QueryParser.java:758)
>>> >> at org.basex.query.QueryParser.parseMain(QueryParser.java:172)
>>> >> at
>>> >> org.basex.query.QueryContext.parseMain(QueryContext.java:223)
>>> >> at org.basex.query.QueryProcessor.parse(QueryProcessor.java:57)
>>> >> at org.basex.core.cmd.AQuery.parse(AQuery.java:145)
>>> >> at org.basex.core.cmd.AQuery.updates(AQuery.java:159)
>>> >> at org.basex.core.cmd.AQuery.updating(AQuery.java:267)
>>> >> at org.basex.core.Command.execute(Command.java:94)
>>> >> ... 7 more
>>> >> Caused by: java.lang.InstantiationException:
>>> >> org.basex.modules.CR_xquery_31_20151217
>>> >> at java.lang.Class.newInstance(Unknown Source)
>>> >> at
>>> >> org.basex.query.util.pkg.ModuleLoader.addImport(ModuleLoader.java:124)
>>> >> ... 16 more
>>> >> Caused by: java.lang.NoSuchMethodException:
>>> >> org.basex.modules.CR_xquery_31_20151217.<init>()
>>> >> at java.lang.Class.getConstructor0(Unknown Source)
>>> >> ... 18 more
>>> >> Stopped at ., 1/68:
>>> >> [XQST0059] Could not instantiate
>>> >> org.basex.modules.CR_xquery_31_20151217:
>>> >> org.basex.modules.CR_xquery_31_20151217.
>>> >> >
>>> >>
>>> >>
>>> >>
>>> >>
>>> >>
>>> >>
>>> >>
>>> >>
>>> >>
>>> >>
>>> >>
>>> >>
>>> >>
>>> >>
>>> >>
>>> >>
>>> >>
>>> >>
>>> >>
>>> >>
>>> >>
>>> >>
>>> >>
>>> >>
>>> >>
>>> >>
>>> >>
>>> >>
>>> >>
>>> >>
>>> >>
>>> >>
>>> >> On 7 April 2016 at 15:55, Christian Grün <christian.gr...@gmail.com>
>>> >> wrote:
>>> >>>
>>> >>> > If instead I install it to the repo. It appears as
>>> >>> > "org.basex.modules.CR_xquery_31_20151217"
>>> >>> > but
>>> >>> > import module namespace
>>> >>> > p="org.basex.modules.CR_xquery_31_20151217";
>>> >>> > Fails with
>>> >>> > Could not instantiate org.basex.modules.CR_xquery_31_20151217:
>>> >>> > org.basex.modules.CR_xquery_31_20151217
>>> >>> >
>>> >>> > Any ideas where the problem could be?
>>> >>>
>>> >>> It sounds as if it’s not possible to create an instance of this
>>> >>> class.
>>> >>> Could you possibly forward the stack trace (triggered by -d)?
>>> >>
>>> >>
>>> >
>>
>>

Reply via email to