bugGNU Octave - Bugs: bug #48428, Support for java.lang.XXX syntax


bug #48428: Support for java.lang.XXX syntax

Submitted by:  Rik <rik5>
Submitted on:  Wed 06 Jul 2016 10:59:39 PM UTC  
Category: InterpreterSeverity: 1 - Wish
Priority: 5 - NormalItem Group: Matlab Compatibility
Status: NoneAssigned to: None
Originator Name: Open/Closed: Open
Release: devOperating System: Any

Add a New Comment(Rich Markup)

You are not logged in

Please log in, so followups can be emailed to you.


(Jump to the original submission Jump to the original submission)

Wed 10 Aug 2016 11:56:29 AM UTC, comment #11:

A, my failure:
This is java code.
In fact, in matlab constructor is without new.
So i cannot know whether an according form of constructor of arrays works in matlab.

Does anyone have a working matlab at hand??

Ernst Reissner <ernstreissner>
Wed 10 Aug 2016 01:10:16 AM UTC, comment #10:

Is new a keyword in the Matlab language or a function? What happens if you shadow new before trying to create a java array with new in Matlab?

Carnë Draug <carandraug>
Project Member
Tue 09 Aug 2016 11:22:23 PM UTC, comment #9:

I have forgotten:
seemingly also javaArray can be written
in the form java.lang...
in the matlab docs I found in


the snippet:
A = new PackageName.ClassName[x1]...[xN];

Ernst Reissner <ernstreissner>
Tue 09 Aug 2016 11:07:45 PM UTC, comment #8:

This thread concentrates on object creation with javaObject.
But there are still static methods and fields.

Semmingly matlab does not allow static methods
invoked in java style like java.lang.System.load(...)
but i am not sure...

What about set and get fields?
is java.lang.Double.MAX_VALUE possible?
Maybe for set/get only?

Ernst Reissner <ernstreissner>
Sun 31 Jul 2016 08:36:46 PM UTC, comment #7:

The only way I have to check the usefulness of supporting java.XXX only vs a proper fix is via Octave Forge.

Which would suggest that supporting java.XXX only is not that important (almost all of the hits are from the io package and some from ltfat). That kind of makes sense, most of the stuff in the java namespace is core stuff that Octave will already support natively. If it's being used, is for use in java classes outside the java namespace.

Carnë Draug <carandraug>
Project Member
Sun 31 Jul 2016 05:38:19 PM UTC, comment #6:

I borrowed this for pytave because every Python class is prefixed with "py." in Matlab's interface.

I agree this could be used for the "java.xxx" namespace only which may be partially useful, but also misleading since it won't support any other namespaces.

Mike Miller <mtmiller>
Project Administrator
Sat 30 Jul 2016 01:57:09 PM UTC, comment #5:

The hack I proposed on comment #4 is now being used in pytave to support py.foo syntax so maybe it's not that bad and we could consider to support java.XXX only.

One thing that I now realize for supporting this notation on other java namespaces. If we want to cover anything in the javaclasspath, we will have to start the JVM the first time someone calls an undefined function of mistypes a variable name. That's a performance hit we might not want to have.

Carnë Draug <carandraug>
Project Member
Thu 14 Jul 2016 03:11:52 PM UTC, comment #4:

This can be easily worked around for java.X classes with the following class:

Obviously this will not be merged but it might be useful if anyone needs to make some Matlab code work and they only use java.XXX classes.

Carnë Draug <carandraug>
Project Member
Thu 07 Jul 2016 04:45:14 PM UTC, comment #3:

I'd like to leave this up as a stand-alone item. The list on the task tracker is pretty long, and I want to see if we can get this one feature implemented for 4.2.

Rik <rik5>
Project Administrator
Thu 07 Jul 2016 04:25:32 PM UTC, comment #2:

There's task tracker entry (task #12601) where this is also mentioned in your original report.

Should we close this bug and refer to the task tracker?

Philip Nienhuis <philipnienhuis>
Project Member
Wed 06 Jul 2016 11:00:48 PM UTC, comment #1:

More specific examples that work in Matlab, but not Octave

Rik <rik5>
Project Administrator
Wed 06 Jul 2016 10:59:39 PM UTC, original submission:

Matlab supports java.XXX syntax to easily use Java in m-files. Octave only supports the longer form using javaObject, the class name, and any function arguments.

It would be nice to add a little bit of syntactic sugar in the parser to possiby convert


Rik <rik5>
Project Administrator


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by ernstreissner (Posted a comment)
  • -email is unavailable- added by mtmiller (Posted a comment)
  • -email is unavailable- added by rik5 (Submitted the item)

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.


    Please enter the title of George Orwell's famous dystopian book (it's a date):



    No Changes Have Been Made to This Item

    Back to the top

    Powered by Savane 3.1-cleanup1