[Top][All Lists]

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

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

From: Philip Nienhuis
Subject: Re: retrieving a fields of java object with a private constructor
Date: Tue, 8 Jul 2014 11:23:34 -0700 (PDT)

Mike Miller 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(
>> 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 :)
> [1]

It's gone, but as Rik explained to me, java_get's (undocumented) workhorse
__java_get__() still exists in default...
In fact I use that for the io pkg spreadsheet functions when I run 4.1.0+.

Maybe we can persuade the lead devs to keep java_get & java_set around in
4.2.0+ ?

I often wonder why it is necessary to do away with all non-Matlab compatible
constructs just for the sake of Matlab compatibility. It's often quite handy
to have more than one way to get things together.
The syntax change will force me again to recode significant parts of the io
package and keep 2 versions of it around, or find other kludges to have it
working across different Octave versions. Not to mention user confusion.


View this message in context:
Sent from the Octave - General mailing list archive at

reply via email to

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