help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: retrieving a fields of java object with a private constructor


From: Carnë Draug
Subject: Re: retrieving a fields of java object with a private constructor
Date: Tue, 8 Jul 2014 00:21:51 +0100

On 7 July 2014 23:34, Mike Miller <address@hidden> wrote:
>
> On Mon, Jul 7, 2014 at 23:24:44 +0100, Carnë Draug wrote:
> > Hi
> >
> > to access a field from a java object, I would usually do:
> >
> >  x = javaObject (class_name).field_name;
> >
> > However, the class I am trying to use now (loci.formats.FormatTools) [1]
> > does not have a public constructor [2] so the previous fails:
> >
> >> a = javaObject ('loci.formats.FormatTools')
> > Exception in thread "main" java.lang.NoSuchMethodException:
> > loci.formats.FormatTools
> >     at org.octave.ClassHelper.invokeConstructor(ClassHelper.java:402)
> > error: [java] java.lang.NoSuchMethodException: loci.formats.FormatTools
> >
> > This is a not a bug as indeed there is no constructor. How can I access a
> > field value in this case? I am specifically trying to access the field
> > VERSION. It seems that in Matlab, aside the functional form of interacting
> > with java (javaObject and javaMethod), one can do
> >
> >  x = loci.formats.FormatTools.VERSION;
> >
> > which is not yet implemented in Octave.
>
> Yep, see open bug #41239 [1]. You can use java_get() with the java
> package and with Octave version 3.8.0-4.0.x, but it's gone in 4.1.0+
> so classdef had better work with Java for 4.2.0 :)

I am hopeful about creating an Octave package of their Matlab toolbox
[2], while keeping the changes required to the minimum. When I change
their code to use javaMethod() or javaObject(), at least it still work
on both programs. Oh well, I guess I'll just use an is_octave in there
and hope they accept it.

And I will also use the __java_get__ function then since java_get()
prints a deprecated warning which is not nice for the end user. Seems
like classdef is the new thing that will solve all of our
compatibility problems.

Thank you,
Carnë

[2] 
https://github.com/openmicroscopy/bioformats/tree/master/components/formats-gpl/matlab



reply via email to

[Prev in Thread] Current Thread [Next in Thread]